Posts

php - Find the network distance between two IPv4 addresses (not geographic distance) -

given ipv4 address (needle) , unsorted array of ipv4 addresses (haystack), how programmatically determine single address in given haystack closest (network-wise, not geographically) needle? since don't have access netmask of every address, solution should ignore netmasks , traceroute alike options. all sorts of addresses used, mean: private, reserved, broadcast, lan , wan. any in form of theory, pseudo-code, python, php or perl welcome. the question getting ip address list between 2 ip addresses similar, quite cut it. i'm still not quite sure you're asking, based on comment @petergibson closest meant, 192.168.1.101 closer 192.168.56.1 172.30.130.66 . , 192.168.1.254 closer 192.168.1.240 192.168.2.1 you try following python code distance function: import socket def dist(a, b): def to_num(addr): # parse address string integer quads quads = map(ord, socket.inet_aton(addr)) # spread quads out return reduce(l...

html - use width inside of calc -

i trying this: .my-style { width: 50px; margin-left: calc(50% - calc(width / 2)); } later changing width 90px , want margin grow accordingly. doesn't work. possible? the newest browser's should support it, tried following code. this webkit example made, check in chrome css p { -webkit-var-a: -webkit-calc(1px + 3px); margin-left:-webkit-calc(-webkit-var(a) + 5px); } html <p>this text should have margin-left, doesn't</p> fiddle http://jsfiddle.net/uqe8b/ if inspect <p> element can see see code valid, doesn't anything... seems have use javascript, less or equivelent it's still experimental feature. edit: it does seem work when make var plain number: p { -webkit-var-a: 3px; margin-left:-webkit-calc(-webkit-var(a) + 5px); } http://jsfiddle.net/uqe8b/1/ so answer question, yes possible, not recommend now. css .my-style { height:100px; background-color:bl...

why ffmpeg is not working in new installation -

i working on live encoding ffmpeg last few days. 1 day re-installed os , tried run ffmpeg commands again after configuration. publish points in starting not started. why? missing configuration required? the command trying run is: ffmpeg -y -re -i d:\video2.mp4 -pix_fmt yuv420p -movflags isml+frag_keyframe -f ismv -threads 0 -c:v libx264 -preset fast -profile:v baseline -map 0:v -b:v:0 800k http://localhost/pps/publishpoint.isml/streams(encode r1) output got in command prompt is: ffmpeg version n-54772-g53c853e copyright (c) 2000-2013 ffmpeg developers built on jul 16 2013 22:25:42 gcc 4.7.3 (gcc) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-...

Use library Windows.Networking.Sockets ( metro app ) in a dekstop app c# -

recently i've developped c# metro app works , want developp same app in c#. i've done few things enable use of metro app library website library windows.networking.proximity still working, windows.security.cryptography apparently windows.networking.sockets doesn't work. goal in part of code, receive data sent smartphone wifi: namespace openitformedesktop{ class server { private streamsocketlistener serverlistener; public static string port = "3011"; public static string adressip = "192.168.173.1"; private hostname hostname; //initialize server public server() { serverlistener = new streamsocketlistener(); hostname = new hostname(adressip); listen(); } //create listener waiting connection private async void listen() { serverlistener.connectionreceived += onconnection; try { //await serverlistener.bindendpointasync(hostname, port); ...

java - Refresh TabActivity on TabHost -

i have same code: public class mainactivity extends tabactivity { private tabhost mtabhost; private void setuptabhost() { mtabhost = (tabhost) findviewbyid(android.r.id.tabhost); mtabhost.setup(); } @override protected void oncreate(bundle savedinstancestate) { setcontentview(r.layout.activity_main); // create tabs , etc... setuptabhost(); mtabhost.gettabwidget().setdividerdrawable(r.drawable.tab_divider); setuptab(new textview(this), "category", "category.class"); setuptab(new textview(this), "top", "top.class"); setuptab(new textview(this), "favorite", "favorite.class"); } private void setuptab(final view view, final string tag, final string classname) { view tabview = createtabview(mtabhost.getcontext(), tag); tabhost tabhost = gettabhost(); tabhost.tabspec spec; intent intent; intent = new intent().setclass(this, category....

How to directly upload files from browser to Google Cloud in Rails -

i have rails app allows users upload files. upload (via post) server, uses fog gem upload google cloud storage. problem files universally available knows url, want prevent. so have 2 issues i'd solve: i'd enable users upload google directly browsers i'd prevent downloading files, users logged app i have downloaded p12 file google api generated, i'm stuck. according documentation need generate key (done google-api-client gem) , signature (not done) , put post headers if understood correctly? does has example use? edit: got done, secret in interoperable storage access keys , sha1 , google documentation doesn't say. i'll cover solution in blog post shortly. here example of generating signed urls in python . details different in ruby, process same.

simulation - C++ simulate pressing of equal sign (=) and question mark (?) -

having problems simulating keypress of equal sign (=) , question mark (?). figured if there's no virtual key code two, should combine key presses , releases guy did ctrl-v: http://batchloaf.wordpress.com/2012/10/18/simulating-a-ctrl-v-keystroke-in-win32-c-or-c-using-sendinput/ my code "=" (shift + "+"): input ip; ip.type = input_keyboard; ip.ki.wscan = 0; // hardware scan code key ip.ki.time = 0; ip.ki.dwextrainfo = 0; ip.ki.wvk = vk_lshift; ip.ki.dwflags = 0; // 0 key press sendinput(1, &ip, sizeof(input)); // press "+" key ip.ki.wvk = vk_oem_plus; ip.ki.dwflags = 0; // 0 key press sendinput(1, &ip, sizeof(input)); // release "+" key ip.ki.wvk = vk_oem_plus; ip.ki.dwflags = keyeventf_keyup; sendinput(1, &ip, sizeof(input)); // release "shift" key ip.ki.wvk = vk_lshift; ip.ki.dwflags = keyeventf_keyup; sendinput(1, &ip, sizeof(input)); it outputs "+" sign. need work on, preferably windows os,...