Posts

Showing posts from March, 2012

c - how to disable fast frames in ath5k wireless driver -

by default, fast frames enabled in ath5k. ( http://wireless.kernel.org/en/users/drivers/ath5k ) have found macro disables it #define ar5k_eeprom_ff_dis(_v) (((_v) >> 2) & 0x1 the question do it? replace above line #define ar5k_eeprom_ff_dis(_v) 1 ? do compile passing parameter? the bit-shift expression confuses me. _v variable? the question more general how deal such macros in drivers. i've seen them in other codes , got confused. ok, try explain simplified example #include <stdio.h> /* print in binary mode */ char *chartobin(unsigned char c) { static char a[9]; int i; (i = 0; < 8; i++) a[7 - i] = (c & (1 << i)) == (1 << i) ? '1' : '0'; a[8] = '\0'; return a; } int main(void) { unsigned char u = 0xf; printf("%s\n", chartobin(u)); u >>= 2; // shift bits 2 positions (to right) printf("%s\n", chartobin(u)); ...

bash - I'm trying to create a script that'll delete all files which have a bitrate less than 130 kbps -

to #!/bin/bash find ./ -name '*.mp3' | while read -r i; echo "----------------------------------------" if [ $(mp3info -x "$i" | grep audio | awk '{print $2}') < 130 ] read -p "delete? " -n 1 -r if [[ $reply =~ ^[yy]$ ]] rm -f "$i" && echo "$i succesfully deleted!" fi fi echo "----------------------------------------" done it stops output: error opening mp3: /like prayer/madonna - act of contrition.mp3: no such file or directory it looks there error filepath, cause leading dot missing. i think ifs set value ".". also, compare integers, use [[ ]]: #!/bin/bash find ./ -name '*.mp3' | while ifs='' read -r i; echo "----------------------------------------" if [[ $(mp3info -x "$i" | grep audi...

wordpress redirect loop on the login page (wp-login.php) -

i working on wordpress site (3.0.1) ok. can't login admin bo. have endless redirection ! i have tried : cleaning cookies, disable plugins... i have added : @define('admin_cookie_path', '/'); on wp-config.php, nothing changes . can please ? thanks you can try these steps. log in wordpress database using phpmyadmin. go wp_options table , go page two. remove active plugins. if have backup of old database paste plugins in. or 1) backup .htaccess file on hard drive 2) delete .htaccess file root of server 3) go blog’s admin panel , log-in 4) on left sidebar, go settings –> general , changes wordpress address , blog address include www (so should http://www.domainname.com instead of http://domainname.com ). 5) save settings 6)take .htaccess backup , reupload root of server/directory

(Rails app Api) Send data via HTTP and receive JSON or XML -

i'm building simple calculator courier company. calculator should receive data via http request: weight, origin city , destination city. calculator should send json or xml: price. sounds simple, can't find usable information how handle http request. as understand request should this: localhost?weight=20&origin="almaty"&destination="moscow" but have no idea how handle rails. how obtain these variables in http? you have use sockets client make http request, receive on socket, compute , send him result. documentation url attributes parser: http://www.ruby-doc.org/stdlib-2.0/libdoc/cgi/rdoc/cgi.html#m000075 this might edit: require 'cgi' cgi::parse('param1=value1&param2=value2&param3=value3') returns sth that: {"param1"=>["value1"], "param2"=>["value2"]}

Android apps - are users automatically notified of new versions -

are there special requirements app should obey ensure users notofied when update available? (my current app freeware if matters) google play shows automatic update once release newer version of app in google play. update can see if user visits app in google play. if want show update notification @ launch of application, coding required. you can write code inside start of application read file server, contains version number of app. evereytime update application, can change version number in server. so, once app gets different version number compared t previous 1 saved in sharedpreference, can write logic launch googleplay update app , update sharedpreference latest version number. hope understand trying say.

animation - Convert 3D data into maya anim file -

Image
i'm working on collecting data kinect skeleton model contains 23 3d-point/set @ time, , convert them .anim file can load unity , make character move. there solution so? convert 3d data .anim file? p.s. have 3d-data stored in format [time|x|y|z]. if you're on windows can use brekel's tools (have @ workflow tutorial ) if can write bit of code, can try this approach .

c++ - how can I use std::enable_if in a conversion operator? -

basically want range type implicitly convertible range<const char> range<const unsigned char> . std::enable_if seems impossible because function takes no arguments , has no return. whats work around? here tried: template<typename t> class range{ t* begin_; t* end_; public: range(t* begin,t* end):begin_{begin},end_{end}{} template<int n> range(t (&a)[n]):begin_{static_cast<t*>(&a[0])},end_{static_cast<t*>(&a[n-1])}{} t* begin(){return begin_;} t* end(){return end_;} operator typename std::enable_if<std::is_same<t,const char>::value,range<const unsigned char>&>::type (){ return *reinterpret_cast<range<const unsigned char>*>(this); } }; make template dummy parameter defaults t - postpone type deduction point function gets instantiated, otherwise sfinae doesn't work . check want in default value of parameter. template< typename u = t, ...

javascript - confusion with instanceof Array and String -

this question has answer here: why instanceof return false literals? 10 answers i read instanceof answer ,but have question when code ["a","b"] instanceof array why reutrns true same new array("a","b") instanceof array while "a" instanceof string returns false not same new string("ab") instanceof string ? appreciate answers , help! for strings, have both primitive strings (the ones manipulate of times, , literals) and instances of string class. and they're not same. here's what mdn says on distinction between both . another way see difference, mdn doesn't point, can add properties on objects : var = "a"; a.b = 3; // doesn't add property wrapped copy console.log(a.b); // logs undefined = new string("a"); a.b = 3; console.log(a.b); ...

java - How to embed JasperReports Viewer in web application -

the following code launch report in jasperviewer generated jrxml net.sf.jasperreports.view.jasperviewer jv = new net.sf.jasperreports.view.jasperviewer(jasperprint); jv.viewreport(jasperprint,false); how can embed same viewer web application, user can able use same, can applet or else 1 knows other way work around?

c# - Reflecting a WinRT executable from a .Net 4.x App -

in console application; if execute: assembly.loadfrom(@"c:\...\mywinrtapp.exe") i get: system.badimageformatexception occurred hresult=-2147024885 message=could not load file or assembly 'file:///c:\_...\mywinrtapp.exe' or 1 of dependencies. attempt made load program incorrect format. source=mscorlib is there way around this? edit 1 in relation "vyacheslav volkov"'s answer below, step further, thank you. different issue. "assembly.getexportedtypes()" throws "cannot resolve dependency windows runtime type 'windows.ui.xaml.application'. when using reflectiononly apis, dependent windows runtime assemblies must resolved on demand through reflectiononlynamespaceresolve event." if try reflectiononlyload referenced assemblies, error: "could not load file or assembly 'windows, version=255.255.255.255, culture=neutral, publickeytoken=null, contenttype=windowsruntime' or 1 of dependencies. operation no...

SVG animation inside svg:use element. Works in Firefox, not in Chrome -

i'm using svg:use element embed animating svg spinner inside large d3.js tree many nodes. one node looks this: <g class="node clickable" data-path="1" data-depth="0" transform=""> <text class="title" x="0" y=".36em" style="fill-opacity: 1;" text-anchor="begin">model</text> <text class="subtitle" x="0" y="2em" style="fill-opacity: 1;" text-anchor="begin"> <use href="static/spinner.svg#spinner" transform="translate(54.75,-9) rotate(0 7,9)"> </g> i use jquery insert spinner when needed in 1 of many g.node elements in tree. the svg source of spinner follows: <?xml version="1.0" encoding="utf-8"?> <!doctype svg public "-//w3c//dtd svg 1.1//en" "http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd"> <svg id="spinner...

php - Abstract class calling a method from the wrong child class -

i have abstract class extended several other classes, each abstract method called child_save_changes() . one of methods in template class called on_save_changes() , , whenever user clicks 'submit', method called page. the on_save_changes() method first sets class variables required validating/saving, calls child_save_changes() , , handles redirection referring page. the problem is, because i'm calling on_save_changes() via callback page, doesn't know child class call abstract method child_save_changes() from, , it's picking first 1 finds. it seems inefficient repeat code in each child_save_changes() method, i'm wondering if has come across similar scenario in past, , actions took fix issue? thanks. it sounds me using static methods. otherwise problem describe cannot reasonably occur. you wrote, " on_save_changes() not know child class call abstract method child_save_changes() from". ordinary (i.e., non-static) methods not c...

java - How do you override the null serializer in Jackson 2.0? -

i'm using jackson json serialization, , override null serializer -- specifically, null values serialized empty strings in json rather string "null". all of documentation , examples i've found on how set null serializers refers jackson 1.x -- example, code @ bottom of http://wiki.fasterxml.com/jacksonhowtocustomserializers no longer compiles jackson 2.0 because stdserializerprovider no longer exists in library. web page describes jackson 2.0's module interface, module interface has no obvious way override null serializer. can provide pointer on how override null serializer in jackson 2.0? override jsonserializer serialize method below. public class nullserializer extends jsonserializer<object> { public void serialize(object value, jsongenerator jgen, serializerprovider provider) throws ioexception, jsonprocessingexception { // json value want... jgen.writestring(""); } } and create custom object mapper , set nullseari...

php - How to set cron for every min in godaddy server. -

i need execute cron job every minute, possible in godaddy hosting? there way of configuring it? thanks. using godaddy's cron job manager, could create 6 individual cron jobs execute twice hourly. set twice hourly minutes execute each task at: job 1: x:0-30 job 2: x:5-35 job 3: x:10-40 job 4: x:15-45 job 5: x:20-50 job 6: x:25-55

c# - Integrate twitter in windows phone 8 app -

i developing windows phone 8 application, in need integrate twitter. tried many ways got in search. so please me out if used it. thanks in advance. edit using tweetsharp; using system.io.isolatedstorage; public partial class mainpage : phoneapplicationpage { twitterservice service; private const string consumerkey = "some key"; private const string consumersecret = "some key1"; private oauthrequesttoken requesttoken; private oauthaccesstoken accestoken; private bool userauthenticated = false; public mainpage() { initializecomponent(); service = new twitterservice(consumerkey, consumersecret); //chek if have autehntification data var token = getaccesstoken(); if (token != null) { service.authenticatewith(token.token, token.tokensecret); userauthenticated = true; } } private void tweetclick(object sender, routedeventargs e) { if...

android - Download Manager crashing when calling from child activity -

i facing head scratching issue , not able resolve. can here help... i have 1 activity (parent) starts activity(child). , initiating download manager child activity. when clicking button on child activity view downloads, opens download manager , shows downloads. till point goes fine. when return download view window pressing return key, of time crashing (specially when download completed). don't know why.. note: when initiate download manager parent activity, works well. need child. appreciated. i starting child activity like: lv.setonitemclicklistener(new adapterview.onitemclicklistener(){ public void onitemclick(adapterview<?> p, view v, int position, long id) { intent = new intent(audiodownloadactivity.this,cdpageactivity.class); i.putextra("audiocdurl", "http://bkdrluhar.com/00-htm/" + hiddentext); i.setflags(intent.flag_activity_new_task); audiodownloadactivity.this.startactivity(i); }}); in child activity, defining , init...

android - Start new Activity On Sensor Changed? -

how can start new activity on accelererometer (on shake): when shake phone app crashes - accelerometer run in background public class shaker_service extends service implements sensoreventlistener{ private static final string tag = "myservice"; private sensormanager sensormanager; apppreferences appprefs; @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { toast.maketext(this, "my service created", toast.length_long).show(); log.d(tag, "oncreate"); } @override public void ondestroy() { toast.maketext(this, "my service stop", toast.length_long).show(); log.d(tag, "ondestroy"); } @override public void onstart(intent intent, int startid) { toast.maketext(this, "my service start", toast.length_long).show(); log.d(tag, "onstart"); sen...

jquery - Spring MVC 415 Unsupported Media Type -

i using spring 3.2 , try use ajax post request submit array of json objects. if relevant, escaped special characters. i getting http status of 415. my controller is: @requestmapping(value = "/save-profile", method = requestmethod.post,consumes="application/json") public @responsebody string saveprofilejson(@requestbody string[] profilecheckedvalues){ system.out.println(profilecheckedvalues.length); return "success"; } jquery is: jquery("#save").click(function () { var profilecheckedvalues = []; jquery.each(jquery(".jsoncheck:checked"), function () { profilecheckedvalues.push($(this).val()); }); if (profilecheckedvalues.length != 0) { jquery("body").addclass("loading"); jquery.ajax({ type: "post", contenttype: "application/json", url: contextpath ...

asp.net - javascript calculation not giving desired out put -

i have following code function calculatevat() { var vat = null;var amount=null; vat = document.getelementbyid("hiddenvat").value; amount = document.getelementbyid("numtxt_itemcost").value; var total = parseint(amount)* parseint(vat) / 100 ; document.getelementbyid("txt_total_text").value = total; } here calculating vat price according amount price e.g vat value 13.5 if input 1780 on numtxt_itemcost field should give output 240.30 but when run programme puting value 1780 on numtxt_itemcost field it shows 231.4 wrong output help please urgent!! you should use parsefloat instead: parsefloat(1780)* parsefloat(13.5) / 100 //240.3 when use parseint , decimals stripped off.

Sharing a java object across a cluster -

my requirement share java object across cluster. i confused whether write ejb , share java objects across cluster or to use third party such infinispan or memecached or terracotta or what jcache? with constraint i can't change of source code specific application server (such implementing weblogic's singleton services). i can't offer 2 builds cluster , non cluster environment. performance should not downgraded. i looking open source third party if need use it. it need work in weblogic , websphere , jbos , tomcat too. can 1 come best option these constraints in mind. it can depend on use case of objects want share in cluster. i think comes down following options in complex least complex distributed cacheing http://www.ehcache.org distributed cacheing if need ensure object accessible cache on every node. have used ehache distribute quite successfully, no need setup terracotta server unless need scale, can point instances via rmi. work...

Exclude certain elements with an xpath query -

i'm using xpath extract elements following url: http://gizmodo.com/how-often-cities-appear-in-books-from-the-past-200-year-1040700553 to extract main content, i'm using query: //p[@class='has-media media-640'] however, i'd exclude spans within main content have class "magnifier lightbox". i've looked through stackoverflow , tried sorts of methods such as: //div[@class='row post-content']/*[not(self::span[@class='magnifier lightbox'])] to no avail.

neo4j - condition in count function -

can put condition in count()? let me explain. start me=node:node_auto_index(userprofileid = '1'), other=node(*) match pmutualfriends=me-[r?:friends]-mf-[r1:friends]-other other.username? =~ '(?i)dh.*' , other.userprofileid? <> 1 return me.emailid, other.emailid,other.userprofileid, other.username, r.approvalstatus, count(pmutualfriends) mutualcount in above query can user this. count(pmutualfriends r.approvalstatus = 1 , r1.approvalstatus =1 ) or may in other way? thanks the filter function should you. if need further assistence, please provide data sample on http://console.neo4j.org , share here. as example: start me=node:node_auto_index(userprofileid = '1'), other=node(*) match pmutualfriends=me-[r?:friends]-mf-[r1:friends]-other other.username? =~ '(?i)dh.*' , other.userprofileid? <> 1 return me.emailid, other.emailid,other.userprofileid, other.username, count(filter(x in r.approvalstatus: x=1)), ...

c# - GetSafeHtmlFragment removing all html tags -

i using getsafehtmlfragment in website , found of tags except <p> , <a> removed. i researched around , found there no resolution microsoft. is there superseded or there solution? thanks. an alternative solution use html agility pack in conjunction own tags white list : using system; using system.io; using system.text; using system.linq; using system.collections.generic; using htmlagilitypack; class program { static void main(string[] args) { var whitelist = new[] { "#comment", "html", "head", "title", "body", "img", "p", "a" }; var html = file.readalltext("input.html"); var doc = new htmldocument(); doc.loadhtml(html); var nodestoremove = new list<htmlagilitypack.htmlnode>(); var e = doc .createnavigator() ...

java - Generics vs. Method Overloading -

i have 3 methods: //1 -- check 1 item public static <t> void containsatleast(string message, t expecteditem, collection<? extends t> found) { if (!found.contains(expecteditem)) assert.fail("..."); } //2 -- check several items public static <t> void containsatleast(string message, collection<? extends t> expecteditems, collection<t> found) { (t expteteditem : expecteditems) containsatleast(message, expteteditem, found); } //3 -- check several items, without message parameter public static <t> void containsatleast(collection<? extends t> expecteditems, collection<? extends t> found) { containsatleast(null, expecteditems, found); } i expect method //3 invoke //2 not, invoke method //1...

Why my application shows in battery after exit android application? -

Image
screens problems 1) drains lots of battery. 2) after exit application display in battery status. this number not current battery use percentage of battery used since last charge. to fix this, need optimize program , performance profile it. when it's running, using lot of battery.

javascript - How to add question mark parameter instead of forward slash in history js plugin -

trying change url ( http://www.rangde.org/gift-cards?theme=anniversary ) but output getting ( http://www.rangde.org/gift-cards/?theme=anniversary ) i dont want forward slash in front of question mark parameter pls me fix this script here: history.pushstate({state:1,rand:math.random()}, 'designs', '?theme=diwali'); function(){ var history = window.history, // note: using capital h instead of lower h state = history.getstate(), $log = $('#log'); history.log('initial:', state.data, state.title, state.url); history.adapter.bind(window,'statechange',function(){ // note: using statechange instead of popstate var state = history.getstate(); // note: using history.getstate() instead of event.state history.log('statechange:', state.data, state.title, state.url); }); } not sure...

mysql - select columns dynamically based on list of column names obtained from -

i need simple select statement, based on list of column names dynamic , filtered lower case column names in table. table structure out of control , varies. not possible me know column names before hand - there upper case names (not wanted) , lower case names (wanted). the_table: col_uppercase_1 col_uppercase_2 col_lowercase_1 col_lowercase_2 data1 data2 data3 data4 data5 data6 data7 data8 i can list of column names want using this: select group_concat(column_name) `information_schema`.`columns` (`table_schema` = 'the_database' , `table_name` = 'the_table' , column_name = binary lower(column_name)); which returns list of columns want: +---------------------------------+ | group_concat(column_name) | +---------------------------------+ | col_lowercase_1,col_lowercase_2 | +---------------------------------+ my question: how insert results of query select statement? e.g. select <colum...

android - HttpService - not able to play online videos -

i using httpservice send responses android devices , browsers share files. service works on android device. works fine exclude video files. listening online music works perfect. when try watch online video webservice fails error can see below: java.net.socketexception: sendto failed: epipe (broken pipe) @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) @ libcore.io.iobridge.sendto(iobridge.java:475) @ java.net.plainsocketimpl.write(plainsocketimpl.java:507) @ java.net.plainsocketimpl.access$100(plainsocketimpl.java:46) @ java.net.plainsocketimpl$plainsocketoutputstream.write(plainsocketimpl.java:269) @ org.apache.http.impl.io.abstractsessionoutputbuffer.write(abstractsessionoutputbuffer.java:109) @ org.apache.http.impl.io.contentlengthoutputstream.write(contentlengthoutputstream.java:113) @ org.apache.http.entity.fileentity.writeto(fileentity.java:83) @ org.apache.http.impl.entity.entityserializer.serialize(entityserializer.java:97) @ org.apache.http.impl.abstracth...

ruby - How would I design this scenario in Twilio? -

i'm working on yrs 2013 project , use twilio. have twilio account set on $100 worth of funds on it. working on project uses external api , finds events near location , date. project written in ruby using sinatra (which going deployed heroku). i wondering whether guys guide me on how approach scenario: user texts number of twilio account (the message contain location , date data), process body of sms, , send results number asked them. i'm not sure start; example if twilio handle of task or use twilio's api , checking smss , returning results. thinking not using database. could guide me on how approach task? i need present project on friday; i'm on tight deadline! our help. they have great documentation on how of this. when receive text should parse format need put existing project , when returns event or events in area need check how long string due constraint twilio has of restricting messages 160 characters or less. ensure split message elega...

mysql - SQL select first found value in 'in group' -

is possible select first row matched in list? table bar : column 'bar' values: value2, value3 select * `foo` `bar` in ('value','value2','value3'); it select value2 , returns. thanks in advance edit: the values expecting are: foo foobar foobarsome foobarsomething i determine based on length of strings need default value if nothing found. lets 'nothing' nothing bigger foobar , valid value. you can use case statement in order clause specify order based on column values. use can use limit select 1 row in result. select * foo bar in ('value','value1','value2') order case bar when 'value' 1 when 'value1' 2 when 'value2' 3 else 100 end limit 1; i tested example on sql fiddle . update: original poster edited question , added wants sort on string length , have default value of 'nothing' returned if there no results. select * foo bar in ('value','va...

c# - Modified Data Table -

for example have table employeename empoyeeid john mark 60001 bent ting 60002 don park 60003 how can show employeeid have leading asterisk in data table? sample: *60001 *60002 *60003 public datatable listofemployee() { dataset ds = null; sqldataadapter adapter; try { using (sqlconnection mydatabaseconnection = new sqlconnection(myconnectionstring.connectionstring)) { mydatabaseconnection.open(); using (sqlcommand mysqlcommand = new sqlcommand("select * employee", mydatabaseconnection)) { ds = new dataset(); adapter = new sqldataadapter(mysqlcommand); adapter.fill(ds, "users"); } } } catch (exception ex) { throw new exception(ex.message); } return ds.tables[0]; } i need show data...

asp.net mvc - MVC3 Razor ViewBag.Model not making into the Page -

i have modified model system i've inherited, , reason viewbag.model not making page. i've reverted code before started tinkering, , still no luck. the call view follows: public virtual actionresult edit(long id) { var _news = _newsrepository.getnewsbyid(id); viewbag.model = automapper.mapper.map<news, newsmodel>(_news); viewbag.model.currentnewsimagefile = configsettings.hostdomainname + configsettings.newsimagebasepath + _news.image_file; return view(); } the view has following code: @model mymodels.models.newsmodel @{ bool iscreate = model == null || model.id == 0; viewbag.title = iscreate ? "add news" : "edit news"; } the problem "model" null in view code... have missed? missing fundamental here? when tracing through actionresult code, right until return view() debug inspector correctly shows model containing expect too. you need return view(themodel) . if don't pass model view() d...

javascript - CKEditor Add new list plugin using UL tag -

i'm trying add new list plugin similar bulletedlist i've created new button i'm trying use ul tag pairs new button called arrowedlist bulletedlist button. the reason doing can add class (which know how do) can have 2 different buttons 1 applies default bullet list , other applies ul tags class. the basic question is: there way can add button uses ul same way bulletedlist without pairing buttons together? // register commands. editor.addcommand( 'numberedlist', new listcommand( 'numberedlist', 'ol' ) ); editor.addcommand( 'bulletedlist', new listcommand( 'bulletedlist', 'ul' ) ); editor.addcommand( 'arrowedlist', new listcommand( 'arrowedlist', 'ul' ) ); // register toolbar button. if ( editor.ui.addbutton ) { editor.ui.addbutton( 'numberedlist', { label: editor.lang.list.numberedlist, command: ...

Count of patients department wise in SQL Server -

select distinct patient_ref_master.dept_id 'dept', patient_ref_master.male_femal 'gender', count(patient_ref_master.pat_id) 'count' patient_ref_master left join patient_master on patient_master.pat_code=patient_ref_master.pat_id (patient_ref_master.age > 16 , dbo.patient_master.pat_sex = 2 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age > 16 , dbo.patient_master.pat_sex = 1 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age >= 0 , patient_ref_master.age <= 16 , dbo.patient_master.pat_sex = 2 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age >= 0 , patient_ref_master.age <= 16 , dbo.patient_master.pat_sex = 1 , patient_ref_master.creation_date = '2013/08/02') group patient_ref_master.male_femal, patient_ref_...

c - WSA Connection refused even though the host is not present -

i'm writing code discover devices on network , part of it. i'm trying discover host establishing socket connection host on port 80. it connects on of hosts on port 80 devices listening on port 80. @ times connect function returns error wsaconnectionrefused there no web service running on host. it surprising see when try establish socket connection on invalid ip addresses wsaconnectionrefused instead of wsaetimedout . i googled , found out antivirus , firewall can cause problems , have disabled both on scanning machine no luck causing problem? i have posted code below: #ifndef unicode #define unicode #endif #define win32_lean_and_mean #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> #pragma comment(lib, "ws2_32.lib") int main() { wsadata wsadata; int iresult = wsastartup(makeword(2, 2), &wsadata); if (iresult != no_error) { wprintf(l"wsastartup function failed error: %d\n", iresult); r...

Read DigitalProductId Value From Windows Registry in Ruby -

so far have code require 'win32/registry' win32::registry::hkey_local_machine.open('software\microsoft\windows nt\currentversion',win32::registry::key_all_access) |reg| puts reg['digitalproductid'] end but doesn't allow me digitalproductid value. of values available of them not. currentversion currentbuild softwaretype currenttype installdate registeredorganization registeredowner systemroot installationtype editionid productname currentbuildnumber buildlab buildlabex buildguid csdbuildnumber pathname it because running on 64 bit machine. not identify key "digitalproductid" registry untill change tragetplatform x64 bit cpu. hope helps

Reduce TCP maximum segment size (MSS) in Linux on a socket -

in special application in our server needs update firmware of low-on-resource sensor/tracking devices encountered problem in data lost in remote devices (clients) receiving packets of new firmware. connection tcp/ip on gprs network. devices use sim900 gsm chip network interface. the problems possibly come because of device receiving data. tried reducing traffic sending packages more error still occured. we contacted local retailer of sim900 chip responsible giving technical support , possibly contacting chinese manufacturer (simcom) of chip. said @ first should try reduce tcp mss (maximum segment size) of our connection. in our server did following: static int create_master_socket(unsigned short master_port) { static struct sockaddr_in master_address; int master_socket = socket(af_inet,sock_stream,0); if(!master_socket) { perror("socket"); throw runtime_error("failed create master socket."); } int tr=1; i...

java - Communication between different Jar's/Classloaders -

i've got following problem solve: there 2 jar files. these jar's start independently each other. now, let's first jar a.jar calculates or computes , has commit results b.jar . i tried communicate via central singleton (enum singleton , singleton uses own classloader mentioned here: singleton class several different classloaders ). but didn't seem work me. when start 2 jar's hashcode of instances different. can tell me i'm doing wrong? or other ideas how solve problem? there 2 jar files. these jar's start independently each other. so they're separate processes . won't share instances of classes, variables etc. need form of inter-process communication communicate between them. that mean form of network protocol (e.g. tcp/udp sockets, http etc.). simple reading/writing shared file (that's not particularly nice, straightforward simple cases)

java - How to handle categories inside properties file? -

there new process implement involves writing , reading excel file. this, process needs properties define sheets , cells use write/read values. there fixed number of properties use based on category. show example: category1.sheet1=customer info category1.cell1=a10 category1.cell2=b10 category1.cell3=a20 category2.sheet1=customer data category2.cell1=a20 category2.cell2=b20 category2.cell3=a25 //more categories... in process, @ step, decide category i'm using , must consume properties category only. how load properties single category? currently, have approach (code simplified better understanding): //get category1 or category2 based on rules... string category = getcurrentcategory(); //define name of properties use string sheet1 = category + "sheet1"; string cell1 = category + "cell1"; string cell2 = category + "cell2"; string cell3 = category + "cell3"; //use properties... string sheet1value = getproperty(sheet1); string cell1va...

iphone - UITextView Autocomplete modification -

i'm using htautocompletetextfield fill in uitextfield predefined list, should user start typing in entry exists. there couple of problems i've been having however. first seems stop when comma typed in (but not apostrophes). i've been looking around , i'm not sure why it's doing it. thought @ 1 point comma different comma, apostrophe issue had due importing list word document. however, wasn't case. second issue more of addition i'm not sure how implement. want autosuggest detect suggestions words in mid string, not beginning. instance typing in "string" suggest "this string". how auto suggest, have no idea how above things. nsstring *prefixlastcomponent = [componentsstring.lastobject stringbytrimmingcharactersinset:space]; if (ignorecase) { stringtolookfor = [prefixlastcomponent lowercasestring]; } else { stringtolookfor = prefixlastcomponent; } (nsstring *stringfromreference in coloraut...

Custom exceptions with kwargs (Python) -

is safe? class specialalert(exception): def __init__(self, message, **kwargs): exception.__init__(self, message) kw in kwargs: if kw == 'message': continue setattr(self, kw, kwargs[kw]) related to: proper way declare custom exceptions in modern python? butt.. safe? mean i'm overriding attributes of self? in specialalert want pass kinds of things (this exception done doing long series of different checks, "try..except specialalert error" in loop , details out of error in handlers) i have basic check if i'm not overriding "message", should skip setting other attrs on self too? they? this work fine; it's cromulent put additional attributes on object. however, rather checking standard attributes don't want clobber, call exception.__init__ last, , let clobber yours if accidentally set them. __init__() can be: def __init__(self, message, **kwargs): self.__d...

wordpress - Combining tags and categories -

i have set custom post type custom tags , categories. i want show posts country , category , categories need common countries. if user chooses country drop down (or something) categories of country should listed. south africa - sport -- golf --- irons one option make countries parent categories unique child categories each country. complicated , show looooong lists of duplicated category names in post editor. not smart way you'll agree. the other option thought using tags , categories together, countries added tags , categories common. question how make dynamic list of countries display categories particular tag/country? is there maybe simpler/better option can suggest? edit @mike this. route have been playing since posting q, kind of. have set custom post type custom hierarchical taxonomy called product categories , custom non-hierarchical taxonomy (tags) called countries. created new archive template displays tagged posts. @ moment displays tagged...

java - Does the DispatcherServlet creates new instance of controller and methods inside for each user? -

good day folks. have controller in application: @controller public class loginsearchcontroller { //list store data resulthtml method list<cars> listcars = null; @autowired private educationwebserviceinterface educationwebservice; //this method render jsp page user , create model resulthtml @requestmapping(value="/search", method=requestmethod.get) public string search(formbackingobjectsearch fbos, model model) { model.addattribute("fbosattributes", fbos); return "search"; } // method name form form object , use fetchcarsbynameservice method // after if found stores in listofserchobjects , after listofserchobjects stores in listform list @requestmapping(value="/result", method=requestmethod.get) ...