Posts

Showing posts from September, 2013

Hubot's github-pull-request-notifier.coffee -

i got hubot setup irc , works fine. i'm trying add this script. i'm not entirely understanding setup instructions however. setup instructions read curl -h "authorization: token <your api token>" \ -d '{"name":"web","active":true,"events":["pull_request"],"config":{"url":"<this script url>","content_type":"json"}}' \ https://api.github.com/repos/<your user>/<your repo>/hooks i don't understand "url":"<this script url>" refers to. know? i'm deploying heroku if helps. add more explanation @mikekusold 's answer the curl command create github hook , therefore set hook receiver notification. "config": { "url": "http://example.com/webhook", "content_type": "json" } the hook hubot plugin, url path defined in that script , see

Regex + vs *. What is the standard? -

i use regex quite bit find , replace, , want use best practices as possible. i understand difference between + , * characters. reference * find matches specified phrase, , + find last instance of specified phrase. that being said, when regex phrases on internet, see lot of people using + feel using * . standard use + instead of * on generic regex phrases or there convention missing? the site you've linked great, you're misunderstanding definitions of * , + . essentially, * means "zero or more," + means "one or more." in other words: x* means "any number of x characters in row, or possibly none @ all. " x+ means "any number of x characters in row, at least one. " so x+ equivalent xx* (or x*x ). both have infinite upper limit, different lower limits. as far 1 standard/best practice, answer "neither," since both have different meanings. however, if you're trying match 1 or more of so

java - Real-Time Excel Updates -

i have third party application updates cell values opening excel file, setting values in cells, , writing (saving) excel file. suppose have excel spreadsheet open @ times, how have spreadsheet reflect these changes in real-time? every time there update, have re-open excel file see new changes. ps. using apache poi. thank you. you cannot using apache poi. if have excel spreadsheet open in excel, filenotfoundexception if attempt write changes file. @ least on windows, this: java.io.filenotfoundexception: myspreadsheet.xlsx (the process cannot access file because being used process) additionally, if worked, there nothing in apache poi api interacts excel application itself, cannot tell excel re-open spreadsheet.

c# - Nested looping XML elements -

this xml: <scenario> <steps> <step name="a"> <check name="1" /> <check name="2" /> </step> <step name="b"> <check name="3" /> </step> </steps> </scenario> i trying loop through xml elements by, each step, doing step's respective check elements. so: foreach(step step in steps) { foreach(check in step) { // } } it might output like: a1 a2 b3 the code i'm using is: foreach (xelement step in document.descendants("step")) { // start looping through step's checks foreach (xelement substep in step.elements()) { however not looping properly. nested loop structure above doing check elements each step, instead of doing child check elements of each step. example, output of code is: a1 a2 a3 b1 b2 b3 how can fix loops? your code fine. see this fore

python - gevent-socketio not using my @app.route endpoint for socketio -

i using flask gevent-socketio: $ cat requirements.txt flask==0.10.1 jinja2==2.7.1 markupsafe==0.18 werkzeug==0.9.3 argparse==1.2.1 gevent==0.13.8 gevent-socketio==0.3.5-rc2 gevent-websocket==0.3.6 greenlet==0.4.1 itsdangerous==0.23 wsgiref==0.1.2 i'm using pretty standard setup start server: #called __main__ def run_dev_server(): app.debug = true port = 5000 dapp = werkzeug.debug.debuggedapplication(app, evalex = true) socketioserver(('', port), dapp, resource="socket.io").serve_forever() and pretty standard hook socketio namespace: @app.route('/socket.io/<path:rest>') def push_stream(rest): print 'ws connect', rest try: socketio.socketio_manage(request.environ, {'/join_notification': joinsnamespace}, request) except exception e: app.logger.error("exception while handling socketio connection", exc_info=true) return flask.response() however, i'm having probl

How to add transparent image on Oracle Reports? -

in 1 of oracle report, have 2 images overlay each other , front image covered part of image on back, set watermark. is there way can add transparent image in oracle reports? i have tried make image transparent in gif , tif format, after load image oracle reports, transparent part of image tuns black colour instead of no colour (transparent). i know using photoshop or other tools make front image looks transparent way, want if there solution it. any suggestion welcomed. thanks.

c++ - Can I get a code page from a language preference? -

windows seems keep track of @ least 4 dimensions of "current locale": http://www.siao2.com/2005/02/01/364707.aspx default user locale default system locale default user interface language default input locale my brain hurts trying keep track of hell 4 separate locale's useful for... however, don't grok relationship between code page , locale (or licd, or language id), of appear different (e.g. japanese (japan) langid = 0x411 location code 1, code page japan 932). how can configure our application use user's desired language default mbcs target when converting between unicode , narrow strings? that say, used mbcs application. switched unicode. things work in english, fail in asian languages, apparently because windows conversion functions widechartomultibyte , multibytetowidechar take explicit code page (not locale id or language id), can set cp_acp (default ansi code page), don't appear have value "default user's default interfa

html - CSS ignoring @font-face declarations -

i have 2 @font-face assignments in css. second/last 1 ever renders, though identical. @font-face { font-family: 'callunaregular'; src: url('callunaregular/calluna-regular-webfont.eot'); src: url('callunaregular/calluna-regular-webfont.eot?#iefix') format('embedded-opentype'), url('callunaregular/calluna-regular-webfont.woff') format('woff'), url('callunaregular/calluna-regular-webfont.ttf') format('truetype'), url('callunaregular/calluna-regular-webfont.svg#callunaregular') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'bodonitownregular'; src: url('bodonitownregular/bodonitown-webfont.eot'); src: url('bodonitownregular/bodonitown-webfont.eot?#iefix') format('embedded-opentype'), url('bodonitownregular/bodonitown-webfont.woff') format('woff'),

charts - KendoUI ChartEventBuilder DataBinding event not working -

i'm working kendoui mvc complete , dataviz charting package. i've got databound event hooked , firing well, can't seem databinding event fire. in documentation, charteventbuilder have databinding method , implement specified never gets handled. in docs charteventbuilder.databinding method details, points javascript documentation databinding event, anchor doesn't exist (and databinding event doesn't exist either)! kendo.mvc.ui.fluent.charteventbuilder databinding link here ... , page has link points page databinding event documentation doesn't exist kendo.dataviz.ui.chart databinding link here doesn't exist it's confusing since event mvc extension exists doesn't seem anything. or - doing wrong? i'm hoping can point me working example since none of demos on kendo site show chart databinding event in practice. the databinding event shouldn't exist in charteventbuilder. it carried on mistake during migration legacy tel

python - Program for word reversal randomly skips out letters? -

my program keeps randomly skipping out letters! example, 'coolstory' becomes 'yrotsloc' , 'awesome' becomes 'mosewa' here code: def reverse(text): length = len(text) reversed_text = [] in range(0,length + 1): reversed_text += [''] original_list = [] l in text: original_list.append(l) new_place = length - (original_list.index(l)) reversed_text[new_place] = l return "".join(reversed_text) this happens when have duplicate letters because original_list.index(l) will return same value same l . new_place same 2 of same letters @ different locations. one common way reverse strings in python slicing: >>> s = "hello" >>> s[::-1] 'olleh' you can use reversed() , returns reversed object (not string). better option if want iterate on string in reverse order: >>> c in reversed(s): ... print c ... o l l e h

python - Get the existing margin on a pdf page -

i need existing margins(left, right, top, bottom) on page of pdf file in perl, here code dimension of padf page. !/usr/bin/perl use strict; use warnings; use cam::pdf; $pdf = cam::pdf->new('test2.pdf'); $num_page=$pdf->numpages(); print "total pages : $num_page\n"; ($x,$y,$width,$height)=$pdf->getpagedimensions(2); print "dimension of pdf file : $width x $height px \n"; $width=sprintf("%.2f",$width/72); # ppi/dpi conversion (72 px = 1 inch) $height=sprintf("%.2f",$height/72); print "dimension of pdf file : $width x $height inch \n" a pdf file not word document, cannot change "margins" , have text reflow new size. more image snapshot (i.e. tiff file) of rendered document has been formatted , laid out on page. there no concept of "margin" setting in pdf. @ point it's blank page bunch of objects placed on it. happens most of objects contained within large box defin

git-pull omits a file -

git saying date there file missing on 1 node's copy of source tree. on system a: $ ls -l abc.py xyz.py $ git add xyz.py $ git status nothing added commit... $ git commit nothing added commit... $ git push up-to-date on system b: $ git pull up-to-date $ ls -l abc.py my question is: happened file xyz.py on system b? why did pull not create on system b?

.net - What is the difference between Domain Handlers and Application Services in Project Silk? -

this in reference usage of ddd in project silk . the project uses ddd , has concept of handlers , services implemented. difference , use case these 2 types? for instance, there service userservices creation of user. creation fo vehicle done in handler. would know reasoning behind decision. domain\userservices public class userservices : iuserservices { private readonly iuserrepository userrepository; public userservices(iuserrepository userrepository) { if (userrepository == null) throw new argumentnullexception("userrepository"); this.userrepository = userrepository; } public user createuser(user newuser) { if (newuser == null) throw new argumentnullexception("newuser"); try { model.user usertoadd = todatamodeluser(newuser); this.userrepository.create(usertoadd); retur

c# - Read the Value of an Item in a listbox -

i'm developing small windows store application in c# have populated values , content listbox using following code snippet. code 1 : adds song title item listbox , using song class create item private void addtitles(string title, int value) { song songitem = new song(); songitem.text = title; songitem.value = value; listbox1.items.add(songitem); // adds 'songitem' item listbox } code 2 : song class used set values each item ('songitem') public class song { public string text { get; set; } public int value { get; set; } public override string tostring() { return text; } } population content listbox functioning currently. what want 'value' of each item on click event, on run-time. for purpose, how can read(extract) value of selected item in listbox , in c#? ( value songitem.value ) code 3 : have tried code, trying figure out solution, didn't work priv

linux - How can I use a pipe or redirect in a qsub command? -

there commands i'd run on grid using qsub (sge 8.1.3, centos 5.9) need use pipe ( | ) or redirect ( > ). example, let's have parallelize command echo 'hello world' > hello.txt (obviously simplified example: in reality might need redirect output of program bowtie directly samtools ). if did: qsub echo 'hello world' > hello.txt the resulting content of hello.txt like your job 123454321 ("echo") has been submitted similarly if used pipe ( echo "hello world" | myprogram ), message passed myprogram , not actual stdout. i'm aware write small bash script each contain command pipe/redirect, , qsub ./myscript.sh . however, i'm trying run many parallelized jobs @ same time using script, i'd have write many such bash scripts each different command. when scripting solution can start feel hackish. example of such script in python: for i, (infile1, infile2, outfile) in enumerate(files): command = ("bowtie

Set focus on input field with jquery in specific table row -

i have following html: <table> .... <tr> .... </tr> .... <tr id="myid"> <....> <input value="..." /> </....> </tr> <tr id="myanotherid"> <....> <input value="..." /> </....> </tr> </table> how can set focus on input field in table row "myid" jquery ? can't set id on input field, because html generated automatically. use table anchor , find input regardless of value. $('table tr#myid').find('input:first').focus()

visual studio 2010 - vb.net (4.0 framework) form not loading -

Image
hoping might able shine light on issue. i have form in vb.net (using vs2010, .net 4.0 framework) not load, instead errors out in variable declarations. have following 2 lines in declarations dim rprbuilders new rprbuilder_2010.rp_rbuilder public cr new reportdocument now, when place breakpoints on each line, breaks @ first line, errors out upon processing "public cr new reportdocument" , receive generic error screen: i have downloaded , imported crystal report libraries vs2010, , using versions 13.0.2000.0 in project. the exception detail provided isn't helpful me, 1 of may able understand better i: system.invalidoperationexception unhandled message=an error occurred creating form. see exception.innerexception details. error is: invalid servicedcomponent-derived classes found in assembly. (classes must public, concrete, have public default constructor, , meet other comvisibility requirements) source=reportbuilder2010

c# - CsvReader Mapping and Conversion : No coercion operator -

first, thank time. i'm trying use csvhelper first time along custom class , custom map. i'm getting "no cercion operator defined between types 'system.int32' , 'system.string'" here classes: class vendor { public string vendorid { get; set; } public string vendorname { get; set; } public string vendorshortname { get; set; } public string vendorcheckname { get; set; } public string hold { get; set; } public string vendorstatus { get; set; } public string vendorclassid { get; set; } public string primaryvendoraddressid { get; set; } public string vendorcontact { get; set; } public string address1 { get; set; } public string address2 { get; set; } public string address3 { get; set; } public string city { get; set; } public string state { get; set; } public string zipcode { get; set; } public string countrycode { get; set; } public string country { get; set; } public string pho

How do you detect that a script was loaded *and* executed in a chrome extension? -

i've been tracking down bug days... realized bug me. :/ i had been using webrequest.oncomplete, filtered scripts. error made incorrect association between scripts being loaded , being executed. loaded in different order executed, , timing of events not in order need them in. need inject between scripts need event right after file has been executed , before next one. the solution can think of @ moment alter js being loaded before gets executed. makes stomach turn. , bfcache wreak more havoc, not great solution either. i use html5 spec's afterscriptexecute, not implemented in chrome. there api, perhaps extension api can use? note: method no longer works of chrome 36 . there no direct alternatives. note: answer below applies external scripts, i.e. loaded <script src> . in chrome (and safari), "beforeload" event triggered right before resource loaded. event allows 1 block resource, script never fetched. in event, can determine whether loaded

java - Array initialization in Android OS -

i in first phone development class using dhtml way when offered nextel. not date on going on or since then. creating simple text file driven quiz program using radio buttons. so forcing myself write in java, load csv memory multi-dimensional array , loop through. talking 40 lines of text. question more integration of java phone, how occurs, , appropriate place load array prior execution of activitymain.xml? there flow chart how things execute through android? if "load" mean initialize , give array values, can load array anywhere...maybe outside of method make member variable accessed throughout activity . public class foodsearch extends activity { string[] questions = new string[40]; // want create array // add values if want here public void oncreate(bundle bundle) { // code but can't use contents in view until have called setcontentveiw() . if post of code how doing can better you public void oncreate(bundle bundle

symfony - How can make a INNER JOIN in a DQL sentence? -

i have problem dql in symfony2 project. have defined 3 entities: a entity called category 2 fields : id , slug a entity called subcategory 2 fields : id , slug a entity called categorysubcategories 2 fields : category , subcategory i need obtain subcatgories category (slug) given. got next dql : $em ->createquery('select subcat subcategory subcat subcat.id in (select identity(csc.subcategory) categorysubcategories csc csc.category in (select cat category cat cat.slug = :category))') ->setparameter('category', $category); is there anyway build dql inner joins ? in mysql example: select subcat.slug category cat inner join categorysubcategories csc on (cat.id = csc.category_id) inner join subcategory subcat on (csc.subcategory_id = subcat.id) cat.slug "$category" is there anyway translate dql ? in own opinion, there no need have third entity, 2 enough (category , su

git - github error: insufficient permission for adding an object to repository database -

i used able do, app folder: git add . git commit -m "commit details" git push and latest version of app on local machine backed on in master repo, on github. now, when far git add . command, get: mycompaq@ubuntu:~/myapp$ git add . error: insufficient permission adding object repository database .git/objects error: app/views/reviews/update.js.erb: failed insert database error: unable index file app/views/reviews/update.js.erb fatal: updating files failed mycompaq@ubuntu:~/myapp$ i read in message on stackoverflow way overcome similar problem with: chown -r user:user /project/directory but seeing got in whole load of trouble in first place running commands wasn't sure about, want know if command me. do? can undone? what should exact syntax be, if user 'christophe', , folder rails app stored called 'myapp'. mean should chown -r user:christophe /myapp/app/views/reviews/update.js.erb sorry questions. chown [ -f ] [ -h ] [ -

Python "Hello World" on 1 & 1 server for my web domain -

-create python file (.py) upload folder on on server (i have 1 & 1's "unlimited" package) dedicated mydomain.com -follow link on internet mydomain.com -see "hello world" of python file zed shaw has not taught this, , info doesn't work --> http://docs.python.org/2/howto/webservers.html i have located correct location of python installation on server, , included correct information in first line. , have confirmed via ssh code works. 1 thing can't do...and nobody explains explicitly, how correctly hello world on browser internet. if read instructions correctly, another person upload web server (and test) python program. note "that i upload" in first line. i'm sure pronoun " i " refers author of instructions , not you.

asp.net mvc - Remove migration files and recreate Initial.cs -

i've been using migrations while now, , i've ended bunch of migration files. i've been having trouble seed method duplicates data (when trying use id "identifier"), when want create data once. now thinking of removing migration files , recreating initial 1 tidy bit. planning on seeding data in up() method using sql(), instead of using seed() method. i've got bunch of sites running paying clients. don't want risk ending in situation have chose not being able update db schema, , having drop clients data (that bad on part). i feel unsure whole migration thing. i've had occurrences in stages of development migrations got screwed , had drop/recreate db. so questions boils down to...will encounter problems updating running sites if remove migration files , recreate 1 big initial migration? this current configuration.cs. i'm using option in web deploy "execute code migrations" on application_start(): internal sealed class configu

Can Findbugs detect catching RuntimeException in java? -

could let me know taht findbugs can detect catcing runtimeexception in java? effective java recommends should not catch runtimeexception. so want know findbugs can grab wrong catching. additionally, checked klocwork jd.catch , checkstyle illegalcatch appropriate purpose. sort of. in findbugs there several bug detectors dealing exceptions: de: method might drop exception de: method might ignore exception nm: class not derived exception, though named such rv: exception created , dropped rather thrown rec: exception caught when exception not thrown and findbugs-contrib (findbugs plugin) has some: bed_bogus_exception_declaration dre_declared_runtime_exception exs_exception_softening_no_checked exs_exception_softening_has_checked exs_exception_softening_no_constraints try out , check if match requirements (especially last 1 (rec) of fb). if plainly need detect following pattern: catch ( runtimeexception re){ .... } you may nee

html - Cover background-image with transparent background-color -

i'd place transparent, blue background color on background image, can't seem color overlay on image. update: changed margins name takes 70% , margins 30%. however, doesn't overlay on 2 margins. (see updated fiddle) any ideas on how? html: <body> <div id="name"> <h1 id="h" ><a href=#>h</a></h1> <h1 id="e" ><a href=#>e</a></h1> <h1 id="l" ><a href=#>l</a></h1> <h1 id="l2" ><a href=#>l</a></h1> <h1 id="o" ><a href=#>o</a></h1> </div> </body> css: body { font-family: 'sigmar one', cursive; font-size: 75px; color: white; text-shadow: 5px 5px 5px #000; background-color:blue; background: url(http://placekitten.com/500/500) no-repeat center center fixed; -webkit-ba

project - Selecting values based on other values SQL? -

i wasn't sure title question, apologize if title misleading. i have 2 columns in table movieid , format (i have more, these ones focusing on. there 2 types of values in 'format' column: 'dvd' , 'blu-ray'. want select movies have dvd format. note there multiple movies have blu-ray , dvd format, not want display these values. see fiddle below sample of data. thank you!!! http://sqlfiddle.com/#!2 movieid | format ----------------- 1000 dvd 1000 dvd 1000 blu-ray 1001 dvd 1001 dvd 1002 dvd 1003 dvd 1003 blu-ray 1004 dvd i want output movieid ------------ 1001 1002 1004 one straightforward way accomplish follows: select distinct (movieid) movies m format='dvd' , not exists ( select * movies mm mm.movieid=m.movieid , mm.format='blu-ray' ) this pretty translation of english description of problem sql syntax.

messagebox - How to set the font in different styles for Message Box in WPF -

Image
how can message box in below style eaisly? messagebox function seems cannot trick you can make own notification dialog using window here quick example whipped together usage: notificationdialog.shownotification("backup , restor center" , "you need administrator run backup" , "use fast user switching switch account administrator privileges, or log off , log on administrator" , notifyicon.exclamation); code: using system; using system.componentmodel; using system.drawing; using system.reflection; using system.runtime.compilerservices; using system.runtime.interopservices; using system.windows; using system.windows.interop; using system.windows.media.imaging; namespace wpfapplication8 { /// <summary> /// interaction logic notificationdialog.xaml /// </summary> public partial class notificationdialog : window, inotifypropertychanged { public sta

email - What makes PHP's mail() function so slow? -

i made quick php script on server containing call mail() , started testing it. html page loads instantly, assume means php containing call mail() finished executing. however, emails sent mail() ever being received every 10-20 minutes after call. why delay? mail() trigger external programs? (the emails being sent gmail email account if that's relevant) the behavior seeing has nothing php's mail() function. instead, smtp mail server php hands off message to, taking time deliver. service known a mail transport agent, or mta . there lots of potential reasons won't delivered immediately. possibly, delay see greylisting on receiving server, meaning receiving mail server refuses accept message until sending server (which php script handed to) tries few times resend it. well-behaved mta's retry failed send attempts, spam servers don't, making simple effective method cutting down spam. it simple long queue of messages on smtp server waiting sent, whereb

c++ - difference between L"" and u8"" -

is there difference between followings? auto s1 = l"你好"; auto s2 = u8"你好"; are s1 , s2 referring same type? if no, what's difference , 1 preferred? they not same type. s2 utf-8 or narrow string literal. c++11 draft standard section 2.14.5 string literals paragraph 7 says: a string literal begins u8 , such u8"asdf" , utf-8 string literal , initialized given characters encoded in utf-8. and paragraph 8 says: ordinary string literals , utf-8 string literals referred narrow string literals. narrow string literal has type “array of n const char ” , n size of string defined below, , has static storage duration (3.7). s1 wide string literal can support utf-16 , utf-32. section 2.14.5 string literals paragraph 11 says: a string literal begins l , such l"asdf" , wide string literal . wide string literal has type “array of n const wchar_t ” , n size of string defined below; has static storage duratio

extjs4.2 - ExtJs 4.2 example build -

i new extjs. when practicing in eclipse need include entire library(52 mb approx) in appropriate location? is there shorter version of library? can delete files in library not important? what necessary .js files included building sample mvc pattern, crud operation support application in extjs 4.2? for setup, include /ext directory in project, exclude build path doesn't slow eclipse down. see eclipse: javascript validation disabled. still generating errors? then, if don't want see directory in workspace, can create working set . i wouldn't recommend deleting/excluding extjs source files project, if using sencha cmd and/or using dynamic loading in application. if want include bare-minimum, away using ext-all.js , ext-all.css , , making sure have of extjs image files.

mysql - Open Street Map Address Decode -

i using nominatim reverse geocoding service address latitude , longitude. then, store result in mysql database. coding fiddle below: http://jsfiddle.net/gwl7a/171/ the address returned in local language such in example in chinese. , data stored not readable as: "麒麟山新æ‘, 惠æ¥Ã¥Å½¿, Ã¥¹¿Ã¤¸Å“, 中åŽäººæ°‘Ã¥…±Ã¥’Å’Ã¥›½/china" is possible make address returned in english. if that's not possible, how store data database when retrieve , show in web ui, returned chinese words? must not limited chinese word since might afghanistan, thailand, vietnam or other country's addresses. thank you. the object in question not yet internationalized in osm, nominatim can give original name (which in chinese). if need name “in english”/in latin script, have transcription yourself. guess 1 can find han- pinyin transcription library out there… btw: make sure use correct charset when adding strings database. osm using utf-8.

sql server 2012 express do not understand Russian letters -

Image
i have db working russian text when run queries shows me this. database used russians , has show russian text properly! any ideas how fix it? in future located in russia , work russian version sql server right working on english version sql 2012 express. here table , insert statement: create table employee ( empid int not null identity (10, 1), strname nvarchar (25) not null, phone1 nvarchar (25) not null, phone2 nvarchar (25) primary key (empid), ); insert employee (lastname , firstname,phone1,phone2) values ('Иванов','111 111 11111','111 111 1111'); are sure data has been stored in database correctly? how know? make sure column has proper collation, defined nvarchar , inserts of string literals prefixed n . example, these not same: insert dbo.table(column) select 'foo'; insert dbo.table(column) select n'foo'; as example: use tempdb; go create table dbo.foo ( id int primary key, bar nvarchar(32) col

vb.net - AES decrypt error -

hi getting error: padding between characters invalid , cannot removed or padding invalid , cannot removed. the code is: public shared function decrypt(byval text string) string dim inputbytes byte() = convert.frombase64string(text) dim resultbytes byte() = new byte(inputbytes.length + 1) {} dim decryptedtext string = [string].empty dim cripto new rijndaelmanaged() using ms new memorystream(inputbytes) using objcryptostream new cryptostream(ms, cripto.createdecryptor(_key, _iv), cryptostreammode.read) using sr new streamreader(objcryptostream, true) decryptedtext= sr.readtoend() end using end using end using return decryptedtext end function please me

pointers - What is the size and lifetime of a node in a linked-list implementation in C? -

in linked-list implementation in c (or c++), size of node , lifetime of pointer variable? example: struct node { int data; struct node *next; }*ptr=null; now want know size of node: 4 bytes, , if so, how? secondly, how long pointer live: throughout execution of program? lastly, proper call *ptr instance variable or data member or object? sizeof compile time operation . node structure . size of node summation of members size in structure . u have integer , pointer . size of node size of integer + size of pointer . lifetime : memory allocated dynamically . until call free , node lives . if u perform delete operation , programmer style used free memory allocated node .

performance - Unique random number algorithm -

i algorithm/function that, given number n, generates random numbers 0 n - 1 in constant time. after nth call, function may pleases. also, important algorithm generates numbers when requested rather using shuffling, because may (and in average case do) not need full list of numbers. best approach take? (optional read) thought of having hash set of numbers, , pulling numbers out 1 @ time, require inserting elements (which not need) hash set first... not work... argh thanks in advance. modify fisher–yates shuffle replacing array map stores elements have been moved. in python: import random class shuffle: def __init__(self, n): self.d = {} self.n = n def generate(self): = random.randrange(self.n) self.n -= 1 di = self.d[i] if in self.d else # idiomatically, self.d.get(i, i) dn = self.d[self.n] if self.n in self.d else self.n self.d[i] = dn self.d[self.n] = di return di the space usage

php - Laravel 4, Basset, Less - preg_match compilation failed -

background: using ubuntu 12.04, php 5.5.1-2, , laravel 4. when run: php artisan basset:build i error {"error":{"type":"errorexception","message":"preg_match(): compilation failed: nothing repeat @ offset 0", "file":"\/home\/ryan\/myapp6\/vendor\/jasonlewis\/basset\ /src\/basset\/filter\/filter.php","line":241}} my problem similar this: how make less work basset in laravel 4? however, have tried lessphpfilter, , have node.js installed... can manually compile stylesheet node, neither work me through basset. for example, given mytest.less: @color:blue; body{ background-color: red; color:@color; } myapp/app/config/packages/jasonlewis/basset/config.php 'collections' => array( 'mytest-css' => function($collection) { $collection->directory('assets/bs3/css', function($collection) { $collection->add('../les

c# - How to split string and display it in a gridview ? -

i have denominations stored in database(sql server 2008) column seperated $ sign following 1000*2=2000$500*1=500$100*0=0$50*0=0$20*0=0 i want split string , display in gridview column : 1000*2=2000 500*1=500 100*0=0 50*0=0 20*0=0 in 1 single column try following string val = @"1000*2=2000$500*1=500$100*0=0$50*0=0$20*0=0"; list<string> fields = new list<string>(val.split(new[] { '$' })); you can assign datasource member of gridview , call databind . gridview1.datasource = fields; gridview1.databind();

file - Read and write in c# -

i want read file(image) , file video in c# , save(write) contents of both files(1 after another) in single txt file.now want again retrieve first image file content , second file content separately. possible read video , image file save in single file. short answer : yes, possible. long answer : depends heavily on implementation. you may, example, create holder class receives both binaries properties, serialize them , commit storage; whenever necessary, load file , deserialize instance of holder class.

c++ - Where is Dhcpv6CApiInitialize? -

i trying dynamic loading of dhcpcsvc6.dll support ipv6 on win7 , ipv4 on xp. getprocaddress of dhcpv6capiinitialize fails. used exescope examine exports of dll, got. version: 6.1.7600.16385. 00000001 404632ea dhcpv6acquireparameters 00000002 40463e4f dhcpv6canceloperation 00000003 40463eb9 dhcpv6enabletracing 00000004 40461d3b dhcpv6freeleaseinfo 00000005 404644d3 dhcpv6gettracearray 00000006 404645d9 dhcpv6getuserclasses 00000007 404642d1 dhcpv6isenabled 00000008 40461730 dhcpv6queryleaseinfo 00000009 40463419 dhcpv6releaseparameters 0000000a 40463e31 dhcpv6releaseprefix 0000000b 40463bf5 dhcpv6releaseprefixex 0000000c 40463bd1 dhcpv6renewprefix 0000000d 40463892 dhcpv6renewprefixex 0000000e 40463f51 dhcpv6requestparams 0000000f 40463871 dhcpv6requestprefix 00000010 40463549 dhcpv6requestprefixex 00000011 404647d1 dhcpv6setuserclass dhcpv6capiinitialize not in it. tried dhcpc

python - Django aggregation across multiple tables in ModelAdmin queryset -

django code & reference django bug report given 3 models follows (simplified excessively demonstration...not identical related models) class derp(models.model): ... class derp_related_1(models.model): fk = models.foreignkey(derp) amount = models.decimalfield(max_digits=15, decimal_places=2) class derp_related_2(models.model): fk = models.foreignkey(derp) amount = models.decimalfield(max_digits=15, decimal_places=2) and overriding queryset in model admin follows. (it isn't working because of this django bug .) class derpadmin(admin.modeladmin): ... list_display = ['derp_r1_sum', 'derp_r2_sum'] ... def queryset(self, request): qs = super(derpadmin, self).queryset(request) qs = qs.annotate(derp_r1_sum=models.sum('derp_r1__amount', distinct=true)) qs = qs.annotate(derp_r2_sum=models.sum('derp_r2__amount', distinct=true)) def derp_r1_sum(self, obj): return u'%s'

php - What is the appropriate value for UDP port? -

i'm creating php script listening incoming data user. idea user able send udp packet remotely browser , show on browser. the script works fine when tested on localhost using xampp. after uploading script in server, fails bind socket connection everytime. tried port number 50000, 5000, 561, 61 , many others failing. here's php script, taken php's website ... $socket = socket_create(af_inet, sock_dgram, sol_udp); if ($socket == false) { echo 'socket_create failed'.socket_strerror(socket_last_error())."\n"; } if(!socket_bind($socket, $ip, $port)) { socket_close($socket); echo 'socket_bind_failed'; } socket_recvfrom($socket, $buf, 255, 0, $from, $port); so, decided known udp port shown here , seems used application. question is, appropriate value udp port?

php - How to have multiple fields (D/M/Y) for single date property in Yii? -

i want take user birth day database , there field in table called dob . when created model , crud generated text field dob always. want create 3 inputs. for years for months and dates so question how add inputs in model's form. thinking of adding new attributes model class there no such attributes in table. add fields model: public $year; public $month; public $date; add these methods model: protected function afterfind() { parent::afterfind(); $dob = explode('/', $this->dob); $this->year = $dob[0]; $this->month = $dob[1]; $this->date = $dob[2]; return $this; } protected function beforesave() { parent::beforesave(); $this->dob = $this->year .'/'. $this->month .'/'. $this->date; return $this; } you can use them in cactiveform form: <?php echo $form->textfield($model, 'year'); ?> <?php echo $form->textfield($model, 'month'); ?> &l

jquery - JavaScript event on addition of certain element -

there page list of urls, when user clicks on 1 of url, jquery modal popup opens list of elements. items in list added dynamically doing ajax call. each item in list has raty & timeago (both jquery plugins){"5 star rating, 2 months ago"}. now problem - typically execute javascript functions related these plugins @ time of page load in document.ready event. however, these functions need executed after items added & ready processing. what name of event handle? edit:- easier way visualize : when add comments question on stackoverlow; can see "added 5 minutes ago". part of counting time & showing 'time ago' handled 'time ago' plugin. function (timeago) must executed on on addition of element(comment in case of stackoverflow). want know handle execute function on addition of new element dom tree. you can use event delegation using jquery on dynamically added elements. $(document).on('click', '.classname

asp.net - Exception handling in C# and ASP .Net -

i have page , sql db behind sql table not allowed duplicate names addresses. connect db , trying implement try catch stamen working fore reason doesn't want show error message html <%@ page language="c#" autoeventwireup="true" codefile="admaddstreet.aspx.cs" inherits="admaddstreet" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> add new address<br /> <asp:textbox id="txbaddress" runat="server" height="22px" width="348px"></asp:textbox> <br /> <br /> <asp:button id="button1" runat="server" text="button" onclick="button1_click1" width="353px" />

php - Any extra steps required to ensure jQuery functionality on dynamic content fetched by getJSON? -

i have learnt how use jquery's getjson method php file making queries on mysql database running results through php's json_encode . <script> $(document).ready(function() { $(".click_me").click(function(){ $.getjson("http://path/to/file.php",function(results){ $("#container").html(results[0].key-name); }); }); }); </script> the functionality working except returned data (html) has classes wrapped around content should triggering jquery actions on hover , click etc. none of functionality working though , wondering if there sort of 'reinitialisation' needs take place on content 'dynamically' generated getjson method? the handlers have attached page @ load attached elements present during call. need either 1. attach them again calling teh functions 2. use $.on suppose added handler $(".someclass").click(dosomething) . can call line again , handler reattached class. after ajax call. you

neo4j - Order nodes by relationship count --> ThisShouldNotHappenError -

in neo4j database couple of nodes , relationships, trying find out "popular" users (in case: nodes participating in relationships): start n=node:user('*:*') match (n)-[r]->(x) return n order count(r) desc limit 10 however, query (neo4j 1.9.2) results in following error: thisshouldnothappenerror developer: andres claims that: aggregations should not used this. stacktrace: org.neo4j.cypher.internal.commands.expressions.aggregationexpression.apply(aggregationexpression.scala:31) org.neo4j.cypher.internal.commands.expressions.aggregationexpression.apply(aggregationexpression.scala:29) org.neo4j.cypher.internal.pipes.extractpipe$$anonfun$internalcreateresults$1$$anonfun$apply$1.apply(extractpipe.scala:47) org.neo4j.cypher.internal.pipes.extractpipe$$anonfun$internalcreateresults$1$$anonfun$apply$1.apply(extractpipe.scala:45) scala.collection.immutable.map$map1.foreach(map.scala:109) org.neo4j.cypher.internal.pipes.extractpipe$$anon