CPP calling Python, undefined references (Raspberry Pi)

Uncategorized
Question: I am trying to call a python script from my cpp script using the below programs, however the cpp script will not compile saying that there is an undefined reference to Py_Initialize and PyRun_SimpleString. What do I need to do to fix the makefile? (Cpp 11, python 2.7) Cpp:#include #include #include #include #include using namespace std; int main() { Py_Initialize(); while(1) { PyRun_SimpleString("print 'a'"); usleep(1000); } Py_Finalize(); return 0; } My Makefile is:all: myserver myserver: myserver.o g++ myserver.o -o myserver myserver.o: myserver.cpp g++ -c myserver.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7 -L/usr/lib/python2.7/config/ clean:rm -rf *o myserver This seemed to work, not a good solution though:all: myserver myserver:g++ myserver.cpp -std=c++11 -I/usr/include/python2.7 -lpython2.7 -L/usr/lib/python2.7/config/ -o myserver clean:rm -rf *o myserver Answer: Read more
Read More

How to set temporary values

Uncategorized
Question: I'm tired of having to go about things this way. I want to be able to set a value to something and have it quickly get/set back to the state it was at before. static int FixJump=false; if (NeedsToJump) { m_InputData[pD].m_Jump = 1; FixJump = true; } else if (FixJump) { m_InputData[pD].m_Jump = 0; FixJump = false; } I tried to do something like this:m_InputData[pD].m_Jump = (1 + 0) - m_InputData[pD].m_Jump; But this method proved defective and didn't work properly. Answer: Read more
Read More

@match regex not working

Uncategorized
Question: I'm trying to condense // @match https://www.groovypost.com/* // @match https://www.instagram.com/ // @match http://www.ketv.com/* // @match http://www.snopes.com/* // @match http://www.thewindowsclub.com/* to //match //(http|https)://www.(groovypost|instagram|ketv|snopes|thewindowsclub).com/.+ but it fails to work, in my test (http://regexr.com/3gi94) it worked fine? Answer: Read more
Read More

Woocommerce 3 – translate Related Products

Uncategorized
Question: I used to have the following function working to change to Related Products text in Woocommerce. function my_text_strings( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Related Products' :$translated_text = __( 'Related Books', 'woocommerce' ); break; } return $translated_text; } add_filter( 'gettext', 'my_text_strings', 20, 3 ); It always worked perfectly, but as of Woocommerce version 3.0 or so, this function no longer works. How should I fix this in order to make it working in the version 3.0 and up? Answer: Try this, it's working with me add_filter( 'gettext', 'wps_translate_words_array' ); add_filter( 'ngettext', 'wps_translate_words_array' ); function wps_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' 'Related Products' => 'Check out these related products', ); $translated = str_ireplace( array_keys($words), $words, $translated );…
Read More

Maze generator algorithm

Uncategorized
Question: I need a maze generator algorithm and I looked at some but I need some special conditions:It needs to be customizable in some way to change the difficulty of the maze It needs to be able to be used in a variety of arrangements ( for example hexagonal grid) I need to after that be able to find a solution for it. (so it can't be graphical for example because I need to traverse the maze after that to find a solution) Answer: Read more
Read More

Merging separate git repos into one

Uncategorized
Question: I can use a hand coming up with the right way to do this. I've got a TFVC style repository in which there are several branches. I want to move the entire thing over to git. I'm using git tfs (https://github.com/git-tfs/git-tfs) to export the TFVC stuff to local git repos, but the history is too complex and therefore I cannot export all of the branches at once. That in itself is not a problem since we also want to migrate to a different branching strategy whilst at it. What the plugin does allow me is to export each individual branch with a subset of its history to a local git repo. So I end up with local repos for "master" and one for every release that has been stored…
Read More

Fixed Anchors Rotation

Uncategorized
Question: I'm trying to mess around with Apple's default ARKit (using SpriteKit) demo that has an emoji text appear in from of the camera. When trying to place multiple Anchors and move around them, the Anchors seem to rotate in order to face the camera. Is there a way to disable the automatic rotation of the Anchors? P.S: I won't be sharing the code since whoever have access to xCode 9 has it. Plus I didn't add any changes. Answer: Read more
Read More

c# Message Message Queue Count. – Sharing violation resulted from queue being open already for exclusive receive

Uncategorized
Question: So I am busy writing an Watchdog for message queue installed on one of my servers. I have a application ( 3rd party ) that is listening on the queue and processing the messages. I now want to do a count on it and if message reach example 1500 I send a email. So all my code works except that I need to close the 3rd party app to use the message queue. What I do is I get all the queue names that exist. Work fine. public void GetPrivateQueues() { MessageQueue[] QueueList = MessageQueue.GetPrivateQueuesByMachine("."); foreach (MessageQueue queueItem in QueueList) { i++; myPrivateQueues.Add(queueItem.Path); Count(queueItem.Path); } return; } So when I do the count of the queue like this public void Count(String path) { MessageQueue queue = new MessageQueue(path); MessageEnumerator…
Read More