Posts

Showing posts from August, 2010

mono - How to add c# custom controls to MonoDevelop toolbox? -

i new mono develop, created gtk# 2.0 project in mono develop , tried add c# user defined controls zedgraph, toolbox not accepting c# user-defined controls. there way add c# user defined controls mono develop toolbox. please me. i have same problem. can not see zedgraph widgets in toolbox...but can add widgets via code. instead of going "designer" view , via gui, via "source" view. (after add dll references). i hope has better solution.

c# - Cast boxed object to typeof(object) -

i have following poco classes public interface iobject { guid uid { get; set; } } public class boo : iobject { public guid uid { get; set; } public string name { get; set; } } public class foo : iobject { public guid uid { get; set; } public string name { get; set; } } i trying write generic method insert type of object database type inherit iobject . using following method (with servicestackormlite underneath): public interface idataaccess { idbconnection getconnection(); boolean insertobject<t>(t newobj, idbconnection connection) t : idataobject, new(); } trying insert each object separately works follow : public static boolean addfoo(this foo foo) { // dataprovider initiated using implementation of idataaccess return dataprovider.insertobject(foo, dataprovider.getconnection()); } question : i trying use following method valid 1 both fails. syntax wrong consider pseudo code. how can acheive that? obj boxed foo or boo i...

Is it possible to restore a SQL Server backup to a different database -

Image
i restore backup different database original. i did backup databasea , want restore databaseb . want test first , data backup, take data need update databasea . how this? yes can. in gui your source database "databasea" your destination database if "databaseb" on files tab, you'll need provide new file names.

bash - how to remove final "dot" from directory name -

a program messed directory putting dot "." on end of file , directory names. easiest way remove them? i have thought of removing last character not files/dirs have dot on end. removing dots problem, make extension useless. what need rename change name.of.the.file.ext. name.of.the.file.ext , name.of.the.dir. name.of.the.dir thanks! go on files dot @ end, rename each if possible (i.e. target file not exist). for file in *. ; [[ -e ${file%.} ]] || mv "$file" "${file%.}" done echo not renamed: *.

xml - Out of Memory Error while using archive::extract -

can u me in getting out of error "out of memory" while using archive::extract i'm using below code .. my $extract_obj = archive::extract->new(archive => $tar_file_work_path, type => 'tgz'); $extract_obj->extract(to => $work_dir) please suggest me how extract xml file ...

jquery - Why is my post-animate function not being called? -

i'm animating popups fade , slide in simultaneously. want reset position of hidden popup once it's hidden animation same every time. when element rolled over, popup slides down , fades in. when it's rolled out of, popup slides down further , fades out, when it's hidden, resets initial position. here's code: $('*:has(.rollover)').hover(function(){ $('.rollover',this).fadein('fast').animate({ 'top' : '60px', }, {duration: 'fast', queue: false}, function() {}); },function(){ $('.rollover',this).fadeout('fast').animate({ 'top' : '70px', }, {duration: 'fast', queue: false}, function() { console.log("hello"); $(this).css('top','50px'); }); }); the problem last line top reset not being triggered, , neither log statement. why this? my error having: , {duration: 'fast', queue: false}, function() {}); whe...

asp.net - How to clear exisiting dropdownlist items when its content changes? -

ddl2 populates based on ddl1 selected value successfully. my issue data present in ddl2 not clear before appending new data ddl2 content continues grow every time ddl1 changed. <asp:dropdownlist id="ddl1" runat="server" datasourceid="sql1" datavaluefield="id1" datatextfield="name2" appenddatabounditems="true" autopostback="true"> <asp:listitem text="all" selected="true" value="0"/> </asp:dropdownlist> <asp:dropdownlist id="ddl2" runat="server" datasourceid="sql2" datavaluefield="id2" datatextfield="name2" appenddatabounditems="true" autopostback="true"> <asp:listitem text="all" selected="true" value="0"/> </asp:dropdownlist> <asp:sqldatasource id="sql1" runat="server" selectcommand="sp1" selectcommandtype=...

c# - Saving object of Mailitem or any property which can be used to invoke Mailitem which was saved -

i using vs 2010 , dot net framework 2.0 . have created project in extensibility->shared add-ins outlook. i want save outlook.mailitem object in datatable on explorer_selectionchange() , use outlook.mailitem object manipulate subject , body after-wards. when saving object of mailitem in datatable getting saved sys.comaddins. here code class variables : private outlook.mailitem connectingmailitem; private outlook.inspectors inspectors; private outlook.application applicationobject; private object addininstance; private outlook.explorer explorer; datatable dtmailitem = new datatable(); onconnection : explorer = this.application.activeexplorer(); explorer.selectionchange += new outlook.explorerevents_10_selectionchangeeventhandler(explorer_selectionchange); dtmailitem.columns.add("mailitem",typeof(outlook.mailitem)); tfollowup = new timer(); tfollowup.interval = 100000; tfollowup.tick += new eventhandler(tfollowup_tick); explorer_select...

pointers - C# Object Reference : How can i do it? -

this class test public class test { public string mystr; } and call method : string = "abc"; test test = new test(); test.mystr = my; test.mystr = ""; result of bit code above : my = "abc" , test.mystr = "" how can set my empty string "" when change test.mystr = "" ? if understand correctly, want variables my , test.mystr linked, if 1 changes, other changes? the answer simple: cannot! a string immutable class. multiple references can point string instance, once instance modified, string instance created new value. new reference assigned variable, while other variables still point other instances. there workarounds, suspect not happy it: public class test { public string mystr; } test mytest1 = new test { mystr = "hello" }; test mytest2 = mytest1; now, if change mytest1.mystr , variable mytest2.mystr modified, because mytest1 , mytest2 same instances. there ...

xml - Grabbing specific lines from block of TEXT -

i have large text (xml?) dump , want out lines containing content. for example, want 'text here' part grepped out or something. there way grep out throughout file 'values' of 'content' tags? <mtg:property displayname="content" hidden="false" name="content" nullable="true" readonly="false" type="string"> <mtg:value>text here</mtg:value> </mtg:property> thanks help. awk '/content/ {print $2}' fs='<mtg:value>' rs='</mtg:value>' set record separator </mtg:value> set field separator <mtg:value> find records containing content , print field 2

performance - Handling large object in stateless environment -

we have various windows services load large amount of data i.e. settings, database object used whenever calls made our various .net remoting functions (i know it's old!!). having object containing these settings in memory saves having query database or load data cache whenever queries executed. settings in "large" object collections of data, id, path, text, etc... we want move away .net remoting wcf , potentially rid of our windows services , run lot under iis (and azure), being stateless, i'm wondering how should handle this? 1) what's best method can think of? experience preferrably. one suggestion made me return of client, cache , use relevant settings when making wcf call. 2) numerous services have polling services, monitoring, databases, file locations, ftp locations, etc... how recommend handle in stateless environment?? can't see how handled. we use sql server, don't want rely heavily on build-in features potentially have suppor like...

javascript - How to change a choice selection with jQuery -

i have choice: <select id="selectlang"> <option value="en" selected>english</option> <option value="de">deutsch</option> </select> now, set default value inspecting browser's language. var lang = window.navigator.userlanguage || window.navigator.language; how can modify selection of choice jquery? you can do: $("#selectlang").val(lang.split('-')[0]); fiddle

formatting currency output in ios -

- (void)textfielddidendediting:(uitextfield *)textfield { if (textfield1) { nsstring *txt = self.textfield1.text; double num1 = [txt doublevalue]; double tcost = num1 /100; nsnumberformatter *numberformatter = [[nsnumberformatter alloc] init]; [numberformatter setnumberstyle: nsnumberformattercurrencystyle]; nsstring *numberasstring = [numberformatter stringfromnumber:[nsnumber numberwithfloat:tcost]]; self.textfield1.text = [nsstring stringwithformat:@"%0.@",numberasstring]; } } this code ive put formats output of textfield currency im trying work out how format currency output is, if types in 1625 formats 0.1625 if somone types in 50 formats 0.50 correct supposed calculator taking in peoples electricity rates either in cents or pences. to currency formatting use following code : - (nsstring*) getamountincurrencyformatwithvalue:(nsstring*) valuestring { nsnumberformatter *number...

java ee - Glassfish - Marking servlet FacesServlet as unavailable -

when startup glassfish 2.1 server, seems startup without problems, when try access admin console error: the requested resource (servlet facesservlet not available) not available. on console , server.log, can see: [#|2013-05-09t14:59:36.647+0200|info|sun-appserver2.1|javax.enterprise.system.core|_threadid=10;_threadname=main;|application server startup complete.|#] [#|2013-05-09t15:01:23.250+0200|info|sun-appserver2.1|javax.enterprise.resource.webcontainer.jsf.config|_threadid=15;_threadname=httpworkerthread-4848-0;;|initializing mojarra (1.2_13-b01-fcs) context ''|#] [#|2013-05-09t15:01:24.420+0200|info|sun-appserver2.1|javax.enterprise.system.container.web|_threadid=15;_threadname=httpworkerthread-4848-0;|pwc1412: webmodule[] servletcontext.log():pwc1409: marking servlet facesservlet unavailable|#] the last 2 entries logged when access admin console first time. why glassfish marking facesservlet unavailable? it related bug: https://java.net/jira/brow...

cordova - Cookie based Authentication on Phonegap -

i'm facing problem phonegap cookie based authentication: after force iphone close app (double click on physical button , close), lose cookie established server. how can avoid it? there configuration? or alternative way it? it works when run first time , error happens when force close app. works on android. i'm using: iphone - ios 6.1 , cordova 2.5 thanks i advice abandon cookie solution , instead switch localstorage solution. ios 6.x has few problems cookie handling , if apple fix problems people still use older version making app unusable on older platforms. cookies archaic technology , there talks ios loose support in future versions. on other hand localstorage supported on html5 browsers. you can go further that. there's great js framework called persistance.js . automatically use best storage option device , there 4 different kinds of storage solution.

Is the git submodule name used for anything other than display? -

the .gitmodules file used track submodules within git repository has name each submodule, this: [submodule "my-submodule"] path = foo/bar/my-submodule url = http://github.com/myuser/original-my-submodule however, i've seen written local path duplicated in submodule name: [submodule "foo/bar/my-submodule"] path = foo/bar/my-submodule url = http://github.com/myuser/original-my-submodule i have both of these styles in 1 of repositories, accident, , i'm not sure why different. i'd make sure have these expressed correctly. of these "correct"? matter? submodule name used other display? the gitmodules man page includes: the file contains 1 subsection per submodule, , subsection value name of submodule. the name set path submodule has been added unless customized --name option of git submodule add . it possible submodule added ( git submodule add ) twice, , without --name option ("without" means:...

matrix - Actionscript 3 - How To Check A Random Pixel Of A Sprite -

i have sprite drawn in random , complicated way. pixels either transparent or not. , need check if pixel new point(10, -5) transparent or not. how can ? this not collision detection. i draw in negative area of sprite graphics. not centered. solution: the main problem drawing in negative area. figured out myself: var bitmapdata: bitmapdata = new bitmapdata(sprite.width, sprite.height, true, 0x0); var rect: rectangle = sprite.getbounds(sprite); var mat: matrix = new matrix(); mat.translate(-rect.left, -rect.top); bitmapdata.draw(sprite, mat); bitmapdata.getpixel32(xcoordtotest - rect.left, ycoordtotest - rect.top); // etc create new bitmapdata object , draw sprite onto it. check desired bitmapdata pixel. var bitmapdata:bitmapdata = new bitmapdata(mysprite.width,mysprite.height,true,0x00000000); bitmapdata.draw(mysprite); bitmapdata.getpixel32(10,5);

php - How to get data from a table with a foreach loop -

i trying data table array, , want use foreach loop not while speed issues. i tried using function getrowsassoc() { $ret = array(); while (($temp = mysql_fetch_assoc($this->result)) !== false) { if (count($temp) > 0) { $ret[] = $temp; } } if (count($ret) > 0) { return $ret; } else { return false; } } however results in to. array ( [0] => array ( [mysku] => bb1-3500-48 [upc] => 721343100171 ) [1] => array ( [mysku] => bc7-3501-19 [upc] => 721343103516 ) [2] => array ( [mysku] => bc7-3501-95 [upc] => 721343103523 ) [3] => array ( [mysku] => bb1-3502-12 [upc] => 721343114000 ) [4] => array ( [mysku] => bc7-2370-03 [upc] => 721343121602 ) ) the problem instead of returning assoc array adding numbered array in top of cannot data item codes. i like this array ( [mysku] => bb1-3500-48 [upc] => 72...

javascript - Is it possible to force knockout to parse new bindings added via html binding? -

i adding simple html when user clicks table row. table row gets "expanded" , the html added via knockout html binding. the html being injected view works fine, have added data-bind of html , knockout parse/process it. possible? after add html, call apply bindings again restrict html you're looking @ newly-added html, so: ko.applybindings(viewmodel, $("#new-html")[0]);

nfc - Android Beam: Sending message to only specific application -

i developing 1 application uses android beam. can send message through beam gets delivered same application ? no other app able receive that, not device's default nfc reader application !! if have solution, please let me know.

javascript - Module pattern & "private attributes" -

ok, couple of weeks ago, learned "module pattern" in javascript. examples found went : var module = (function () { // private variables , functions var foo = 'bar'; // constructor var module = function () { }; // public methods module.prototype = { something: function () { } }; // return module return module; })(); var my_module = new module(); i excited, started own test : var mymodule = mymodule || {}; mymodule.user = (function(){ "use strict"; // "private" attribut var id //constructor var user = function(l_id){ id = l_id; }; //"public" method user.prototype.getid = function(){ return id }; return user; })(); var u2 = new mymodule.user(2); var u1 = new mymodule.user(1); console.log(u2.getid()); // print 2 console.log(u1.getid()); //print 2 oo however, didn't expect called "private" attribut "id...

io - is Scanner in Java enough for reading input from a text file? -

what i'm going do i'm going build phone book program in java following jobs: read 2 text files, instruction.txt , phonebook.txt phonebook.txt includes phone entry, each entry person instruction.txt includes instructions execute phonebook.txt , such add new entry, query entry, delete entry, etc. for sure care output of program, now, focus on input. my problem i want use scanner input jobs, read in strings stored in instruction.txt , phonebook.txt, doubt if can handle difficult conditions. conditions how correctly each entry, , identify is. for each phone book entry, 5 fields needed: name , birthday , phone number , address , email . , name , birthday compulsory each entry. for instructions, add , delete , save , read , query . sample text files here sample of instruction.txt : add name testing three; birthday 13-05-1982; phone 12345677; address address three; email testing@gmail.com delete testing 1 save each entry separated 1 or more b...

excel - Sum cells based on colour and date -

Image
i have following: date ------- cost jan £500 jan £600 feb £300 feb £600 march £1000 march £500 the cost cells coloured differently depending on current status (confirmed green, unconfirmed white, semi-confirmed yellow), need formula sum costs example, green , in february. i'm aware vba required sort of colour function, , have found useful 1 called colorfunction() allows me sum/count cells of colours using following formula: colorfunction(a1, b1:b5, false) a1 being colour compare range against, , false / true returning sum or count result. however cannot work custom function month() formula or sumif. over-complicating please point out idiotic mistakes i'm making in trying figure out. add function vba module in order return cells interior color index: function colorindex(rng range, _ optional text boolean = false) variant dim cell range, row range dim long, j long dim iwhite long, ibla...

c# - Bitmap Image URI, Setting an image uri with an assembly path but returns exception -

i'm binding uri string: <image> <image.source> <bitmapimage urisource="{binding itemvalue}" /> </image.source> </image> and in return path returned: <resourcevalue>pack://application:,,,assemblyoutput;component/resources/hellothere.png</resourcevalue> the folder name assemblyoutput > resources > hellothere.png , correct path there, throws exception file not found.

c# - Updating n:m relationship without much overhead -

i got n:m relationship between these 3 tables: products , keywords , productkeywords now everytime update product , provide list<keyword> new chosen keywords. collection can contain keywords chosen product keywords, new or removed ones. want update in database. for i'm clearing entire productkeywords table productkeywords.productid equals product.id . of course produces very much overhead clears out keywords specific product. is there easy way update n:m relationship without clearing entirety of products keywords before? should remove productkeywords not present in new list<keyword> collection anymore still in table, add new productkeywords not present in table yet, in list<keyword> . others (present in table , present in list<keyword> ) should remain untouched lessen overhead. it should remove productkeywords not present in new list collection anymore still in table, as add new productkeywords not present in table yet, in ...

In Python, have json not escape a string -

i caching json data, , in storage represented json-encode string. no work performed on json server before sending client, other collation of multiple cached objects, this: def get_cached_items(): item1 = cache.get(1) item2 = cache.get(2) return json.dumps(item1=item1, item2=item2, msg="123") there may other items included return value, in case represented msg="123" . the issue cached items double-escaped. behoove library allow pass-through of string without escaping it. i have looked @ documentation json.dumps default argument , seems place 1 address this, , searched on google/so found no useful results. it unfortunate, performance perspective, if had decode json of each cached items send browser. unfortunate complexity perspective not able use json.dumps . my inclination write class stores cached string , when default handler encounters instance of class uses string without perform escaping. have yet figure out how achieve though, , grateful...

ruby on rails - postgres search query error if space used -

i'm following along ryan bates' railscast on full text search postgres, however, he's using postgres 9.1 , i'm using 9.2. builds following query execute search. works me if query single word, such "superman" if it's 2 words, such dc comics , or super man , i'm getting error, being new postgres can't figure out how fix. can assist? pg::error: error: syntax error in tsquery: "super man" line 1: ...articles" (to_tsvector('english', name) @@ 'super man... ^ : select "articles".* "articles" (to_tsvector('english', name) @@ 'super man' or to_tsvector('english', content) @@ 'super man') order ts_rank(to_tsvector(name), plainto_tsquery('super man')) + ts_rank(to_tsvector(content), plainto_tsquery('super man')) desc limit 3 offset 0 query article.rb def self.text_search(query...

ruby on rails 3.2 - Ember Route model issue -

i following tutorial brian cadarella on dockyard. building ember app rails-api backend. http://reefpoints.dockyard.com/ember/2013/01/09/building-an-ember-app-with-rails-api-part-2.html as change: app.usersindexroute = ember.route.extend setupcontroller: (controller, model) -> controller.set('users', model) @controllerfor('application').set('currentroute', 'users') to: app.usersindexroute = ember.route.extend model: -> app.user.find() setupcontroller: (controller, model) -> controller.set('users', model) @controllerfor('application').set('currentroute', 'users') my link users page not work. following error in firebug console: typeerror: ember.rsvp.reject not function [break on error] return ember.rsvp.reject(error); ember.rsvp.reject in ember-data.js why not working? have been following tutorial word word. this other answer of maybe of emberjs typeerror: obj...

linux - How do I connect a hardware interrupt to Qt Emit? -

i'm building , embedded app , rather use hardware interrupt listener chew cpu cycles polling every 10th of second. this can done since there listener hardware interrupts keyboard, mouse , networking. have hardware interrupt trigger qt emit signal. thanks in advance. example: hardware interrupt -> readport() -> emit(value) update think work hear has experience this. msn = new qsocketnotifier; // defined in .h qfile file("/dev/testdriver"); if(file.open(qfile::readonly)) { qsocketnotifier msn(file.handle(), , qsocketnotifier::read); msn.setenabled(true); connect(msn, signal(activated(int)), &this, slot(readyread())); } not knowing else application, there may non-interrupt solution. create subclass of qobject , move unique qthread. in object, call starttimer(100). in timerevent(), poll hardware. emit signal necessary. in qt4, signals , slots automatically queued across threads.

java ee - EJB modules cannot find class from another EJB module on glassfish -

i have ejb 3 module deployed on glassfish 2.1 server. i'm trying deploy second ejb module, depends on first module, deployment fails java.lang.noclassdeffounderror class can found in first ejb module. what's best way solve dependecy between 2 ejb modules? want deploy them separately, , not have them in same ear. more specifically, have dependecy injection of ejb first ejb module in 1 of ejbs of second ejb module: @ejb (name="ejb/firstejb") private firstejbremote ejb; but during deployment noclassdeffounderror class firstejbremote: error in annotation processing: java.lang.noclassdeffounderror: firstejbremote miljen mikic has point whole classloaders loading commonly named classes if wouldn't isolated. but glassfish, should in case place first ejb module in directory glassfish_home/domains/domain1/lib/applibs . during deployment of second ejb module can specify first ejb module's jar should loaded ejb module being deployed. that...

python - Executing command non root -

i have script being run root. part of script calls pythons webbrowser.open . currently when webbrowser.open executed attempt open browser using scripts root/sudo user. is there way open script current user , not root? maybe should downgrade privileges of script, using import os os.setuid(1000) have other tools, seteuid() , setgid() here : http://docs.python.org/2/library/os.html cheers, k.

java - Hibernate: updating an object in a different Session? -

is bad practice in hibernate update object in different session created in? think answer yes, because hibernate session (by default) cache session objects, , release them when session closed or object evicted. creating object in 1 session updating in session (while object still 'alive' in first session) seems bad practice me. can explain why, repercussions? example, consider code (which shortened clarity): private void updaterequest(request req){ //request came hibernate session mydao mydb = null; mydb = new mydao(); transaction trans = mydb.getsession().begintransaction(); mydb.getsession().update(object); trans.commit(); } this called "session per operation anti-pattern", here quote hibernate documentation better explains issue: do not use session-per-operation antipattern: do not open , close session every simple database call in single thread . the same true database transactions. da...

c++ - Trying to compile and receiving the following errors, undefined references to certain classes. -

these errors have occured when trying compile file main.cpp: c:\users\student\desktop\c++ solution framework (1)\assignmentsolution\assignmentsolution\main.o:main.cpp|| undefined reference `msgpacket::msgpacket(int, int, int, int, std::string)'| c:\users\student\desktop\c++ solution framework (1)\assignment solution\assignmentsolution\main.o:main.cpp|| undefined reference `datastream::datastream()'| ||=== build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===| this main.cpp file itself: #include <iostream> #include <iomanip> #include "datastream.h" #include "msgpacket.h" using namespace std; datastream * packet = new datastream(); datastream::datastream(); int main() { int source; int destination; int type; int port; int input; std::string data; cout << "my assignment" << endl;; msgpacket * packet = new msgpacket(source,destination,type,port,data); } this msgpacket.h #ifndef msgpacket_h...

Ruby deep merge with different hash types -

i'm struggling problem , can't figure out how that. let's suppose have 2 hashes: hash1 = { "address" => "address", "phone" => "phone } hash2 = { "info" => { "address" => "x", "phone" => "y"}, "contact_info" => { "info" => { "address" => "x", "phone" => "y"} }} i'd output: { "info" => { "address" => "address", "phone" => "phone"}, "contact_info" => { "info" => { "address" => "address", "phone" => "phone"} }} i've tried hash#deep_merge not solve problem. need merge keys , values anywhere in second hash whatever it's structure is. how can that? clues? i think want recursively merge hash1? maybe this: class hash def deep_merge_...

Regex to validate phone numbers, making sure there are no letters in them -

we have live project , need filter out letters phone numbers, using regex. being live, cannot fiddle it, thinking of regex: ^[^a-za-z]*$ do think trick? eliminate phone numbers contains letters? being multicultural site, know of country uses letters in phone numbers? cheers! based on current regex, assuming need regex match valid inputs. your current regex work fine prevent letters, think make more sense figure out minimum set of characters consider valid , create regex that. for example if want allow digits use ^\d*$ or ^[0-9]*$ . to allow spaces, hyphens, , parentheses number (123) 456-7890 valid: ^[\d \-()]*$

java - android Calender event issues -

hi newbie , learning android...i got following code this post written @abhi put reminder in real calendar on phone? this post provide answers, code. me problem having, first code: code onclicklistenerevent below: btnone.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { // calendar datetoshow = calendar.getinstance(); // datetoshow.set(2013, calendar.may, 10, 9, 0); // // showcalendarattime(datetoshow); uri event1; long epoch, epoch1; uri events_uri = uri.parse(getcalendaruribase(this) + "events"); contentresolver cr = getcontentresolver(); contentvalues values = new contentvalues(); try { epoch = new java.text.simpledateformat ("yyyy-mm-dd hh:mm a").parse(date+" "+time).gettime(); //epoc...

vb.net - Random XML Exceptions - ' ', Hexadecimal value 0x1F, is an invalid character -

i'm getting random errors when trying load xdocument, complaining invalid characters in xml. ' ', hexadecimal value 0x1f, invalid character. line 1, position 1. this happens 1 of these 21 locations, doesn't. it's bbc's rss, strictly managed , encoded xml. when open files i've downloaded , have problem with, inside: Í–ÛnÛ8†ïôhq[¤¤ÈvÙÁÆez “¢hÒä2 %Ú""‰iÅÍ[õúd;”åsì´nÐ,öƦ43üçð‘p|ò­Èáž+-d9t<—:ÀËd¦¢œ ¯wgÝs2zý*vzº–:bfc'3¦Š™Ïçî<p¥šŸÒüf§uœq‰q[®‹wûb鬵}Ôf%€8Éxyò¼yÀg+墼ƒlñéj?yñÒÍÅ=w'“Äm¤[ß‘9g&ãŠl9o5á%ñ{gƒ°l‚”=l¥â ÓÆmtÏ‡ŽæùÔópñ¡Ãª* 3˜awx„d™„&ç£ÓÓ1Ü,4 g톀;|È™žÉy¾–ÂðþÁ¦²ˆÉ"´ÝÇÖ1ÚèÈnîmÊ1i\Û°”ëd‰Ê&7 ºxl7Å[m˜*yÀf’e’×vš0_¾2¼¨¸b¦vx™Â\à(qŸ¢©>&›j˼y9«ÙŒ8Úw­1‘Õƒ³ÌŒÆËuoÆoát #t†ÿ’¥6[›ÈxªjªfªšsØÛÃu¡ ksay~kÁÑ™a\mÅ–)7lä:&ëÚŒªzòž>ºÊêÐc¸ÀŽùÔÀëgÞ ÂÅ;êq“¥c'Šuynê¸s­ò娵ÁÚ[ªx4zê®oÒd¡‰hd‰¿e*îezcÂþíâ/oey›ÛŠo'3âùîllcbevŠÏ# ç"5Ù¨ëÅd±z2Þ´ØzÚeÛ5²Ù¶ûp<n!ÎaiÄ6‚s_˜Àá_ˆruwk"#èÿø>†7gáïgowÚxpq'(6¤kÛû—â¸...

php - How to restrict access of a specific country to my website? -

this question has answer here: how limit countries can view website ( php ) 6 answers i have 2 websites different domain extensions provide same services visitors, 1 .com , other .com.au. want give access australian people visit .com.au website not .com, cannot visit .com website. would please guide me how restrict access of australian visitors .com website? if use typo in address bar of browser's they'll automatically redirected .com.au website. as i'm not techno guy, need firm guidance make happen. thank assistance. first geolocation based on ip, here the maxmind service locating countries here there should free services google around , sure able find them but load php library of whichever service find, feed ip of visitor $_server['remote_addr'] then redirect .au address if geolocation comes australian result header('l...

Perl send() UDP packet to multiple active clients -

i implementing perl based udp server/client model. socket functions recv() , send() used server/client communication. seems send() takes return address recv() call , can server respond client sent initial request. however, i'm looking server send data active clients instead of source client. if peer_address , peer_port each active client known, how use perl send() route packets specific clients? attempts: foreach (@active_clients) { #$_->{peer_socket}->send($data); #$socket->send($_->{peer_socket}, $data, 0, $_->{peer_addr}); #send($_->{peer_socket}, $data, 0, $_->{peer_addr}); $socket->send($data) #echos source client } perldoc send briefly describes parameter passing. have attempted adopt , result either 1) client receives socket glob object or 2) packet never received or 3) error thrown. examples of how use send() route known clients appreciated. yes, store addresses place , answer on them: # receiving packets while (my $a = re...

Change javascript function -

i have function in theme.js file $('.open_copy').click(function(){ var = $(this); var copy = that.prev(); that.parents('.asset').find('.cover').click(); copy.css('opacity', 0).show(); if (copy.children('.copy_content').data('jsp')) { copy.children('.copy_content').data('jsp').destroy(); } var height = copy.children('.copy_content').css({height: ''}).height(); if (height < that.parents('.asset').height() - 37) { var top = (that.parents('.asset').height() - height)/2; top = top < 37 ? 37 : top; copy.children('.copy_content').css({'margin-top': top}); } else { copy.children('.copy_content').css({'margin-top': '', height: that.parents('.asset').height() - 37}).jscrollpane(); } if (!that....

regex - extracting sentence containing 2 words from a text file in java -

i'm trying extract sentence containing 2 words text file. have used regex shown in code below. file doc = new file("d:\\myfile.txt"); bufferedreader br = null; system.out.println("enter regex pattern matched"); scanner keyboard = new scanner(system.in); string regxpat = keyboard.nextline(); string line; br = new bufferedreader(new filereader(doc)); pattern p = pattern.compile(regxpat, case_insensitive); while ((line = br.readline()) != null) { try { matcher m = p.matcher(line); m.find(); system.out.print(m.group().tostring()); } catch (illegalstateexception e) { } continue; } //i tried regex= "(he)*([.&&[^\.]]*?)milan(.*?)\." if text is: "...thomas edison scientist. invented bulb. born in milan, ohio, , grew in port huron, michigan. seventh , last child of samuel ogden edison, jr...." i want sentence(sentence boundary full stop follo...

Remove an event from jQuery queue -

i want remove calculatecost event when meets criteria. there isn't room design changes, have work with: layout, aspx page jquery tab (each tab .net user control). tabs added dynamically. within user control follow input element exist , method bound onchange event target. <input type="text" id="txtcost" disabled="disabled" onkeypress="return isvalidmoney(event);" onchange="calculatecost(true, false); validatecostperuom(this);" runat="server"/> what happening: when field being edited , doesn't lose focus event not fired. user doesn't trigger blur , selects different tab. onchange event fired (jquery or .net) during function execution selected tab value changes hosing things up. what i'd in jquery tab's select method check method in execution queue , remove (or stop it). have no code samples because have no clue start. tried looking @ jquery.queue() api doc fruitless. thanks!!!

php - zend framework 2 constants -

i have declare constants available anywhere in application. in zend framework 1 used declare in application.ini : constants.name_title = "user name", where , how in zend framework 2 ? i have found solution here . have create storage class in model. in class can create many constants want. <?php namespace application\model; class application { const email = 'email@gmail.com'; } now can accessed everywhere by: nameofmodule\model\nameofmodel::nameofconstant so can example print constant in view this: <?php echo application\model\application::email; ?>

c++ - Decisions using Template Tags -

i have templated class need instantiate depending on command line arguments. there must better way can think of: if (optiona == 1){ if (optionb == 2){ myclass <option1, option2, option3> object; } } else if (optiona == 2){ // whole big if-else ladder } this doesn't allow me use templated object outside scope of if statement! way, options tags your challenge want compile-time decision (option type selection) based on runtime data (args). imagine macro/template solution generated 'parse tree', mapping option codes tags. result in combinatorial explosion generate templated types, slow compilation (and runtime). alternative use factory methods each option, passing option objects myclass constructor. not efficient pure compile-time generation, don't see alternative.

java - repaint function not work when event happen -

i trying change button background color 10 time when event happen? private void jbutton2actionperformed(java.awt.event.actionevent evt) { try { (int = 0; < 10; ++i) { random r = new random(); jbutton2.setbackground(new color(r.nextint(150), r.nextint(150), r.nextint(150))); jbutton2.repaint(); thread.sleep(200); } } catch (exception e) { system.out.println(e.tostring()); } } but button show last color?? thanks it's work correctly int x = 0; timer timer; private void jbutton2actionperformed(java.awt.event.actionevent evt) { timer = new timer(1000, new actionlistener() { @override public void actionperformed(actionevent e) { random r = new random(); jbutton2.setbackground(new color(r.nextint(150), r.nextint(150), r.nextint(150))); jbutton2.r...

node.js - Pros and cons of different ways of adding a real-time multiplayer game to a website on PHP -

background the website has classic lamp setup , runs on virtual private server. aim add html5 multiplayer game runs on same domain, has latency of 500ms, maintains state on server side , can support few thousand concurrent games 2-5 players per game @ peak times. since had little experience php , server side in general, original plan write game demo in node.js+socket.io , rewrite in php later on. however, i've written demo (~400 lines of code on server side) have doubts plan. there 2 ways of integration considering: write game in php pros: fewer changes original setup not having split server side 2 parts in terms of languages, templates etc. cons: lack of popular solutions real time communications in php scalability concerns run node.js , php servers in parallel since site hosted on vps, think can put nginx in front of apache , node.js client have use single port on single domain. pros: ability use socket.io real-time communication client if game s...

ios - Getting UIScrollView to work correctly on iPad -

2nd update courtesy of thread in ios6, xcode 4.5, uiscrollview not scrolling, despite contentsize being set the answer has been provided! turning off auto layout on storyboard (the entire thing) fix scrollview , allow things scroll properly. spread word people! update added code. cannot figure out why not work on ipad. .h file #import <uikit/uikit.h> @interface viewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uiimageview *imageview; @property (weak, nonatomic) iboutlet uiscrollview *scrollview; @end .m file #import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; self.scrollview.contentsize = cgsize(768, 1600); } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end again clarify i'm using storyboards, i'm first dragging in scrollview, setting size standard ipad screen (...

ruby - How do I download a web page into a single file from a specified URL? -

i'm trying scrape web pages. i want download web page providing url , save offline reading images. can't manage wget since creates many directories. is possible wget? there "save as" option in firefox creates directory , puts required resources html page? would possible nokogiri or mechanize? you can use wget , run within ruby script. here's example rip homepage of site, skrimp.ly, , put contents single directory named "download". @ top level , links embedded in html rewritten local: wget -e -h -k -k -p -nh -nd -pdownload -e robots=off http://skrimp.ly note: should checkout of docs wget. can crazy stuff go down multiple levels. if sort of thing please cautious -- can pretty heavy on web server , in cases cost webmaster lot of $$$$. http://www.gnu.org/software/wget/manual/html_node/advanced-usage.html#advanced-usage

jquery - read a div from an html file to a javascript var -

i want read coltwo div file members.html (in same folder) variable, set innerhtml variable. result 'undefined'. how can fix this? var fredpagevar; $.get("members.html", function(data){ fredpagevar = $(data).find('#coltwo').html(); }); function fredpage(){ document.getelementbyid('boldstuff').innerhtml = fredpagevar;} based on markup : <li><a href="#" onclick='fredpage()'>fred</a></li> try - function fredpage(){ $.get("members.html", function(data){ $('#boldstuff').html($(data).find('#coltwo').html()); }); }

git - Setting no "fast forward" as the default when merging. Is this wise and what are some of the consequences? -

so follow workflow of master branch production code only, while development done on development branch merge feature branches. git merge --no-ff because records commit history of feature branch when merging development. however, i've seen many warnings approach when setting no fast forward default in git config. has had problems approach? can explain reasons bad idea? i think 1 downside setting --no-ff default when working team may encounter cases want fast forward merge update feature branch team member collaborated on you. it might better approach create alias handle merges --no-ff

validation - Java validating a range of numbers from user input -

i have been having problem validation, , stressing me out, have done in various ways different loops, , 1 have of one, if take out if statement if function numbers, since program can accept numbers 1 5 want take step validating number , returning it. try declaring int option inside loop not carry out return statement. public int makeoption(){ int option; system.out.println("choose following options: "); system.out.println("(1)create entry || (2)remove entry || (3)list entry || (4)list || (5)exit "); while(!reader.hasnextint()){ system.out.println("choose valid option."); reader.next(); } if(reader.nextint()<1 || reader.nextint()>5){ system.out.println("choose valid number options."); reader.next(); } option = reader.nextint(); system.out.println("you choosed: " + option); return option; } swap out if statement switch statement: in...

nasm - What does mov cx, 02001Q mean in assembly -

i'm doing analysis of shellcode found @ http://www.shell-storm.org/shellcode/files/shellcode-211.php i wondering particular instruction does: mov cx, 02001q i know moves value cx, i'm not sure q stands for. from nasm docs ; nasm allows specify numbers in variety of number bases, in variety of ways: can suffix h or x, d or t, q or o, , b or y hexadecimal, decimal, octal , binary respectively in other words, 02001q means 2001 octal.

regex - Matching word with php -

after doing research can't seem find solution problem. have list of bad words , want able see if user left comment of words. have tried different regular expressions no success. btw im no regex guru. lets have word $word = 'bi' on list. , comment says: $comment = bi , using preg_match($pattern, $comment) parent has been: 1) $word#i 2) /\s+($word)/\s+/i 3) /\b($word)/\b/i with code: if (preg_match($pattern, $commentdata['comment_content'])) { echo 'spam'; } else { echo 'true' } i get: 1) spam this case words linke combination dont want block 2) true 3) true how can make pattern matches word , not word within? this job, near solution: preg_match("~\b$word\b~i", $comment); for particular cases 'bi-directional' : you can use instead: preg_match("~(?<![a-z]-)\b$word\b(?!-[a-z])~i", $comment);

php - Undefined Offset 0 , how can i set this array -

hello have undefined offset 0 . inside code. $q = mysql_query("select * category"); if (false === $q) { echo mysql_error(); } while ($r = mysql_fetch_row($q)) { $names[$r[0]] = $r[2]; $children[$r[0]][] = $r[1]; } function render_select($root=0, $level=-1) { global $names, $children; if ($root != 0) echo '<option>' . strrep(' ', $level) . $names[$root] . '</option>'; foreach ($children[$root] $child) render_select($child, $level+1); } echo '<select>'; render_select(); echo '</select>'; the exact line error : foreach ($children[$root] $child) render_select($child, $level+1); this selectbox tree format, found code in question more efficient hierarchy system there ambiguity in code here: if ($root != 0) echo '<option>' . strrep(' ', $level) . $names[$root] . '</option>'; foreach ($children[$root] $child) render_select...

actionscript 3 - Click Event in a cell of a Flex Spark Datagrid -

i have following code: <s:datagrid id="preciosgrid" top="65" width="935" height="379" horizontalcenter="0" requestedrowcount="4" dataprovider="{clientmodel.model.arraycolumnproducts}"> <s:columns> <s:arraylist> <s:gridcolumn headertext="edit" width="30" itemrenderer="renderers.editgridrender"></s:gridcolumn> <s:gridcolumn datafield="product" headertext="product" width="200" editable="false"></s:gridcolumn> <s:gridcolumn datafield="provider" headertext="" width="52" editable="true" itemrenderer="renderers.pricecellitemrenderer"></s:gridcolumn> </s:arraylist> </s:columns> </s:datagrid> and need able catch double-click e...

mysql - ejabberd "mysql_conn: Received unknown signal, exiting" error -

i use ejabberd 2.1.12. seems work fine, in logs keep getting mysql connection errors. thought because of mod_roster_odbc (according i.e. this thread, disabled mod_roster , mod_shared_roster , nothing has changed). i on amazon ec2 on ubuntu 12.04. errors raised 2 minutes after connecting users chat. update: have found pattern here. when connect few users (using adium), every few minutes there few errors that. not depends on connected users count because same 2 , 8 connected users. every error 1 more mysql connection if 5 errors have 5 new connections, after while goes initial connections number. here log: =error report==== 2013-05-09 19:52:55 === e(<0.585.0>:ejabberd_odbc:552) : mysql_conn: received unknown signal, exiting : {mysql_recv, <0.586.0>, closed, ...