Posts

Showing posts from January, 2012

google spreadsheet - Remove characters from a string after a certain word - excel -

Image
ive got list of imported data formatted following in excel / google spreadsheet. in column have full data , in b im trying strip out data left of word on . full data | stripped data nnk gov on 31 aug cde | nnk gov giffgaff.com on 30 aug cde | giffgaff.com tmrco stores on 12 aug cde | tmrco stores i using following forumal, falls down there non uniform white space there on last entry. =left(a1, len(a1)-14) is there more robust way can write this, dosnt fall on when there non uniform whitespace or additional wording after "cde" ? ive created shared google spreadsheet here scratch pad : https://docs.google.com/spreadsheets/d/1iier_hak8qjpy8w6qq7ww9-640o-hzmflnnjecps6m4/edit#gid=0 im using google spreadsheets, although ive marked question excel ive found there many shared functions. in excel: =trim(left(a1,find(" on",a1))) this work in google sheets there may easier way in google

python - Django view - exclude in queryset? -

i have problem: after creating new world, (all countries automatically assigned every new world) user choose 1 country showed on top of site , can't delete country. how this? class country(models.model): name = models.charfield(verbose_name="name of country", max_length=100, default="australia") number = models.integerfield(verbose_name="number of country", default="1") def __unicode__(self): return self.name class world(models.model): country = models.manytomanyfield(country) name = models.charfield(verbose_name="new map", max_length=100) def __unicode__(self): return self.name now have this: after creating world user redirecting new_my_world, there should choose country , redirected site my_world view can delete countires expect one. how this? views.py def new_my_world(request, pk): world = get_object_or_404(world, pk=pk) return render(request, 'game/new_my_world.htm

python - Change Pandas index datatype on MultiIndex -

i have pandas dataframe 2 indexes column1 indexa indexb 1001 aaa 1 bbb 1 ccc 1 ddd 1 created by pd.read_sql(sql=sql, index_col=['indexa', 'indexb']) mysql reading in indexb unicode , convert string. goal pivot table , have entries in indexb column names. when unicode values following column names: � � � � � � � � � when running pd.read_sql(sql=sql, index_col=['indexa', 'indexb']).unstack().fillna(0) edit: comment suggested following: df = pd.read_sql(sql) df['indexb'] = df['indexb'].astype(str) df = df.set_index(('indexa', 'indexb'), drop=true) which nice work around problem (thank you). still nice know if can done during initialization.

java - SQL Password Decrypt -

i having trouble finding out how decrypt sql passwords. many questions similar, none same. sql syntax: insert `a2166327_db`.`users` ( `id` , `username` , `password` , `bio` ) values ( '2', 'waffles', password( 'waffles' ) , 'waffles' ); i entry: |2|waffles|*a734e3e66d51b5043a297ec66ee24d3bc26ae328|waffles| how decrypt *a734e3e66d51b5043a297ec66ee24d3bc26ae328 "waffles?" can in java? this example: hash('admin') return 'd033e22ae348aeb5660fc2140aec35850c4da997' but can't decrypt result !!! why encryption existing, secure data. hash functions yoused in 1 way but can compare data in backend programming. if(hash('admin') == 'sql_password'){...} and example of java hash class. java hash class encrypt secret password

mysql - Navicat add fields to existing table -

using navicat application. have set of additional data want add , existing mysql table. new data has column key existing table, plus 35 additional fields of data. how can navicat used add in these new fields of data via interface? import tools don't see add new fields. run alter table table_name add column_name column_characteristics; described @ following url in navicat query window. http://www.tech-recipes.com/rx/378/add-a-column-to-an-existing-mysql-table/ make sure add ";" @ end of each line. this allow add multiple columns/fields @ once, easier adding them one-by-one navicat's design table tool. once columns/fields in import usual

php - MySQL join on data from two tables -

i trying make mysql query joins multiple tables have problems 1 join part. here query: select cs.survey_id, csq.question_id, csq.text question_text, cso.option_id, cso.text option_text, cstr.text text_question_result, count(csr.option_id) votes customer_survey cs inner join customer_survey_questions csq on cs.survey_id=csq.survey_id inner join customer_survey_options cso on cso.question_id=csq.question_id inner join customer_survey_results csr on cso.option_id=csr.option_id inner join customer_survey_text_results cstr on csq.question_id=cstr.question_id inner join customers c on c.customer_id= ??? cs.survey_id='$this->survey_id' group csr.option_id order csq.ord, cso.ord the problem this: the last join supposed join previous tables "customers" table on field customer_id. problem there 2 tables may include records in field - "customer_survey_results" table, , "customer_survey_text_results" table.

r - Compiling ipopt for ipoptr on Mac -

how compile ipopt on mac os x natively tuned accelerate blas/lapack in order able use r ipoptr ? there several configure options need specified: option enable necessary dynamic loading r add: --with-pic in order enable native blas/lapack add both: --with-blas="-framework accelerate" --with-lapack="" resulting configure command: ../configure --disable-shared \ f77=gfortran fflags="-fexceptions -m64 -fbackslash" \ cflags="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64" \ cxxflags="-fno-common -no-cpp-precomp -fexceptions -arch x86_64 -m64" \ --with-blas="-framework accelerate" --with-lapack="" --with-pic

winapi - How to set focus correctly when deal with wm_nclbuttondown? -

Image
i want create window dismiss when lose focus in wm_nclbuttondown handler, firefox's menu button window does. didn't manage it. new window lose focus after creation. so digged spy++ , found wm_nclbuttondown cause main window focused, here messages logged spy++: in 0xb13f2 main window's hwnd, , 0x46139a new window hwnd. then how set focus correctly? i tried lot methods: pre-translate wm_nclbuttdown wm_lbuttondown. nchittest window area htclient , try handle move , resize manually, modification huge continue. in wm_nclbuttondown handler, sendmessage wm_lbuttondown. call setfocus lot. ... some works, bring other problems. used spy++ log messages of firefox, , found make nchittest return htclient in area need handle left button down message.

javascript - Is there a way to get key name from keyCode/which for certain language programmatically? -

so, here's case: i have search field on html page (app), gives suggestions user types a user can type stuff there in either language x or english (s)he can forget language layout (s)he has , start typing in wrong layout what i'd achieve: on input, make same change in field in couple of variables, in 1 in english, in – in language x make suggestions based on 2 variables, not field content, if user has confused language layout, (s)he adequate suggestion anyway now, question is: possible convert e.which or e.keycode programmaticaly standart layout letter language without listing stuff like var keysmap = { .., keycode: { englishletter: .., languagexletter: .. } , .. } (in other words, browsers know letter should keycode / which correspond to? or jquery?) i imply 2 cases: language x known (say, can hardcode it) language x unknown, can extracted browser reduce case 1? ps in sense, i'd implement analogue of puntoswitcher/keyboardninja/.. on

android - how to uninstall MinGW and make cygwin 'make' as deafult make program with gcc 3.8.1 -

okay let me go straight thing : q.1 ) how uninstall mingw? i have installed software dont use software @ , need remove mingw in order use cygwin android devlopement. i need answer in human terms mingw site has confused me lot q.2 ) how set cygwin 'make' file deafult gcc 3.8.1 ? note : on windows 7 64-bit answer 1: if have used installer, uninstall through program manager remove mingw folder (eg. c:/mingw ) make sure there's no mingw path left in path environment variable if haven't used installer, can skip 1. , if have, should check 2. , 3. manually. answer 2: do use ide? if yes can specify make / gcc there. can set absolute path correct program too.

function - Read.table error in R -

i'm using r read text file , subsequently manipulate it. input file has 22 columns. first column looks : name length c d e f g h k l m n p q r s t v w y i using: read.table("filename", stringsasfactors=false) to input file. when run same, warning: error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 2 did not have 23 elements not sure going wrong. i'm new r , appreciate help. i've tried make sure isn't repost, if is, please link me original. assuming text file looks this: name length c d e f g h k l m n p q r s t v w y ape:ape_0001 242 15 0 1 12 10 18 2 27 9 43 7 2 8 3 5 25 15 24 3 12 ape:ape_0002 113 7 1 6 6 1 12 3 4 10 16 4 2 4 0 10 3 5 9 4 5 ape:ape_0004 305 24 2 5 8 9 25 4 36 12 43 8 11 14 2 12 20 21 27 9 12 and called 'dat.txt' , stored in working directory, should work: dat <- read.table("dat.txt", stringsasfactors=false, he

Excel matching and comparing -

Image
so seems bit perplexing me being i'm new excel. i have one-to-many relationship sku , part#. i want see if each parts' price equal each other, if share same sku #. and, if not same price, return result of essentially, "different price". sku# part# price 1000-002-581 56465 12800 1000-002-581 800335 13300 1000-002-582 56455 12800 1000-002-582 800325 13300 1000-002-584 56445 12800 1000-002-584 800315 13300 above results have. i.e. sku 1000-002-581 has part #: 56465 , 800335 . , price each part different (12800 vs 13300) . want retrieve message because different. at end of day, want display lines part price differences each associated sku. any thoughts on collective functions work? add column table formula =if(sumif(a:a,a2,c:c)/countif(a:a,a2)<>c2,"different","") turn on autofilter , filter last column.

html - Twitter Bootstrap: Can't get navbar centered -

i searched around , used solutions worked others - unfortunately not me. <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <ul class="nav"> <li class="active"><a href="#">menu</a></li> </ul> </div><!-- container --> </div><!-- navbar-inner --> </div><!-- navbar navbar-fixed-top --> css things i've added .navbar .nav, .navbar .nav > li { float:none; display:inline-block; *display:inline; /* ie7 fix */ *zoom:1; /* haslayout ie7 trigger */ vertical-align: top; } .navbar-inner { text-align:center; } have tried - .navbar { margin: 0 auto; width: 200px; }

dns - Users outside domain administrators group lost access to outlook and shared folders -

at point on weekend users lost access outlook (they unable sync) , shared folders. users kept workstations logged in during time still had access both outlook , shared folders. if added "domain administrators" group, users have access both outlook , shared folders. not solution, in short term, symptom of problem. i don't think deliberately changed setting in server. believe wrong setting somewhere. have windows 2003 sbs exchange server, domain controller , primary dns. we've been having issues dns servers. need add shared folder ip. other times added name.domain.local , , name. although think current problem not related, mention context. after lot of research found issue cal´s, licenses somehow reset default values , preventing users accessing outlook , share folders. after stopping "license logging" service, using info contained in autolicstr.cpa , passing licstr.cpa, restarting service...the licences restored , had access again.

synchronous - sending requests for images synchronously with jquery -

i having page feed youtube , display on page. there 3 rows each of 4 images each corresponding youtube videos. these image links youtube feed itself. what want achieve while rendering these images, want fetch image youtube 1 row @ time. if images load not completed, want wait until next row images fetched. can guide me how can de done? read stuff jquery deferred objects , callbacks, since not strong on jquery/js not able crack one. js executes asynchronously , therefore image requests go 1 after , not able make js wait until images each row rendered before next row sent. i have loop , diaply images follows: $j("#thumbnail_image_"+i).css({'background-image':'url('+cdnpath+')'}); myimage[i].src = cdnpath; basically, if use proper img element store image, can subscribe onload , onerror events. can count how many of images loaded var loaded = 0; (var = 0; < imgtags.length; i++) { imgtags[i].src = "/path/to/img"; f

i want to merge multiple csv files by specific condition using perl -

i have multiple csv files, want merge files..... showing of sample csv files below... m1dl1_interpro_sum.csv ipr017690,outer membrane, omp85 target,821 ipr014729,rossmann,327 ipr013785,aldolase,304 ipr015421,pyridoxal,224 ipr003594,atpase,179 ipr000531,tonb receptor,150 ipr018248,ef-hand,10 m1dl2_interpro_sum.csv ipr017690,outer membrane, omp85 target,728 ipr013785,aldolase,300 ipr014729,rossmann,261 ipr015421,pyridoxal,189 ipr011991,winged,113 ipr000873,amp-dependent synthetase/ligase,111 m1dl3_interpro_sum.csv ipr017690,outer membrane,905 ipr013785,aldolase,367 ipr014729,rossmann,338 ipr015421,pyridoxal,271 ipr003594,atpase,158 ipr018248,ef-hand,3 now merge these files have tried following code @argv = <merge_csvfiles/*.csv>; print @argv[0],"\n"; open(page,">outfile.csv") || die"can't open outfile.csv\n"; while($i<scalar(@argv)) { open(file,@argv[$i]) || die"can't open ...@argv[$i]...\n"; $data.=join(&quo

Memory Leak on Android Wear with fragments and ViewPager -

Image
i have app has 1 main activity. activity holds reference fragmentmanager, , fragments use in app. once main activity loads, displays "navigation fragment", fragment holds viewpager uses fragments display menu items (done using fragmentpageradapter). when select menu item (by clicking it, or using gesture) current navigation fragment replaced menu item fragment using: public void replacefragment(fragment frag, string fragtag) { fragment currentfrag = mfragmentmanager.findfragmentbyid(r.id.fragmentcontainer); mfragmentmanager.begintransaction() .remove(currentfrag) .add(r.id.fragmentcontainer, frag, fragtag) .addtobackstack(null) .commit(); } when return menu item fragment navigation fragment, using: fragmentmanager.popbackstackimmediate(); i getting big jumps in allocated memory. after selecting menu item , returning navigation fragment 8-10 times or so, memory begins fill , sensorlisteners stop working can&#

android - How to write files to a usb memory? (root) -

tablet usb plug in memory stick , access try { runtime.getruntime().exec("su"); } catch (ioexception e) { e.printstacktrace(); } file testfile = new file("mnt/usbhost0"); boolean b1 = testfile.canread(); //b1 = true boolean b2 = testfile.canwrite(); //b2 = false why b2 false? my device rooted ps. sorry english bad.. you need set app's persmissions in manifest write storage <uses-permission android:name="android.permission.write_external_storage" />

jquery - JavaScript not recognizing array declaration -

i'm trying check user input against predefined array of values ensure user entered valid input. to this, i'm using jquery's $.inarray() function. takes 2 arguments: value checked, , array check with. returns index of value in array if found, , -1 if not. however, when use $.inarray() function, not seem recognize genrearray array (see code below). while doesn't show here, genrearray variable not have proper syntax highlighting in function call. in addition, seems if if check gets carried out, nothing (not error) shows on console. the if statement syntax working fine - replace code if (1 === 1) , code carried out fine. in addition, placement of variable declaration not seem matter either. i've put before/after every important point in code, no difference in results. i've ruled out problems genre variable. thanks lot help. $(document).ready(function() { var genrearray = [...]; $('.menu').click(function() { var genre = $(

amazon web services - How to override the env variables and use the AWS credential file instead in AWS CLI? -

when using aws cli, there way can specify use credential file instead of values stored in env variables? $ aws ec2 describe-instances --profile saml saml profile name inside credentials file stored in ~/.aws/credentials. want aws cli use credential file default , not use ones stored in env variable. how can this? unfortunately, can't specify priority credential file on environment variables. http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment environment variables override configuration , credential files , can useful scripting or temporarily setting named profile default. building mentioned in answer, write wrapper script would: overwrite environment variables export command (which think temporary within scope of script only) pass through command aws cli once completed, wrapper script terminate , environment variables should go way (i think) i tested out below (very basic) bash script. have environment

cakephp - URL rewriting in Cake -

i need rewrite url in cake application in such way slug (e.g. title) shown in url. example, if have cake url www.site.com/users/view/1 (controller/action/id), need show /vikram.sinha if user's nick vikram.sinha (no id, no action, no controller or else in url). i making sure title (slug) unique before storing , best following. www.site.com/profile/vikram.sinha adding route below. router::connect('/profile/:slug', array('controller' => 'users', 'action' => 'view'), array( 'pass' => array('slug'), )); the problem facing need remove profile url. couldn't find way rewrite url in cake without adding before slug. or may url can rewritten using htaccess directly not either. if suggesting using htaccess please assume url need changed www.site.com/users/view/vikram.sinha thanks! your best bet imo reddit each slug prefixed /r/. example: mysite.com/u/johnsmith then, i

python - Is it possible to modify a df from pandas function read_html before pasting into a csv file? -

i able pull df reading html function in pandas reason not able modify columns if select table want since pulling tables reference 1 want.but when comes changing name of columns or specific piece of data printing column, can't figure out. out there know's how deal this. here example: import pandas pd url= 'http://www.espnfc.com/barclays-premier-league/23/table' df = pd.read_html(url) print(df) print(df[0].home) '✔ works print(df[0][unnamed: 17]) 'throw's me error df.rename(columns = {'away':'awayy2'}, inplace = true) 'throw's me error df[0]['unnamed: 17'] df[0].rename(columns = {'away':'awayy2'}, inplace = true) above works me. (apostrophe & [0] missed)

vb.net - WPF MediaElement opacity does not fade in gradually after changing source -

i have wpf digital signage application displays slideshow of images and/or videos. i'm using single mediaelement object , transition handled storyboard animations of opacity property. the image fades out smoothly, fade in doesn't. opacity appears stay @ 0 length of animation duration, , go 1 in 1 go. private function getfadeinstory() storyboard dim story new storyboard dim fadeinanimation new doubleanimation { .begintime = new timespan(0), .from = 0, .to = 1, .duration = timespan.frommilliseconds(my.settings.fadeinduration)} storyboard.settargetproperty(fadeinanimation, new propertypath(uielement.opacityproperty)) story.children.add(fadeinanimation) return story end function private function getfadeoutstory() storyboard dim story new storyboard dim fadeoutanimation new doubleanimation { .begintime = new timespan(0), .to = 0, .from = 1, .duration = timespan.frommilliseconds(my.s

javascript - Unable to run a Screen share chrome app using electron -

i ran github app under chrome extenstion. when run using electron socket connection error in connection establishment: net::err_connection_refused below package.json file. tried "chromium-args": "--allow-running-insecure-content --ignore-certificate-errors", did not help. there specific changes need make in package.json. trying learn let me know if information missing? { "name": "electron-app", "version": "1.0.0", "description": "", "main": "main.js", "icons": { "16": "icon.png", "128": "icon.png" }, "app": { "background": { "scripts": ["background.js"] } }, "sockets": { "udp": { "bind": "*", "send": "*" } }, "permissions": [ "system.networ

How to correctly setup the Facebook OpenGraph API story with map attachment? -

i'm trying setup custom story website/facebook app provide users "i've been here" , "i want visit place" functionality according documentation: https://developers.facebook.com/docs/opengraph/creating-custom-stories/ everything working great except "stories" app appears on timeline normal item layout photo , description when want show item on map. example url og data: http://en.advisor.travel/poi/16828 : <meta property="place:location:latitude" content="36.25500"/> <meta property="place:location:longitude" content="-112.69770"/> <meta property="og:image" content="http://img1.advisor.travel/657x340px-bd308129ce37a06485dfe9ac47bee982.jpg"/> <meta property="og:title" content="havasu falls"/> <meta property="og:url" content="http://en.advisor.travel/poi/16828"/> <meta property="og:type" content="wo

osx - Annoying terminal bug, is this known and a solution is out there? -

i use default terminal.app use cmd+d command split panes can @ part of code while using command. this annoying bug comes when de-splitting panes. reduces vertical length of terminal, after de-split, terminal not filling screen vertically. is there solution this? any true solution going have depend on bug fix. works me: set window default size in preferences/profiles/window. assign shortcut key window/return default size.

c# - Linq Enumeration Error -

i getting users posted form data, might empty. var users = request.form.getvalues("users[]") == null ? null : request.form.getvalues("users[]").toarray(); so, users becomes null if empty. but, following linq query not work. var submissions = db.quicksearchviews.where(x => (users != null && users.contains(x.userid))) .tolist(); error: additional information: unable create null constant value of type 'system.string[]'. entity types, enumeration types or primitive types supported in context. i going assume entity framework based on error message. reason why query throws error message (you didn't post full error & stack trace, it's notsupportedexception ) twofold users not entity within context db (database mapping) , checking if null cannot translated sql statement. users.contains(x.userid) cannot translated sql statement because users not part of database. y

Suitability/Performance of SQLite for large time-series data -

i've got time-series data i'd store in database of format: group : string date : date val1 : number val2 : number ... valn this database reads. searches rows belong group within date range (e.g. group = xxx , date >= start , date <= end). the data-set big. hundreds of millions of rows. sqlite able handle kind of data? appealing thing sqlite is serverless , i'd use if can. updated answer i tried putting 100 million record database on ram disk - don't mean in-memory database, mean ram formatted filesystem database on , same query takes 11 seconds rather 147 seconds below!!! may option if, say, queries largely read-only - copy database disk ramdrive in mornings , access nice , fast on ramdrive day, or until reboot, without worrying losing if power goes or machine crashes. run writes against disk-based copy , reflect changes next time copied database ram whenever wanted to. original answer i created 3 test databases modelled on needs

string - android bluetooth chat force closes when trying to run it as service -

i'm using bluetooth chat sample in android sdk send , recieve strings in many activites rather main activity modifying service,but when application force closes. want work sending , recieving string functions after connecting device in main activity. note: i'm using bluetooth chat sample of sdk 7 has default classes: bluetoothchat,bluetoothchatservice,devicelistactivity service code: class myapp extends application { private bluetoothchatservice mbluetoothconnectedthread; @override public void oncreate() { super.oncreate(); } public bluetoothchatservice getbluetoothconnectedthread() { return mbluetoothconnectedthread; } public void setbluetoothconnectedthread(bluetoothchatservice mbluetoothconnectedthread) { this.mbluetoothconnectedthread = mbluetoothconnectedthread; } } and that's activty i'm trying send string in it: public class newtest extends activity { private bluetoothchatservice mybluetoothconnectedthread; @override public void oncreat

android - Can't check if file on sdcard exists -

i'm trying make simple check if file exist. saw similar questions here, didn't help. when run application, app crashes , got message "unfortunatelly, filecheck1 has stopped". got error both on emulator , smartphone. my code: package com.example.filecheck1; import android.app.activity; import android.os.bundle; import android.os.environment; import android.widget.textview; import java.io.file; public class myactivity extends activity { textview msgtext; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msgtext = (textview) findviewbyid(r.id.textview); string path = environment.getexternalstoragedirectory().getpath()+"/ping.xml"; file file = getbasecontext().getfilestreampath(path); if(file.exists()){ msgtext.settext("found"); } if(!file.exists()){ msgtext.settext

ruby on rails - Unable to use current_user.id in faye extention -

hi using devise , faye. , want track online users. thought of including faye extension. in faye/faye_current_user.rb . when using current_user.id in faye_current_user.rb throwing undefined variable error. if have anyother easy way fetch online users please me out. thank you the problem "current_user" method devise isn't being called before method inside of faye_current_user.rb. a working solution dependent upon file located , how set current_user before calling methods within file.

iphone - What distribution options are there for internal iOS applications? -

i going working on project involves inventory scanning system @ video production company, , want able sign in / sign out inventory using iphone or ipad, require native app. since app on 1 or 2 different devices, , internal use, necessary go through app store distribute it? can permanently distributed devices other means? you either want adhoc build (which allows build 100 - 200 devices), or want company an enterprise account , allows distribute within company internally.

Python Get N max values from dictionary -

this question has answer here: 5 maximum values in python dictionary 4 answers top values dictionary 4 answers assume have dictionary: items = {'a': 7, 'b': 12, 'c': 9, 'd': 0, 'e': 24, 'f': 10, 'g': 24} i want dictionary, containing 4 elements maximum values. e.g. expect get: subitems = {'e': 24, 'g': 24, 'b': 12, 'f': 10} what pythonic , efficient (memory consumption, execution speed - when f.e. i'll have dict 1000000 elements) way this? generators, lambdas, another? heapq.nlargest correct answer when question "how small number of maximum values huge set of inputs?" minimizes memory usage , cpu usage better else in python using heaps. example: import heapq

symfony - Symfony2 Doctrine2 trouble with optional one to one relation -

i have problem doctrine2 in symfony2 , 2 relationed entities. there user-entity can (not must) have usermeta-entity referenced contains information biography etc. the usermeta optional because user imported system, while usermeta managed in application. of course want save both together, saving user must create or update usermeta-entity. both joined column named aduserid (same name in both tables). i've recognized if usermeta optional reference owning-side in case should usermeta, otherwise doctrine loads user , needs usermeta entity - it's not there. please note comments in user->setmeta.. /** * user * * @orm\table(name="user") * @orm\entity */ class user { /** * @var usermeta * @orm\onetoone(targetentity="usermeta", mappedby="user", cascade={"persist"}) */ protected $meta; public function getmeta() { return $this->meta; } /** * * @param usermeta $metavalue */ public function setmeta($metavalue

c++ - I have a segmentation fault and cannot seem to find it -

when run segmentation fault i'm not sure is. in c++. appreciated, in advance template<typename t> void my_vec<t>::insert_at_rank(int r, const t& elem){ int init_size = size; if(r < 0){ cerr << "out of range"<<endl; exit(exit_failure); } else if (r <= size) { ++size; } else size = r+1; if (size > capacity) { t* new_ptr = new t[capacity*2]; (int = 0; < capacity; i++) { new_ptr[i] = ptr[i]; } capacity = 2 * capacity; delete[] ptr; ptr = new_ptr; free(new_ptr); } for(int = size-1; > r; i--){ ptr[i] = ptr[i-1]; } (int = init_size; < r; i++) { ptr[i] = '0'; } ptr[r] = elem; } t* new_ptr = new t[capacity*2]; // allocates new array //...

c - At Least One bit in int num is 0 -

trying create method returns 1 if input int num has 0 in using c without using if-else statements , using bottom bitwise , boolean operators. i tried far: int hasazero(int num){ return !(num && 1); } bitwise , (c = & b) – c has 1s in places both of corresponding bits in , b 1. bitwise or (c = | b) – c has 1s wherever @ least 1 of corresponding bits in , b 1. bitwise xor (c = ^ b) – c has 1s wherever 1 , 1 of corresponding bits in , b 1. bitwise not (c = ~a) – c a, each bit inverted, else c 0. right shift (c = >> b) – c a, each bit moved lower b places. left shift (c = << b) – c a, each bit moved higher b places. boolean , (c = && b) – c 1 if both , b non-zero. boolean or (c = || b) – c 1 if either , b non-zero. boolean not (c = !a) – c 1 if 0. try this: int hasazero(int num) { return ~num != 0; } if num contains 0 bit, bitwise complement contain 1 bit , non-zero. if not contain 0 bit, complement zero. if don't want

javascript - Indicator format with RectangularRangeIndicator using dojo toolkit -

Image
i'm trying use verticallineargauge rectangularrangeindicator obtain triangular format(red , green color ) image below. result large line, used 2 attributes endthickness , startthickness no result. help please.

How to navigate to new page in nw.js -

this simple question can't life of me find answer online. i'm using nw.js , specify main html file in package file. however, how can navigate in same main window different html page? window object doesn't seem have way this. has open() function opens new window isn't want. i pretty new nw.js, have found 1 solution. believe reason window object not work because of javascript context. nw.js has node context , webkit context. (more can read here: https://github.com/nwjs/nw.js/wiki/differences-of-javascript-contexts ). however, solved similar problem making separate js file setting button change page. index.js: document.getelementbyid("button").onclick = function(){ window.location.href = './otherpage.html'; } make sure require method not used in same js file change context. then load html file. index.html: <script src="./path_to/index.js"></script> hope helps. feel free ask questions or elaboration. tr

java - Playframework 2.2: IllegalStateException: No value when invoking bindFromRequest -

in playframework 2.2.x, got error when trying binding form data pojo. illegalstateexception: no value and here sample code: form<orderrequest> form = new form<orderrequest>(orderrequest.class); final orderrequest orderrequest = form.bindfromrequest().get(); this article meant leave trail people suffer similar problem. i answer myself later. i wonder caused problem decided find out parameter might trigger problem. here structure of orderrequest: public class orderrequest { private int num; private boolean isadmin; private string name; .... } i able narrow down 2 parameters, turned out when input parameter [num] null, doesn't recognize null type int , parameter [isadmin] type boolean , for these primitive data type, not nullable type. to avoid situation, suggest checks type of each parameter, making sure setting value matches type. as mentioned, primitive data type not nullable type. one thing replacing primitive data type w

makefile with multiple jobs -j and subdirectories -

imagine have make file subdirectories built using "make -c". image have 4 target directories. 3 out of 4 done, 1 needs run. run overall makefile with: make -j 4 is there way tell makefile system run remaining target make -c -j 4 instead of 1 ? if 2 targets missing make -c -j 2 each one. i'll expand on beta's (correct) answer. individual make processes communicate each other , guarantee there never more n jobs running across different make invocations, when use -jn . @ same time, guarantee (assuming there @ least n jobs can possibly run across make invocations), n jobs running. suppose instead had 4 directories "something do", somehow know priori, , instead of invoking 1 instance of make -j4 , letting make invoke 4 submakes normally, force each of submakes invoked -j1 . suppose first directory had 10 targets out of date, second had 5, third had 20, , fourth had 100 out of date targets. @ first have 4 jobs running in parallel. once se

expandablelistview - Android expandable listview child divider -

Image
i have expandable listview child view, when ever click on group view expand , display child view, have hide divider between parent , child expanded group make visible when collapse, using default divider, how can this.? here perfect solution. to hide child divider set color transparent #00000000 define transparent in color.xml file <color name="transparent">#00000000</color> and set child divider listview.setchilddivider(getresources().getdrawable(r.color.transparent)) or in layout xml file <expandablelistview android:layout_width="fill_parent" android:layout_height="fill_parent" android:childdivider="#00000000"/> here output : for more detail visit here. android: hide child dividers in expandablelistview

javascript - JQuery mouseenter() and mouseleave() -

so have got demo navigation, has small button on side , when hover button, slides menu window. though have got hover working, when mouse leaves, it's still open. how fix this? i'm pretty new jquery way here's html: <div id="demonav"> <button class="open"></button> <ul> <li><a href="index.html">home pagina</a></li> <li><a href="product.html">product pagina</a></li> <li><a href="bestel.html">bestel pagina</a></li> </ul> </div> and jquery: $("#demonav").mouseenter(function(){ $("#demonav").animate({marginleft:'0px'}, 500) }); if need more info, tell me, i'll provide more codes. try this: $("#demonav").hover( function () { $(this).animate({ marginleft: '0px' }, 500) }, function () { $(

java - How to download images from url? -

i want download image reome url , ssl error string imgurl="http://whootin.s3.amazonaws.com/uploads/upload/0/0/23/82/note_03_26_2013_01_10_55_68.jpg?awsaccesskeyid=akiajf5qhw2p5zlagvdq&signature=za4yg0yks4%2fgoxsidfszaaa8vwq%3d&expires=1364888750"; final imageview ivcurrent; ivcurrent = (imageview)findviewbyid(r.id.imageview1); // calling downloadandreadimage class load , save image in sd card downloadandreadimage dimage= new downloadandreadimage(imgurl,1); ivcurrent.setimagebitmap(dimage.getbitmapimage()); the error: javax.net.ssl.sslexception: read error: ssl=0x19a4a0: i/o error during system call, connection reset peer your question make no sense because know nothing downloadandreadimage class, way think need add these 2 permissions in manifest: <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> p.

how to download zip folder in ruby on rails? -

i have download zip file in tmp folder have downloaded zip file not downloaded zip file. code type=> => download folder def download_folder @patient_id = params[:patient_id] @photovideos = photovideo.where('patient_id = ?', user.encrypt(@patient_id)) @time_filename = time.now.strftime("%y%m%d%h%m%s").to_s << ".zip" tmp_filename = "#{rails.root}/tmp/"+ @time_filename zip::file.open(tmp_filename, zip::file::create) |z| @photovideos.each |photovideo| item = user.decrypt(photovideo[:patient_file]) file = "#{rails.root}/public/patients/#{@patient_id}/"+ item if file.exists?(file) t = file.open(file) z.add(item, t) end end end file.chmod(0777, tmp_filename) send_file tmp_filename, :type=>"application/zip", :x_sendfile=>true tmp_filename.delete() #to remove tempfile

Mysql connections in TIME_WAIT state -

i facing issue in server wherein couple of connections being timed out. below errors in err file:- 130401 8:07:06 [warning] aborted connection 1111111to db: 'abc' user: 'u1' host: '1.1.1.1' (got timeout reading communication packets) 130401 8:10:44 [warning] aborted connection 1712056 db: 'xyz' user: 'u2' host: '2.2.2.2.' (got error reading communication packets) below config wait_timeout= 900 max_connections | 500 max_packet_size 256m while historic max connections has not yet reached more 320, seeing lot of connections in time_wait using command: netstat -anlp | grep :3306 | grep time_wait -wc; date 299 on application side, client close connection if idle more 600secs. this means many connections in wait state. @ same time, server not busy. means not in lock state. can me on this? advance thanks. sridhar.

soda/selenium how to log an assert -

i'm sort of new selenium , soda love ability run selenium node. bear me ask basic question. this simple login chain i'm running in script. browser .click('css=a#loginbutton') .type('css=input.input-medium.email',user) .type('css=input.input.pwd',pass) .clickandwait('css=a.btn.login') .assertextpresent('clients','logged in ok') //client page reached however message 'logged in ok' not spitting out anywhere. i'm basic thing i'm missing here there has way spit out progress messages i'm running test script. script has become huge, it's not easy track down errors when occur. i'd sort of log success errors. doh! it's function not string. for else wondering. here's solution: browser .click('css=a#loginbutton') .type('css=input.input-medium.email',user) .type('css=input.input.pwd',pass) .clickandwait('css=a.btn.l

android - How to show direction on map based on calculated angle in degrees -

i have calculated angle between 2 latitude , longitude coordinates below code.it returns angle 3 in radians, , 193 in degrees. want show arrow marker on map based on angle.how display object direction moved,based on angle? public static double getangle(double lat1, double lon1, double lat2, double lon2) { //formulas //θ = atan2( sin(Δlong).cos(lat2),cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong) ) // Δlong = long2 - long1 log.i("angle", "inside getangle"); double latitude1 = math.toradians(lat1); double longitude1 = math.toradians(lon1); double latitude2 = math.toradians(lat2); double longitude2 = math.toradians(lon2); double dlong = math.toradians(longitude2-longitude1); double y = math.sin(dlong) * math.cos(latitude2); double x = math.cos(latitude1)*math.sin(latitude2) - math.sin(latitude1)*math.cos(latitude2)*math.cos(dlong); double angle= math.atan2(y, x); if (angle < 0)