Posts

Writing to linux tty (/dev/) files in c# -

i need program execute command in bash this: "echo p1-12=175 > /dev/servoblaster". how do in mono/c# on linux? wrote following class: public static class servoblasterpwm { private static filestream devfile; public static bool isrunning { get; private set; } public static bool initialize() { try { devfile = file.open("/dev/servoblaster", filemode.open); } catch (exception e) { log.error("error while setting port servo blaster: " + e.message); return false; } log.success("servoblaster set up."); isrunning = true; return true; } public static void setpwmoutput(int pin, int valuesteps) { //byte[] bytes = encoding.ascii.getbytes("p1-" + pin.tostring() + "=" + valuesteps.tostring()); byte[] bytes = encoding.ascii.getbytes("p1-12=175")...

include - How to make CLion use "#pragma once" instead of "ifndef ... def ..." by default for new header files? -

by default, clion add following lines newly created header file: #ifndef some_name_h #define some_name_h .... code here #endif //some_name_h but #pragma once more. how can configure clion uses #pragma once default new header files? go file-> settings -> editor -> file , code templates . find there 3 tabs, namely, templates , includes , , code . under templates choose example c header file . insert #pragma once replace content. every time add new header project menu have template.

php - Nexmo voice call not working -

i have tried execute text speech api in nexmo error: $phoneno = "checkthisout"; $params = "api_key=xxxx&api_secret=xxxxx&to=xxxxx&from=xxxxxx&text=".$phoneno; $url = 'https://api.nexmo.com/tts/json?'; . http_build_query($params); $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); $response = curl_exec($ch); print_r($response); but got new error {"status":"2","error_text":"missing username"} done per url : https://nexmo.github.io/quickstarts/tts/ . i have checked document. don't see such error text. me please? as marc mentioned, expects array parameters, rather string $params = [ 'api_key' => xxxxx, 'api_secret' => xxxxx, 'to' => your_number, 'from' => nexmo_number, 'text' => 'checkthisout', ]; $url = 'https://api.nexmo.com/tts/json?' . http_build_query($...

multithreading - Periodically dump the content of a map to a file in java -

i have 2 json files contain on 1 million objects . i have compare each object both files , write file if there diff object. (each object identified key , key written file). currently using executorservice , doing comparisons using multiple threads , writing mismatches common concurrenthashmap. the map dumped file in end . i update file periodically rather waiting entire execution complete. in case if wish write file once in every 2 minutes, how can achieve this. i familiar done using thread not understand how implement along executorservice. scheduledexecutorservice executor = executors.newsinglethreadscheduledexecutor(); executor.scheduleatfixedrate(() -> { // code execute every 2 minutes }, 0, 2, timeunit.minutes);

javascript - React.js variable -

this question has answer here: reactjs component names must begin capital letters? 4 answers when use variable starting small letter, page showing nothing. if change variable name start uppercase (helloworld) page showing content. <script type="text/jsx"> var helloworld = react.createclass({ render : function () { return ( <div> <h1>hello world</h1> </div> ); } }); react.render(<helloworld/> , document.body); </script> can tell me why happening? as of react v0.12., upper-case components react convention distinguishing between components , html tags. from react documentation under html tags vs. react components header: to render react component, create local variable starts upper-case l...

php - JS/jQuery security -

as beginner, i'm wondering if i'm doing secure. example, finished working on code checks how many times (cross-domain) iframe has been clicked. , when clicked, inserting row mysql (log) table based on ajax request(with jquery) wraps id of iframe $_post: $.ajax({ url: 'execute.php', data: {action: 'some-id'}, type: 'post' }); however i'm wondering: because javascript executed client-side, possible user send fake data through ajax request 'execute.php' page? is possible user send fake data through ajax request 'execute.php' page? yes.

symfony - How to embed radio form field in another radio field -

i'm trying following form: field #1 radio 1 radio 2 radio 3 radio 3.1 radio 3.2 ... radio 4 radio 4.1 radio 4.2 ... when choose radio 3, list of radios show , i'll have choose 1 of children. possible manage kind of form field (i'm talking symfony part, not view , javascript event showing div etc.)? if yes, how? i think problem similar depenend form. idea create listener or subscriber , attach in pre_set_data , submit form event create other list depend of first radio button checked. maybe can follow this post idea.