MoonMail setup/required variables - moonmail

I'm trying to setup MoonMail using their guide on the project GitHub which mentions
Add variables to s-variables-<stage>-<region>:
But not what variables are even required? Trying to set the one variable mentioned (apiHost) and doing a sls resources deploy causes a failure.
Anyone actually managed to set this project up on AWS?

These variables should suffice:
apiHost
defaultRegion
clicksRCU
clicksReportRCU
clicksReportWCU
clicksWCU
defaultRCU
defaultWCU
opensRCU
opensReportRCU
opensReportWCU
opensWCU
recipientsRCU
recipientsWCU
scheduledAtIndexRCU
scheduledAtIndexWCU
scheduledCampaignsRCU
scheduledCampaignsWCU
sentEmailsRCU
sentEmailsWCU
defaultApiKey
defaultApiSecret
defaultEmailAddress
defaultFromName
stage
iotEndpoint

Related

Update Parent Scope Variable Without Passing By Reference

I'm currently working on a PowerShell module, and I've come across something rather unusual that I cannot figure out how to duplicate. I'm using a module from Az PowerShell 3.2.0 as a reference.
I have the following example from Microsoft's Az.Dns Module:
https://learn.microsoft.com/en-us/powershell/module/az.dns/Add-AzDnsRecordConfig
$RecordSet = Get-AzDnsRecordSet -Name www -RecordType A -ResourceGroupName MyResourceGroup -ZoneName myzone.com
Add-AzDnsRecordConfig -RecordSet $RecordSet -Ipv4Address 1.2.3.4
Set-AzDnsRecordSet -RecordSet $RecordSet
The $RecordSet variable is being set locally, passed as a parameter to the Add-AzDnsRecordConfig command of this module, and the value of the $RecordSet local variable is then being automatically updated. When this variable is passed to the Set-AzDnsRecordSet command as a parameter, it contains the updated value it was assigned and not its initial value. Note that there is no additional assignment statement of the return value of Add-AzDnsRecordConfig.
How is this possible?
I know that I can define a function parameter as type [ref] or System.Management.Automation.PSReference and then pass by reference when it is called as function -param ([ref]$myVariable). I can then update the value using $myVariable.Value, but that is not what is happening here. Somehow, this variable is being passed by value, and the value is being updated back in the local scope as if it were passed by reference.
Changing the name of the local variable also does not break this functionality. I've also done a Show-Command -Name Add-AzDnsRecordConfig and I can confirm that the type is not System.Management.Automation.PSReference.
I have a need to duplicate this functionality as closely as possible, as I am building a wrapper of sorts around this, but I am not sure how Microsoft is making this magic happen within this command.
#zett42 Thank you for the concise answer. I definitely over-complicated this, and I did not realize that objects were automatically passed by reference without the need to specify it. As it turns out, I can simply reference the parameter within the function as $RecordSet.Property = "New Value".
Back in the local scope, that does update the initially defined variable.
https://johnfabry.azurewebsites.net/2015/06/26/powershell-reference-types-and-value-types/
This article also helped me to understand how this works.

Arduino and STL

I know this has been posted all over the place but I can not find what I need. I have a Arduino project that I must have vector or another way of allocating a dynamic array safely. I am trying to get the "StandardCplusplus" library to compile but I am getting an error
'Starting combiner'
"C:\Eclipse\eclipse\arduinoPlugin\tools\arduino\avr-gcc\4.8.1-arduino5/bin/avr-gcc" -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "D:/Development/MegaTesting/Release/MegaTesting.elf" ./.ino.cpp.o ./libraries/StandardCplusplus/algorithm.cpp.o ./libraries/StandardCplusplus/associative_base.cpp.o ./libraries/StandardCplusplus/bitset.cpp.o ./libraries/StandardCplusplus/char_traits.cpp.o ./libraries/StandardCplusplus/complex.cpp.o ./libraries/StandardCplusplus/del_op.cpp.o ./libraries/StandardCplusplus/del_opnt.cpp.o ./libraries/StandardCplusplus/del_opv.cpp.o ./libraries/StandardCplusplus/del_opvnt.cpp.o ./libraries/StandardCplusplus/deque.cpp.o ./libraries/StandardCplusplus/eh_alloc.cpp.o ./libraries/StandardCplusplus/eh_globals.cpp.o ./libraries/StandardCplusplus/exception.cpp.o ./libraries/StandardCplusplus/fstream.cpp.o ./libraries/StandardCplusplus/func_exception.cpp.o ./libraries/StandardCplusplus/iomanip.cpp.o ./libraries/StandardCplusplus/ios.cpp.o ./libraries/StandardCplusplus/iostream.cpp.o ./libraries/StandardCplusplus/istream.cpp.o ./libraries/StandardCplusplus/iterator.cpp.o ./libraries/StandardCplusplus/limits.cpp.o ./libraries/StandardCplusplus/list.cpp.o ./libraries/StandardCplusplus/locale.cpp.o ./libraries/StandardCplusplus/map.cpp.o ./libraries/StandardCplusplus/new_handler.cpp.o ./libraries/StandardCplusplus/new_op.cpp.o ./libraries/StandardCplusplus/new_opnt.cpp.o ./libraries/StandardCplusplus/new_opv.cpp.o ./libraries/StandardCplusplus/new_opvnt.cpp.o ./libraries/StandardCplusplus/numeric.cpp.o ./libraries/StandardCplusplus/ostream.cpp.o ./libraries/StandardCplusplus/queue.cpp.o ./libraries/StandardCplusplus/set.cpp.o ./libraries/StandardCplusplus/sstream.cpp.o ./libraries/StandardCplusplus/stack.cpp.o ./libraries/StandardCplusplus/stdexcept.cpp.o ./libraries/StandardCplusplus/streambuf.cpp.o ./libraries/StandardCplusplus/string.cpp.o ./libraries/StandardCplusplus/support.cpp.o ./libraries/StandardCplusplus/typeinfo.cpp.o ./libraries/StandardCplusplus/utility.cpp.o ./libraries/StandardCplusplus/valarray.cpp.o ./libraries/StandardCplusplus/vector.cpp.o arduino.ar "-LD:/Development/MegaTesting/Release" -lm
arduino.ar(new.cpp.o): In function `operator new[](unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:26: multiple definition of `operator new[](unsigned int)'
./libraries/StandardCplusplus/new_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/new_opv.cpp:24: first defined here
c:/eclipse/eclipse/arduinoplugin/tools/arduino/avr-gcc/4.8.1-arduino5/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
arduino.ar(new.cpp.o): In function `operator new(unsigned int)':
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp:22: multiple definition of `operator delete[](void*)'
makefile:83: recipe for target 'MegaTesting.elf' failed
./libraries/StandardCplusplus/del_opv.cpp.o:C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/libraries/StandardCplusplus/del_opv.cpp:25: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [MegaTesting.elf] Error 1
06:23:57 Build Finished (took 21s.666ms)
I have searched here and online and there seems to be a bunch of fixes but none of them work. There was some mention of including a pnew.cpp in one of your files but this file is not in the library anywhere.
All my code contains that I am trying to compile is
#include "StandardCplusplus.h"
#include "Arduino.h"
void setup(void) {
Serial.begin(57600);
}
void loop(void) {
}
There are a couple of versions of this library out there and I have tried the two main forks that I can find and both of them generate this error.
Also I am using Eclipse with the Arduino AVR plugin to compile.
Edit
I thought that commenting out the lines did work until I tried to use a vector. Once I did the StandardCplusplus library got really mad saying that the function new was not defined.
I think that there needs to be something done to the StandardCplusplus library like in new/new_opv delete/delete_opv files? Or is there a better way?
Edit - 2
Alright so I went into the files:
StandardCplusplus/new_opv.h
StandardCplusplus/del_opv.h
And commented out the bodies for the functions and everything seems to be happy. I did a simple test and everything looks like it is working but now I am concerned that I might of removed something that something else in the library might need, can anyone tell me if my changes will hurt anything?
Edit - 3
Well the last fix didn't work so I tried going to another library all together and I am allot closer. I Downloaded this STL-AVR library and had to make a minor edit to vector.h now I am having problems with the pnew.cpp file. Looks like the template is calling a "new" function that is now defined in arduino but if I try to comment out this body I get that it is not defined. I am sure this is some sort of order of the includes or missing one can anyone help?
Those STL like libary versions you have were put together before operator new was added to the Arduino core. Now they are in the core you are getting a multiple definition error.
You can go into your core and comment out the bits causing the multiple definition error.
You can probably just get away with commenting out the function definitions in the .cpp:
C:/Eclipse/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.10/cores/arduino/new.cpp
If you still get the errors, also comment out the function declarations in new.h, but you shouldn't need to as multiple declarations are allowed, only definitions must be unique.

How can I avoid duplicated symbol errors when I use static libraries with Cocoapods?

I've got a executable target called Foobar, a static library holding some common code called FoobarCommon, and a test target specifically for the common code called FoobarCommonSpecs.
Unsurprisingly, I have made both Foobar and FoobarCommonSpecs depend on the FoobarCommon library.
The Podfile looks something like the below:
target 'FoobarCommon' do
pod 'ReactiveCocoa'
...
end
target 'Foobar' do # links against to FoobarCommon in Xcode
...
end
target 'FoobarCommonSpecs' do # links against to FoobarCommon in Xcode
pod 'LLReactiveMatchers', :git => 'https://github.com/lawrencelomax/LLReactiveMatchers.git'
end
LLReactiveMatchers is a Pod that depends on ReactiveCocoa.
Note that in this situation, ReactiveCocoa is prsent in both FoobarCommon and also in FoobarCommonSpecs
The Problem
Whenever I run FoobarCommonSpecs, I get many duplicate symbol errors for ReactiveCocoa.
I want to say to Cocoapods that it should just IGNORE LLReactiveMatcher's dependency on ReactiveCocoa. It should just let Xcode do its job and it should link with the copy of ReactiveCocoa found in FoobarCommon. How do I do that?
Does the link_with directive have anything to do with anything?

How can I start multiple Tornado Server instances in multiple ports

I need to start the blog demo in the following ports:
127.0.0.1:8000
127.0.0.1:8001
127.0.0.1:8002
127.0.0.1:8003
When I run the application using:
./demos/blog/blog.py
it starts in port 8888 as defined by:
define("port", default=8888, help="run on the given port", type=int)
How do I run multiple instances in multiple ports?
I found what I was looking for:
./demos/blog/blog.py --port=8889
you can register several ports when creating a handler
application = tornado.web.Application([
(r".*", MainHandler),
], **app_settings)
application.listen(8080)
application.listen(8081)
Make sure you know, the --port option gets parsed by the options module of the Tornado framework.
The lines that looks like this:
define("port", default=8888, help="Port to listen on", type=int)
and later there's a call to the options module that parses command line vars automatically.
I'm just giving you this because you might want to later specify different variables in your programs that you design around the framework that you may want to change instance to instance.
Use supervisord to start multiple instances. Since each app takes the --port= argument you can set something like this up:
Here's the setup I use for Around The World
[group:aroundtheworld]
programs=aroundtheworld-10001,aroundtheworld-10002,aroundtheworld-10003
[program:aroundtheworld-10001]
command=/var/lib/tornado/aroundtheworld/app.py --port=10001
directory=/var/lib/tornado/aroundtheworld/
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado/aroundtheworld-10001.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
[program:aroundtheworld-10002]
command=/var/lib/tornado/aroundtheworld/app.py --port=10002
directory=/var/lib/tornado/aroundtheworld/
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado/aroundtheworld-10002.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
[program:aroundtheworld-10003]
command=/var/lib/tornado/aroundtheworld/app.py --port=10003
directory=/var/lib/tornado/aroundtheworld/
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado/aroundtheworld-10003.log
stdout_logfile_maxbytes=500MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
If you need help with how to set up Nginx or something similar to load balance across these then submit a new question.
copy /demos/blog/blog.py to blog_otherports.py
change posts in blog_otherports.py
and python blog_otherports.py
you need to run two processes

How to resolve naming conflicts when multiply instantiating a program in VxWorks

I need to run multiple instances of a C program in VxWorks (VxWorks has a global namespace). The problem is that the C program defines global variables (which are intended for use by a specific instance of that program) which conflict in the global namespace. I would like to make minimal changes to the program in order to make this work. All ideas welcomed!
Regards
By the way ... This isn't a good time to mention that global variables are not best practice!
The easiest thing to do would be to use task Variables (see taskVarLib documentation).
When using task variables, the variable is specific to the task now in context. On a context switch, the current variable is stored and the variable for the new task is loaded.
The caveat is that a task variable can only be a 32-bit number.
Each global variable must also be added independently (via its own call to taskVarAdd?) and it also adds time to the context switch.
Also, you would NOT be able to share the global variable with other tasks.
You can't use task variables with ISRs.
Another Possibility:
If you are using Vxworks 6.x, you can make a Real Time Process application.
This follows a process model (similar to Unix/Windows) where each instance of your program has it's own global memory space, independent of any other instance.
I had to solve this when integrating two third-party libraries from the same vendor. Both libraries used some of the same symbol names, but they were not compatible with each other. Because these were coming from a vendor, we couldn't afford to search & replace. And task variables were not applicable either since (a) the two libs might be called from the same task and (b) some of the dupe symbols were functions.
Assume we have app1 and app2, linked, respectively, to lib1 and lib2. Both libs define the same symbols so must be hidden from each other.
Fortunately (if you're using GNU tools) objcopy allows you to change the type of a variable after linking.
Here's a sketch of the solution, you'll have to modify it for your needs.
First, perform a partial link for app1 to bind it to lib1. Here, I'm assuming that you've already partially linked *.o in app1 into app1_tmp1.o.
$(LD_PARTIAL) $(LDFLAGS) -Wl,-i -o app1_tmp2.o app1_tmp1.o $(APP1_LIBS)
Then, hide all of the symbols from lib1 in the tmp2 object you just created to generate the "real" object for app1.
objcopymips `nmmips $(APP1_LIBS) | grep ' [DRT] ' | sed -e's/^[0-9A-Fa-f]* [DRT] /-L /'` app1_tmp2.o app1.o
Repeat this for app2. Now you have app1.o and app2.o ready to link into your final application without any conflicts.
The drawback of this solution is that you don't have access to any of these symbols from the host shell. To get around this, you can temporarily turn off the symbol hiding for one or the other of the libraries for debugging.
Another possible solution would be to put your application's global variables in a static structure. For example:
From:
int global1;
int global2;
int someApp()
{
global2 = global1 + 3;
...
}
TO:
typedef struct appGlobStruct {
int global1;
int global2;
} appGlob;
int someApp()
{
appGlob.global2 = appGlob.global1 + 3;
}
This simply turns into a search & replace in your application code. No change to the structure of the code.