Posts

Showing posts from February, 2012

java - Not returning values, from a function with non-void return type -

i read here on so how : in c++ : not returning non-void function undefined behavior. ... analysis requires inspection of entire program, incompatible separate compilation, , not possible in general case ... from made out of several answers on page, difficult, , infact impossible sometimes, check presence of return statement in functions. not returning non-void function left undefined behavior c++ standard. however, heard in java, same thing reported error @ compile time. q. understanding correct ? , how java achieves same ? edit: clear, interested in understanding : if left undefined in c++ standard implementation difficulties related compiler, how java able achieve same. and if not difficult do, shouldn't c++ standard have defined error ? java refusing run programs, if return value. take following (stupid) method public boolean test() { boolean var=true; if(var) return true; } the method return true, java still refuse accept val

oracle11g - Oracle View based on "Offsets" of a Table Column -

so have table need create view from, we'll call tableabc. thing table has 2 columns. column 1 we'll call c1 , it's char(25) column. easy enough. the tricky part next column....and need it. we'll call c2 , 600 bytes! why may ask? it's 600 characters because storing data in based on offsets. for instance: name1 size:15 beginning offset:1 ending offset:12 name2 size:45 beginning offset:13 ending offset: 49 so need store column based on offsets, , "offset named" need specific, ie name1/name2 (actually called different things, name1/name2 now) there 15 of these offsets. now i've done bit of oracle admin stuff, basic stuff. know sql server better way beyond im used doing, im looking challenge. views sorta new me. makes more difficult. i figure maybe substr function, like: select substr(c2, 1, 12) name1 table would work? i've not done stored procedures, maybe theirs better way? edit: so sample wise, (i need add different offsets) w

c# - create a temp datatable to store values of records -

need dataset working on have dataset 2 tables 1 holds primary key values "statementnumber" , other hold rest of details 1 many relationship now want parse through each statementnumber 1 table details second table , place record new data table. 1 record @ time using loop till reach end of records primary table. how can c#? so far have both tables in same dataset. here code have already. using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using oracle.dataaccess.client; using system.data; using crystaldecisions.crystalreports.engine; using crystaldecisions.shared; namespace webapplication1 { public partial class webform1 : system.web.ui.page { protected void page_load(object sender, eventargs e) { } protected void button1_click(object sender, eventargs e) { string connetionstring = null; oraclecon

python - How to check for a SNS in ec2? -

as far understand sns can push messages subscribers. have simple script push message sqs. want basically: have sns topic, have ec2 instance, have sqs. sqs subscribed sns topic. i want following, when create new msg in sns, want ec2 received notification go check sqs. can last part (go , check sqs) don't understand how receive msg?????? for example, pub: context = zmq.context() socket = context.socket(zmq.pub) socket.bind("tcp://*:%s" % '5556') socket.send("hi") sub socket.recv() from example above, pub should sns , sub ec2, right? how listen new sns message?

iphone image change with motion -

hi there way set image [uiimage image named@"abc.png"] motion effect means image should not changed @ once , need change slow motion effect user can see image changing . thanks in advance * method 1 perform animation * step 1 : add following framework in project , import .m file #import <quartzcore/quartzcore.h> step 2 : write following code in imagechange method imageview.image = [uiimage imagenamed:@"newimage.jpg"]; catransition *transition = [catransition animation]; transition.duration = 1.0f; transition.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; transition.type = kcatransitionfade; [imageview.layer addanimation:transition forkey:nil]; * method 2 perform animation * [uiview transitionwithview:yourimageview duration:0.2f options:uiviewanimationoptiontransitioncrossdissolve animations:^{ yourimageview.image = newimage;

oracle - Comparing outputs from 2 separate sql queries -

i trying write query inventory system. in order have count number of duplicates in 1 table , compare default quantity values taken table. here 2 queries working currently: select template_id, count(template_id) howmuch, t.name consumables e, templates t t.consumable_type_id = '2410980' group template_id, t.name having ( count(template_id) > 1 ) the query above takes account of each unique template id , gives me count of how many duplicates present tells me amount of single substance. select property_descriptors.default_value, templates.name templates, property_descriptors templates.consumable_type_id = '858190' , templates.audit_id = property_descriptors.audit_id , property_descriptors.name = 'reorder point' this query finds amount of each individual substance have in our system. my issue dont know of way compare results 2 queries. ideally, want query give substance have duplicate co

Error when trying to import NetCDF to R -

i' struggeling open netcdf file in r. when try open library(ncdf) # read in netcdf file maize.nc<-open.ncdf("c:/users/jo/desktop/pft_harvest_maize.nc") i following error message: error in r_nc_open: netcdf: unknown file format error in open.ncdf("c:/users/jo/desktop/pft_harvest_maize.nc") : error in open.ncdf trying open file c:/users/jo/desktop/pft_harvest_maize.nc the weird thing is, netcdf file runoff-data exact same simulation exact same datatype opens without problems. the difference in filesize runoff: 56.1 mb (58,870,472 bytes) , harvest: 149 mb (156,968,508 bytes). files not big fail when opening. has idea how can trackback error causes problem?? using rnetcdf package same problem ( error: netcdf: unknown file format ) from ncdump get: netcdf pft_harvest_maize { dimensions: time = 199 ; npft = 32 ; latitude = 78 ; longitude = 79 ; variables: string namepft(npft) ; int time(time

c++ - Get the X509 data from a PFX certificate using CryptoAPI -

good day. stackoverflow has helped me many times before, bit stuck on 1 , hope can give me pointers. background: need pass x509 data of certificate adobe's sdk certlistcab in order sign pdf using acrobat plugin api. my question how can x509 data pfx certificate using cryptoapi? i've doing following: converting pfx certificate in-memory store. crypt_data_blob data; open file , populate data. file *fin = fopen("c:\\certificate\\mypfx.pfx", "rb") fseek(fin, 0, seek_end); data.cbdata = ftell(fin); fseek(fin, 0, seek_set); data.pbdata = (byte *)malloc(data.cbdata); fread(data.pbdata, 1, data.cbdata, fin); fclose(fin); hcertstore hcertstore = pfximportcertstore(&data, l"password", 0); find certificate. there one. pccert_context hcontext = certfindcertificateinstore (hcertstore, x509_asn_encoding | pkcs_7_asn_encoding, 0, cert_find_any, null, null); get public key information cert

php - Multi variables by links -

i'm making news archive. want news archive have several options. @ first want archive have option display news posted in year , option display news thats posted in category. these features both saved in database @ every post small php code can find posts created in e.g 2013. the problem is want make buttons in news archive. buttons can make user decide feature enabled or not (if understand i'm saying). want users have ability make sure posts of e.g 2013 appear on screen on same time posts of e.g sport news appear. making 2 features user enable, couldn't think of way linking them correct page. if click on specific year go article.php?year=2013 example. if want use other feature (category) it's impossible because send article.php?category=sport example , posts no longer searched on published year on category. i want make sure if 1 feature/option enabled other add &category=sport @ end of url url becomes article.php?year=2013&category=sport makes sure us

emacs - How to escape double quote? -

in org mode, if want format text monospace verbatim, i.e. ~...~ , if inside quotes: ~"..."~ , not formatted (left is). also, quotes reserved symbol, if so, mean? (they don't seem affect generated html / inside emacs display). the culprit in case regular expression in org-emph-re org-verbatim-re , responsible determining if sequence of characters in document set verbatim or not. org-verbatim-re variable defined in `org.el'. value "\([ ('\"{]\|^\)\(\([=~]\)\([^ \n,\"']\|[^ \n,\"']. ?\(?:\n. ?\)\{0,1\}[^ \n,\"']\)\3\)\([- .,:!?;'\")}\]\|$\)" quotes , double quotes explicitly forbidden inside verbatim characters =~ [^ \n,\"']\|[^ \n,\"'] i found discussions dating 3 years comming conclusion have tinker regular expression , set variable org-emph-re / org-verbatim-re matches wishes in emacs setup (maybe file local variable works well). can experimen

sql - ActiveRecord Joins -

i'm trying use activerecord best of it's ability , having trouble doing joins in way like. here how models set up: class model has_many :likes end class belongs_to :model belongs_to :user end class user has_many :likes end i likes 'model' object , there users made like. activerecord query is @model = model.find(params[:id]) @users = @model.likes.joins(:user) however, last line of code returns like, not user. there way use joins appropriately , want? thanks, you can has_many :through : class model has_many :likes has_many :users, :through => :likes end or can eager load users , join in ruby: @users = @model.likes.includes(:user).map(&:user)

shell: why [ -d ] returns true instead of false? -

as told here , command [ -d file ] used check whether file directory. however, when miss file parameter in expression, still returns true. why? how shell interpret expression then? example should straightforward enough :) $ [ -d /tmp ] $ echo $? # prints 0 $ [ -d ] $ echo $? # why prints 0 well? it gets interpreted [ -n -d ] . in other words, since you've provided 1 argument -d gets treated if other string, , can read in the man page : -n string length of string nonzero string equivalent -n string

html - scroll bars showing up when not expecting them line-height and overflow-y issue -

i getting unexpected (to me) behaviour vertical scroll bar showing up. not understand constraint on height of container might be. i able make problem go away either changing li's margin:1 or set ul's lineheight: normal instead of 1. can explain occurring? height have exceeded requires vertical scrollbar? i created simple jsfiddle illustrate issue having. html code: <div class="content-section" > <ul > <li>cheese</li> <li>crackers</li> </ul> </div> css code: body { line-height: 1; } ul { margin: 0; } .content-section { overflow-y: auto; } this because line-height set 1, means line-height same font-size. causes font overflow line. need set line-height value greater height of text, may have guessed. text technically behaving should. height of box defined height of lines, text ever larger lines. line-height should never equal font-size readability standpoint. hope h

json - Returning empty variables in PHP using Facebook Graph -

i trying retrieve data json feed , display using php. issue elements return empty. have in loop want return each post, not have picture, message or comments , comes notice: undefined variable. (i trying retrieve data fb group) here settings <?php // settings $groupid = "231809390188650"; $accesstoken = "mytokengoeshere"; // request , parse json $json_string = file_get_contents("https://graph.facebook.com/$groupid/feed? access_token=$accesstoken"); $parsed_json = json_decode($json_string); ($i = 0; $i < $json_string; $i++) { // returned data $gimage = $parsed_json->data[i]->picture; $gmessage = $parsed_json->data[i]->message; $gcreated_time = $parsed_json->data[i]->created_time; $gupdated_time = $parsed_json->data[i]->updated_time; $gcomments_message = $parsed_json->data[i]->comments->data[i]->message; }; ?> here output (rough example) <h1> facebook group </h1> <?php echo

sql - Improving Subquery performance in Postgres -

i have these 2 tables in database student table student semester table | column : type | | column : type | |------------|----------| |------------|----------| | student_id : integer | | student_id : integer | | satquan : smallint | | semester : integer | | actcomp : smallint | | enrolled : boolean | | entryyear : smallint | | major : text | |-----------------------| | college : text | |-----------------------| where student_id unique key in student table, , foreign key in student semester table. semester integer 1 first semester, 2 second, , on. i'm doing queries want students entryyear (and sat and/or act scores), of students associated data student semester table. currently, queries this: select * student_semester student_id in( select student_id student_semester student_id in( select student_id student e

python library for large tab/comma delimited text file -

i have big genomic data files analyze, come in 2 forms, 1 individual dosage file this: id snp1 snp2 snp3 snp4 snp5 snp6 rs1->1000001 dose 1.994 1.998 1.998 1.998 1.830 1.335 rs1->1000002 dose 1.291 1.998 1.998 1.998 1.830 1.335 rs1->100001 dose 1.992 1.998 1.998 1.998 1.830 1.335 rs1->100002 dose 1.394 1.998 1.998 1.998 1.830 1.335 rs1->10001 dose 1.994 1.998 1.998 1.998 1.830 1.335 rs1->1001001 dose 1.904 1.998 1.998 1.998 1.830 1.335 rs1->1002001 dose 1.094 1.998 1.998 1.998 1.830 1.335 rs1->1003001 dose 1.994 1.998 1.998 1.998 1.830 1.335 rs1->1004001 dose 1.994 1.998 1.998 1.998 1.830 1.335 rs1->1005002 dose 1.994 1.998 1.998 1.998 1.830 1.335 the other contains summary info: snp al1 al2 freq1 maf quality rsq 22_16050607 g 0.99

c# - Multi-Tenant Architecture for MVC 4 -

i need create/publish complex mvc site several clients, each shared functionality custom stuff, such client specific controllers / views / business logic etc. insist on hosting site themselves, , have functionality don't want others know about. following reading this post , this , i've created means mvc multi-tenancy, seems handle scenarios. as can't attach stack overflow, have posted here (no need read - it's screenshots!). the basis have generic project, referenced several client projects. client project can have similar structure generic , take precedence when wish use overriding code/controls/views. as it's foundation of whole thing, don’t want implement find else in easier/ better way. my question bit wooly, simple - there better way? your architecture seems right. have careful generic thing , how client's addons talk core application. i having base project in cvs client's specific branchs referencing (as in git submodule) can

javascript eval context not contains parameters in chrome -

i encountered strange error today. when invoked below function in chrome, got: var t = function(i){console.log(i);console.log(eval("i"));}; t("123"); //the result in chrome 123 undefined but above code invoked in firefox, came out thought: second log statement same first. in opinion,the eval statement use context of anonymous function runtime context, contains parameters. i didn't find material involve eval context , parameter. can tell me why ? actually,i used tempo.js render html , came out similar question listed above. the source code here: _replacevariables: function (renderer, _tempo, i, str) { return str.replace(this.varregex, function (match, variable, args) { try { ... if (variable === '.') { val = eval('i'); } else if (utils.typeof(i) === 'array') { val = eval('i

android - Align left edge to center - RelativeLayout -

Image
i have following requirement (drastically simplified): text 2 must start center of screen. i achieve using linearlayout's : <more_code></more_code><linearlayout android:baselinealigned="false" android:weightsum="2" android:layout_width="match_parent" android:layout_height="wrap_content"> <linearlayout android:layout_weight="1" android:orientation="horizontal" android:layout_width="0dp" android:layout_height="wrap_content"> <textview android:layout_width=&

Position in a string C# -

i need know how check character in first position in string on c# code. example , if first character character "&" or other. thanks. as can see answers, there many ways accomplish this. should careful avoid exceptions thrown if attempt call methods on string null or use indexers on string null or empty. if(!string.isnullorempty(input) && input[0] == '&') { // yes } or… if(input != null && input.startswith("&")) { // yes }

sql server - Count group by date zero result -

i have sql report: select count(id_reg) total, year(fechaingreso) ano, month(fechaingreso) mes, day(fechaingreso) dia vw_casos_tc fechaingreso between '2012-12-05' , '2013-5-8' group day(fechaingreso), month(fechaingreso), year(fechaingreso) order ano, mes, dia it works fine excepts days have no records when count(id_reg) = 0, days doesn't appear on result. total ano mes dia ----------------------------- 66 2012 12 13 22 2012 12 14 23 2012 12 17 there no result (2012 12 15 , 2012 12 16). how can modify script days total = 0 ? here way, assuming sql server 2008 (though can modify sql server 2005): declare @startdate date, @enddate date set @startdate = '20121205' set @enddate = '20130508'; alldays ( select @startdate yourdate union select dateadd(day,1,yourdate) alldays dateadd(day,1,yourdate) <= @enddate ) select a.yourdate,

Create a very large Sparse Matrix in R -

i trying create large sparse matrix, 10^5 10^5 in r, running memory issues. > matrix(nrow=1e5,ncol=1e5,sparse=true) error in matrix(nrow = 1e+05, ncol = 1e+05, sparse = true) : many elements specified it looks because number of elements larger 2^31, maximum integer value. running on 64 bit machine. > .machine$integer.max [1] 2147483647 is there way create such large, sparse matrix? it looks trick set data=0 rather data=na . > matrix(data=0,nrow=1e5,ncol=1e5,sparse=true)

uitableview - 3 Requests per object with AFIncrementalStore using NSFetchedResultsController -

i have setup afincrementalstore use parse backend service. using such service makes counting api requests important if exceed 1mm requests/month (though successful metric!) result in decent bills. wouldn't issue, i'm seeing, if put breakpoint @ following method in afhttpclient : - (void)enqueuehttprequestoperation:(afhttprequestoperation *)operation; i find requests particular object occurs 3 times, when need once. $1 = 0x0b9afe30 https://api.parse.com/1/classes/poem/cuptflj0j8 // ... $8 = 0x099e0a30 https://api.parse.com/1/classes/poem/cuptflj0j8 ... $18 = 0x0bb6d530 https://api.parse.com/1/classes/poem/cuptflj0j8 note different memory addresses come afhttprequestoperation , i'm printing request.url property examine objectid (the random string on end of url) each request. now i'm not familiar enough workings of nsincrementalstore or afincrementalstore figure out after 2 days of debugging , examination. i'd love hear thoughts around causing this

c - Looking for a working example of FFT convolution with Intel IPP -

just trying wrap head around ipp right now. have working c/c++ code doing fft convolution on image? example here : /* sample c-code snipet example 1 using intel® integrated performance primitives (intel® ipp): */ /* allocate , initialize specification structures */ ippsfftinitalloc_c_32fc(&fftspec1_p, order, ipp_fft_div_fwd_by_n, ippalghintfast); ippsfftgetbufsize_c_32fc(fftspec1, &bufsize); buf1_p = (ipp8u *) ippsmalloc_32sc(bufsize*sizeof(ipp8u)); // ... /* compute in-place ffts of input sequences*/ ippsfftfwd_ctoc_32fc_i(x_p, fftspec1_p, buf1_p); ippsfftfwd_ctoc_32fc_i(y_p, fftspec1_p, buf1_p); /* perform complex multiplication , inverse fft*/ ippsmul_32fc( x_p, y_p, o_p, veclength); ippsfftinv_ctoc_32fc_i(o_p,fftspec1_p, buf1_p); // ... /* free specification structures */ ippsfftfree_c_32fc( fftspec1_p); ippsfree(buf1_p);

windows - How to map path to correct casing of the underlying location for svn use -

say have path c:\my\multi\component\path . because casing ignored in windows mix , match casing please navigate same node in file system in powershell: 1ps> cd c:\my\multi\component\path 2ps> cd c:\my\multi\component\path 3ps> cd c:\my\multi\component\path 4ps> cd c:\my\multi\component\path the problem when use svn command line tools, example, svn log . . only works if set location line (1) above, i.e. using exact casing matching underlying path. if set location 2, 3, or 4, svn balks with, example: svn: svn: e155010: node 'c:\my\multi\component\path' not found. i understand fact svn case-sensitive while windows not causing issue, , can live that. want workaround, wit: way find underlying, cased-as-originally-created path in powershell. can send path through normalization filter before handing svn. unfortunately, powershell refuses yield true, underlying path me. have examined properties of get-location, get-item, , get-childitem. is there way true pat

python - Pandas Dataframe label selection -

can tell me why df['2005-5-31'] trigger keyerror exception? rng = pd.date_range('2005', '2012', freq='m') df = pd.dataframe(randn(len(rng), 3), rng, ['x', 'y', 'z']) df.head() # works df.ix['2005-5-31'] df['2005-5-31':'2005-5-31'] # gives keyerror: u'no item named 2005-5-31' df['2005-5-31'] follow code using df['2000-01-01'] works. #multiple rows on single date rng = pd.date_range('2000-01-01', '2000-01-3', freq='8h') df = pd.dataframe(randn(len(rng), 3), rng, ['x', 'y', 'z']) # works df['2000-01-01'] x y z 2000-01-01 00:00:00 -0.227981 1.927932 -0.518947 2000-01-01 08:00:00 0.486063 -1.255186 0.375075 2000-01-01 16:00:00 -2.313950 0.654384 1.111493 df['2005-5-31'] returns column named: 2005-5-31. columns named x,y,z. , because don't have date c

C Read colors from Bitmap -

im'm loading color of pixel , writes one-byte variable. when want read color (for red pixel) should result: 255 however, value is: 4294967296. follows value has been recorded in 32-byte variable. why happen? struct rgbpix{ char r; char g; char b; }typedef rgb; ... rgb **data=(rgb **)malloc(sizeof(rgb *)*picture.biwidth); for(i = 0; < picture.biwidth; i++){ data[i] = (rgb*) malloc(sizeof(rgb) *picture.biheight); } ... for(i=0;i<picture.biwidth;i++){ for(j=0;j<picture.biheight;j++){ fread(&data[i][j].r, 1, 1,bmpfile); fread(&data[i][j].g, 1, 1,bmpfile); fread(&data[i][j].b, 1, 1,bmpfile); } } printf("%ld", data[0][1].r); char appears signed type on machine. use unsigned char avoid sign extension.

sql - remove the gap between columns of result in oracle -

i have query gives me exact result. issue in result gives me lot of gap between 2 columns like col1 col2 col3 ---- ---- ---- when have checked length of individual columns length function showing 4 or 5 length . i have used windowing functions calculate columns , aliased them. my question why showing result such , how eliminate gap b/w columns in result? i using oracle10g the sqlplus colsep setting controls what's displayed between columns. try this: set colsep ' ' that's default. can set value want. if want control width of column in sqlplus, it's done through column setting, matches column name. format column col1 20 characters wide, regardless of column's value: column col1 format a20 note if col1 va

Python: get int value from a char string -

this 1 of silly questions , don't know how formulate it, i'll give example. got v = chr(0xae) + chr(0xae) where #aeae is, in decimal, value of 44718. my question how integer value of v ? know ord() can use char, , not string. thank you. i managed using struct module: import struct int_no = struct.unpack('>h', v)[0] print int_no which outputs desired results: 44718

sql server 2008 - Creating a hierarchy group from one table column contain both parent and child hierarchy info -

i need creating hierarchy group 'using' data in event_role column in sample table create grouping structure below. the 6 parent hierarchies 'speaker', 'coordinator', 'volunteer', 'instructor', 'attendee', 'registration' and child hierarchies (or lower levels) did not attend/yes attend attendee , not register/no reg/yes reg registration. i have 100000+ rows create these hierarchy groups , have more groups , child hierarchies. hierarchy groups speaker coordinator volunteer instructor attendee--- **child(lv2)**-- did not attend/yes attend registration--**child(lv2)**---do not register/no reg/yes reg i have create sample data in sql server thank in advance!! create table table1 ( participant_id int not null ,supporter_id int not null ,event_code varchar (50) ,event_role varchar (100) null ) insert table1 (participant_id,supporter_id,event_code,event_role) values ('234221','

statistics - How to MLE estimation of LogNormal data with right-censored failure times? -

so far examples have found "complete" failure data. in line of work, data includes failure times units , times units have not failed yet (right-censored). wondering if can point me reference material on how calculate lognormal parameters using mle method when data includes censored data. edit: should add in end, need newton-raphson equation numerically solve log-normal parameters or other numerical algorithm since there no closed-form solution obtain parameters directly.

command line - WinSCP time based file download -

i write winscp script download file placed onto remote server every morning between 4-4:30am. there way time-stamping? i want pseudocode: get file.txt timestap<1 hour 4 first, assume file not have fixed name (contrary question fixed name file.txt ). if not, please explain, why need timestamp-based solution. anyway, can use file mask time constraint : get "*.txt>2014-07-19 4:00" to dynamically inject today's date, use %timestamp% syntax : get "*.txt>%timestamp#yyyy-mm-ss% 4:00" simply, above means, files created later 4:00 today (the %timestamp#yyyy-mm-ss% resolves today's date in format yyyy-mm-ss , needed time constraint). when passing get on winscp command-line in batch file (using /command switch, opposite using /script switch specify separate script file), have double % avoid batch-file trying interpret %timestamp% : winscp.com /command ... "get ""*.txt>%%timestamp#yyyy-mm-ss%% 4:00"

c# 4.0 - following linq performing left outer join instead of inner join -

i cannot see problem lies following code. trying retrieve employees named responsibles vacancie. have 20 vacancies in db assigned 16 employees , 1801 employee records in employees table. code returns result 1801 entries. from emp in container.employees join p in container.vacancies on emp.empid equals p.responsibleofficer j group j new {k1=emp.empid,k2=emp.name} g select new { empid = g.key.k1, name = g.key.k2 , count = g.count()} i want similar this select emp.empid,emp.name,count(*) count vacancies p, employees e p.responsibleofficer=e.empid group e.empid,e.name any appreciated. thanks you're using join ... into . always return single result each element of original sequence, if there no matches in right sequence. you can filter out entries no elements in j using where clause: from emp in container.employees join p in container.vacancies on emp.empid equals p.responsibleofficer j j.any() group j new {k1=emp.empid,k2=emp.name} g select new { empid = g.k

c - typecasting in threads code -

https://computing.llnl.gov/tutorials/pthreads/samples/join.c i looking @ pthreads code @ link above. i not able understand type casting being done in code above variable t , status in busywork , main methods. from man pages pthread_exit: the value pointed retval should not located on calling thread's stack, since contents of stack undefined after thread terminates. so guess type casting in example trying avoid referring memory on stack of thread has terminated. find typecasting quite inconvenient , bizzare. can explain? when create thread pthread_create, argument limited sizeof(void *) , use pass pointer struct or other data may bigger size of argument. in example, argument long t have size smaller sizeof(void *) , can pass argument directly pthread_create() call. the explicit cast made ensure if there difference between memory allocated type (long) or type (void *), fixed compiler. in practice, cast nothing in platform, cannot guarantee that, must ex

ms dos - Bat file Disconnecting a network drive if it exists -

i need help. how can batch file written check see if network drive connected , if ask user y/n delete it? something along these lines... if exist n:\. goto network goto :eof :network set /p remove=remove network (y/n) if !%remove%!==!y! net use n: /delete

spring - How can I programatically add a beanPostProcessor to a ClassPathXmlApplicationContext? -

there's way programatically add beanpostprocessor classpathxmlapplicationcontext ? i can declaratively in xml, apparently there's no way add programatically. my processor must if bean myinterfaceaware, setmyinterface(...). i need in code cause myinterface implementation instantiated in code, it's not available when starting xml. i'm using spring 3.1.2.release. thanks, ... i'm doing ... public void setspringbeanfactory(beanfactory beanfactory) { this.beanfactory = (applicationcontext) beanfactory; ((classpathxmlapplicationcontext) beanfactory).getbeanfactory().addbeanpostprocessor(new beanpostprocessor() { public object postprocessbeforeinitialization(object bean, string beanname) throws beansexception { return bean; } public object postprocessafterinitialization(object bean, string beanname) throws beansexception { if (bean instanceof registryaware)

How to calculate button counts of a HTML page? -

i have html page, source code given below - <html> <script type="text/javascript"> function jsmeth() { alert('count of buttons : '+document.getelementsbytagname('button').length); } </script> <input type="button" value="button 1" id="btn1" name="btn1" /><br> <input type="button" value="butto 2" id="btn2" name="btn2" /><br><br> <input type="button" value="calculate button count" id="btn3" name="btn3" onclick="jsmeth();"/> </html> my basic purpose is, when click on button having id "btn3", should display number of buttons in html page (in case 3). somehow showing 0. thanks quick reply. of suggested, have modified code shown below - <html> <script type="text/javascript"> function jsmeth() { alert('count of butto

php - MySQL Error Message on first load -

i uploaded site linked mysql database (its first time) when open page pulls info database comes error (it goes away when refresh) warning: mysql_pconnect() [function.mysql-pconnect]: mysql server has gone away in d:\hosting\2941136\html\test_sites\solera2013\connections\soleramenusystem.php on line 9 can tell me why error pops first time page loads , goes away after refresh thanks dan here site: http://graves-incorporated.com/test_sites/solera2013/menu_dinner.php read mysql reference error message: https://dev.mysql.com/doc/refman/5.0/en/gone-away.html

android - No Activity found to handle intent error -

i trying view file word .txt file using android follows: intent intent = new intent(intent.action_view); intent.setflags(intent.flag_activity_new_task); intent.setdataandtype(uri.parse("file:///android_asset/usage.txt"), "plain/text"); getapplicationcontext().startactivity(intent); and intent intent = new intent(intent.action_view); intent.setflags(intent.flag_activity_new_task); intent.setdataandtype(uri.parse("file:///android_asset/usage_instructions_for_smart_responder.doc"), "plain/text"); getapplicationcontext().startactivity(intent); inside method of activity. now, have es file manager installed on device. keep on getting error: 05-09 01:24:53.516: w/system.err(28918): android.content.activitynotfoundexception: no activity found handle intent { act=android.intent.action.view dat=file:///android_asset/usage_instructions_for_smart_responder.doc typ=plain/text flg=0x10000000 } 05-09 01:24:53.516: w/system.err(28918): @ android

r - Behavior of subsetting data frame for unique column values -

background: have data frame 1 column having duplicate values. trying split data frame picking out rows duplicate column values, process them , spit out new data frame processed rows. i amazed going wrong here in following code: dataset <- structure(list(day = structure(1:10, .label = c("tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday", "tuesday"), class = "factor"), variable = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l), .label = c("act1", "act2", "

spring - management using MB @ViewScoped -

//exemple01 @managedbean(name = "mb") @viewscoped public class exemplemb implements serializable { @managedproperty(value = "#{servicebo}") private servicebo servicebo; @postconstruct public void init{ list= servicebo.list(); } public void query(){ servicebo.query(parameters); } } exemple 01: returns me error javax.faces.facesexception: java.io.notserializableexception: being can not serialized because , managed spring. //exemple02 @managedbean(name = "mb") @viewscoped public class exemplemb implements serializable { @managedproperty(value = "#{servicebo}") private transient servicobo servicebo; @postconstruct public void init{ list= servicebo.list(); } public void query(){ servicobo.query(paramestros); } } exemple 02: makes query init, method null search service, has marked transient this, how can solve problem. spring services not serializable. instead inject fully serializable proxies , @viewscoped bea

sql - Combine two queries to check for duplicates in MySQL? -

i have table looks this: number | name --------+-------- 123 | robert this want do: if number in database, don't insert new record. if number not in databse, name is, create new name , insert it. example, if have record contains 123 number , bob name , don't want insert it, if record contains 456 number , robert name , insert 456 , robert1 . going check duplicates individually like: select * person number = 123; //if number not found select * person name = 'robert'; //if name found, add number it. is there way can combine 2 statements? there 2 problems in question. first problem make number column unique , second 1 increment column name appending number if exists. first part since number unique , enforce unique constraint on column. primary key or unique key . if column has no key , want make primary , here alter statement: alter table tablename add constraint tb_pk primary key (number) sqlfiddle demo but if

show a smarty variable with html content -

i have smarty variable html content in like: $html="<strong>content</strong><br/>etc etc" . try show html-formatted. when showing {$html} plain text appears without formatting. try like: {$html|unescape} tags shown not applied. have suggestions? you should try this: {$html|unescape:'html'} also check manual: http://www.smarty.net/docs/en/language.modifier.unescape.tpl