Posts

Showing posts from July, 2015

C++ & Qt: Don't pick a random number for x minutes -

let's have 10 numbers 1 10 , rand() picks number 3. number displayed on screen, but won't shown 15 minutes after picked . how can that? i know srand should used better random results, that's not want achieve. want specific number shown once, after not appear until 15 minutes gone. i've read sleep, haven't figured out how works , if fits problem. one straightforward way: keep record of numbers they're picked , time they're picked. so each time want display number: check record , remove entries older 15 minutes. pick number between 1 , 10. check record see if picked number has been used in last fifteen minutes. if go step one. since picked number hasn't been used in last 15 minutes, display number. add new entry record picked number , current time. note obviously, if pick 9 numbers in less 15 minutes, , tenth number picked within 15 minutes, result not random @ all. point being kind of constraint results less random more numbers ...

r - missing S3 method but higher level-function works -

i'm trying pin down problem grobwidth applied gtable objects (see gtable:::widthdetails.gtable ); issue arises when size specified sum of units ( unit.arithmetic object), library(grid) u = unit(1,"npc") + unit(2,"mm") grid:::absolute.units(u) #error in usemethod("absolute.units") : # no applicable method 'absolute.units' applied object of class #"c('unit.arithmetic', 'unit')" remarkably, absolute.size works, though calls grid:::absolute.units , grid::absolute.size(u) #[1] 1null+2mm how possible? ok, browsing grid source code , found out method is defined, grid:::absolute.units.unit.arithmetic(u) but it's not exported. absolute.size() knows it, because it's in package namespace, calling outside (e.g. gtable) fails.

c++ - Why does this virtual method return true? -

while taking tutorial on polymorphism in c++, code seems acting strangely on call non-overriden virtual method. here classes: // classes.cpp namespace classes { class c { public: virtual bool has_eyesight() { return false; } } c; class see : public c { public: bool has_eyesight() override { return true; } } si; } and here main method: // file.cpp #include <iostream> #include "classes.cpp" using std::cout; using std::endl; using classes::c; using classes::see; int main() { see& si = classes::si; cout << si.has_eyesight() << endl; c& c = si; cout << c.has_eyesight() << endl; c = classes::c; cout << c.has_eyesight() << endl; } this code print 1 1 1 (true true true) when run; shouldn't c.has_eyesight() return false if references c , not see? (forgive me if sounds naive, start...

jquery - Image and label not aligning correct -

Image
i trying align text of label starts @ same indent text in first line when text spills on next line due insufficent screen space. created example demonstrate problem im having. alignment should this http://jsfiddle.net/74k8kptc/2/ <body> <div class="container"> <div class="toggle_head"> <img src="pfeil_rechts_blau.png" alt="expand" class="expand"> <img src="pfeil_links_blau.png" alt="collapse" class="collapse"> <label class="question">some long text doesnt align when page forces text on new line on making smaller</label> </div> <div class="toggle_body"> <hr> lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusa...

ruby - How to draw shape and use as button in Shoes? -

Image
i writing calendar gui in ruby using shoes . going of it's features, until got part wanted style boxes had created. using basic shoes::shapes @ first placeholder, after reading through documentation decided going undoable. tried border solution, didn't seem work well. here basic example of trying achieve. the boxes must function both clickable (so button), , element who's contents can changed. what, if any, best way achieve in shoes? have ditch shoes , pursue other gui framework instead? i found answer. reason, didn't see (or didn't register) when viewed page. answer can found here

mysql - Merging 2 tables with different field name -

select * 'batcha' table 'batcha' +--------+--------+--------+ |fruits | color | class | +--------+--------+--------+ | | | | |apple | red | x | |apple | yellow | x | |guava | green | o | +--------+--------+--------+ select * 'batchb' table 'batchb' +--------+--------+--------+ |fruitsb | size | type | +--------+--------+--------+ | | | | | apple | large | | | guava | medium | b | | guava | small | c | +--------+--------+--------+ is possible query join or union using these results? result +--------+--------+--------+--------+--------+--------+ |fruits | color | class |animals | size | type | +--------+--------+--------+--------+--------+--------+ | | | | | | | | apple | red | x | | | | | apple | yellow | ...

javascript - css only appends to the first panel -

i have wrote jquery change button colour red when 1 clicks on it. work first panel not working rest of panels. in first set of button works not everything. jquery part. function durationonclick(element){ var buttonid = element.id; var buttonname = element.name; var buttonids = ["1hour", "30min", "1day" , "1week", "1month"]; var charttype = $('#charttype').val(); var idvalue = $('#idvalue').val(); //after user click option here changing option black red. $(buttonids).each(function(i, e) { $('#'+e+'[name='+buttonname+']').css("color", ""); }); $('#'+buttonid+'[name='+buttonname+']').css("color", "blue"); ` the html code : <div class="row"> <div class="col-md-6"> <div class="panel panel-default"> ...

javascript - How to Modify Content in a Text Block -

i have html looks this: <td class="targettd"> <a href="http://foo.com"> <span>content</span> </a> **text want modify** <span>more content</span> </td> targettd iterates dynamic number of times depending on content being rendered. each iteration, need remove substring of ": " beginning of code in text block. unfortunately it's not in own element , don't have ability wrap in neat , tidy id/class. did searching , found js thought might trick: <script> var mystring = $('.targettd').html(); mystring = mystring.replace(': ',''); $('.targettd').html(mystring); </script> but spits out console error: unable property 'replace' of undefined or null reference. final update (solution) thanks @vaibhav coming fix! script did trick: <script type="text/javascript"> $(function() { $('.targettd...

Parsing XML using command line -

how parse xml below contents? <?xml version="1.0"?> <saw:ibot xmlns:saw="com.siebel.analytics.web/report/v1" version="1" priority="normal" jobid="36 "> <saw:schedule timezoneid="(gmt-05:00) eastern time (us &amp; canada)" disabled="false"> <saw:start repeatminuteinterval="60" endtime="23:59:00" startimmediately="true"/> <saw:recurrence runonce="false"> <saw:weekly weekinterval="1" mon="true" tue="true" wed="true" thu="true" fri="true"/> </saw:recurrence> </saw:schedule> <saw:datavisibility type="recipient" runas="cgm"/> <saw:choose> <saw:when condition="true"> <saw:deliverycontent> <saw:headli...

haskell - Run cabal repl from winghci -

to include cabal dependencies run cabal install mypackage i run cabal repl , repl use import library this allows use newly added library ghci. is same possible using winghci ? run winghci repl has access installed cabal dependencies ? you can use :! execute shell commands. i.e. run :!cabal install mypackage within winghci repl. can't import mypackage until restart winghci. that's experience @ least. i'm interested in answer well... running :!cabal repl inside winghci repl not sensible (which answers title question literally).

Removing an entry in r -

in sas there capability remove observation through simple if statement. instance if wanted delete rows year = #. write: if year == "#" delete; is there equivalent way in r? tried this: df<- df[!(df$year == "#"),] data set in r: year month # june # july # august 2015 august but when run df$year, still # factor level when thought filtered out? you're doing right. still factor level, doesn't mean exists in vector df$year . can drop factor level if need droplevels or using factor again df$year <- factor(df$year) if need convert factor numeric labels numeric vector, can use: as.numeric( ## convert numeric expected as.character( ## because factors numbers labels your_factor ) ) )

getimagesize() won't work on my site (PHP) -

i used getimagesize() size of .swf file on xampp localhost server , worked. when apply on site. doesn't output anything. so made test page see if react same way , did. echo width see if gets result @ all, , on localhost , gives me output of 800 . when use on site, gives no output @ all... <?php $url= "http://cache.armorgames.com/files/games/sugar-sugar-3-17769.swf"; $tst = getimagesize($url); echo $tst[0]; ?> is there reason why wouldn't work? makes no sense me. i wrote out blank php file , used getimagesize() on url posted , returned expected array of results. how looked @ php error log see if there other underlying errors preventing output? print_r() or var_dump() give anything? array ( [0] => 800 [1] => 600 [2] => 13 [3] => width="800" height="600" [mime] => application/x-shockwave-flash )

amazon s3 - python s3 get file without knowing exactly the name file -

i'm using python , boto files amazon s3. i'm uploading format: year/month/filenameyyyymmdd.hhmmss.zip my problem dont know time (hhmmss) of file. there way it? example: bucket = awscnx.get_bucket(bucketname) directory = 'year/month/filenameyyyymmdd.*.zip' bucket.list(prefix=directory) from boto source-code : def list(self, prefix='', delimiter='', marker='', headers=none, encoding_type=none): """ ... :type prefix: string :param prefix: allows limit listing particular prefix. example, if call method prefix='/foo/' iterator cycle through keys begin string '/foo/'. ... you can read more in docs so see no reason why not implement way wrote it, minor change of declaring: directory = 'year/month/filenameyyyymmdd' (substituting date pattern correct date of course).

c# - Xamarin Forms Maps Android -

i'm trying simple map working in xamarin forms. alread succeeded winphone, android making difficult. i've followed this walkthrough getting api key etc.. when add nuget package xamarin.forms.maps , updated packages, 5 errors including: error: error: package android.support.v7.internal.widget.nativeactionmodeawarelayout not exist i tried solution on this thread (googleplayservices downgrade), that's not working either. suspect has faulty updates of packages, don't want blame guys responsible that. can point me in right direction? that happened me. solution unload project, reload it, tried again download nugets , magic done. hope solves problem too. edit 08/10/2015 try searching route: c:\users\user\appdata\local\xamarin , see if there android.suppor.v7 folder, if not, means xamarin did not downloaded nuget, downloading them xamarin studio solves problem (it not works, it's worth give try). if not work, other thing can try go solution fo...

Java Swing Interface Troubles -

this strangest bug i've ever encountered. whenever start program, in 1 of 2 times, gui created , pop-ups. in other 1 out of 2 times, no gui, no error , code executed in same order whenever gui created. what causing bug? , how resolve this? i'm clueless.. the view class : package view; import controller.gamecontroller; import lombok.data; import model.gamemodel; import javax.swing.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; @data public class view extends jframe { gameinterface gameinterface = new gameinterface(); mainmenuscreen menuscreen = new mainmenuscreen(); public view() { super("view"); setdefaultcloseoperation(windowconstants.exit_on_close); displaymenuscreen(); setvisible(true); } public void displaymenuscreen(){ menuscreen.getstartthegamebutton().addactionlistener(new actionlistener() { @o...

javascript - dynamically adding markers to google map on click -

i trying create website has google map in 1 column , in second list of items location elements. on clicking 1 of these items, drop pin in google map. having trouble updating markers on google map. can add 1 marker @ initialization of map, cannot new markers dropped. here code: https://gist.github.com/aarongirard/32f80f17e19d3e0389da . issue occurs in if else clause within click function. any appreciated!! //global variables //google map var map; var marker; var currentmakerli; function initialize() { //set latlng of starting window of map var mapoptions = { center: { lat: 34.073609, lng: -118.562313}, zoom: 14, }; //set map using above options , attach given element map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); //construct new marker; constructor takes object position , title properties //get lat long first marker var latlng = new google.maps.latlng(34.073514, -118.562348); marker = new google.maps.marker({ pos...

testing - Need to know how to test the output in database as stated below -

i need know way of testing or technique below scenario. input.txt ---> processing module --> output in database tables here how input.txt(it huge file 10k lines) looks like: timestamp1,organisation1,data1,localtimestamp1,place1 timestamp2,organisation1,data2,localtimestamp2,place1 timestamp3,organisation1,data3,localtimestamp3,place1 i feed file processing module , output entered database tables in form (example:- table1 table10 & each table contains more 6 columns). example :- table 1 column1 column2 ....... processeddata1 place1 processeddata2 place2 so output in db tables. my question how test output. input in form of packets in .txt file , processed data in huge rows of database here have tried.. process input (now processed data in db tables) export processed data tables .csv files. validate these .csv files manually (only first time). keep these .csv files standard reference files(std). for every release run proces...

python - Convert a String representation of a Dictionary to a dictionary? -

how can convert str representation of dict , such following string, dict ? s = "{'muffin' : 'lolz', 'foo' : 'kitty'}" i prefer not use eval . else can use? the main reason this, 1 of coworkers classes wrote, converts input strings. i'm not in mood go , modify classes, deal issue. starting in python 2.6 can use built-in ast.literal_eval : >>> import ast >>> ast.literal_eval("{'muffin' : 'lolz', 'foo' : 'kitty'}") {'muffin': 'lolz', 'foo': 'kitty'} this safer using eval . own docs say: >>> help(ast.literal_eval) on function literal_eval in module ast: literal_eval(node_or_string) safely evaluate expression node or string containing python expression. string or node provided may consist of following python literal structures: strings, numbers, tuples, lists, dicts, booleans, , none. for example: ...

PHP - Add null character to string -

i'm trying append number of null characters '\0' string in php. $s = 'hello'; while(strlen($s) < 32) $s .= '\0'; however, php adds 2 characters (\ , 0), instead of escaping character , adding null. know add null character string? i don't know if \0 correct in case, should use " : $s = 'hello'; while(strlen($s) < 32) $s .= "\0";

forms - cgi.parse_multipart function throws TypeError in Python 3 -

i'm trying make exercise udacity's full stack foundations course. have do_post method inside subclass basehttprequesthandler , want post value named message submitted multipart form, code method: def do_post(self): try: if self.path.endswith("/hello"): self.send_response(200) self.send_header('content-type', 'text/html') self.end_headers ctype, pdict = cgi.parse_header(self.headers['content-type']) if ctype == 'multipart/form-data': fields = cgi.parse_multipart(self.rfile, pdict) messagecontent = fields.get('message') output = "" output += "<html><body>" output += "<h2>ok, how this?</h2>" output += "<h1>{}</h1>".format(messagecontent) output += "<form method='post' enct...

conditional formatting html table in php with time stamp comparison -

echo '<table style="width:100%"> <tr>'; echo '<td>order</td>'; echo '<td>destination</td>'; echo '<td>location</td>'; echo '<td>status</td>'; echo '<td>timestamp</td>'; echo '</tr>'; if($result) { while($row = mysqli_fetch_assoc($result)) { echo '<tr><td>'; echo $row['ordernumber'] . ''; echo '</td><td>'; echo $row['destination'] . ''; echo '</td><td>'; echo $row['location'] . ''; echo '</td><td>'; echo $row['status'] . ''; echo '</td><td>'; echo $row['timestamp'] . ''; echo '</td></tr>'; } echo '</table>'; } i want change background of row turned different color time stamp more 60 minu...

angularjs - Take in-app photo with Cordova Camera and upload it to Parse.com -

i'm building ionic/cordova app uses parse.com baas. uses ngcordova camera plugin control device camera. use-case click button, take picture , have upload parse. i've been researching problem week , still can't figure out why can't work. the controller: .controller('cameractrl', function($scope, camera) { var cameraoptions = { quality: 75, destinationtype: 0, encodingtype: 0, targetwidth: 300, targetheight: 300, mediatype: 0, correctorientation: true, savetophotoalbum: true }; }; $scope.takepicture = function() { cameraoptions.sourcetype = 1; navigator.camera.getpicture(onsuccess, onfail, cameraoptions); } $scope.selectpicture = function() { cameraoptions.sourcetype = 0; navigator.camera.getpicture(onsuccess, onfail, cameraoptions); } function onsuccess(picture) { file.upload(picture) .success(function(data) { // upload finish }); $scope...

sql - mysql how to use two field as primary key and unique -

in mysql database have data create table student(user_id int(20) unsigned not null auto_increment, name varchar(20), email varchar(20), primary key(user_id,email)); i want use user_id , email field should unique value. add alter table student add unique unique_index (user_id,email); but still accepts entry mysql> insert student (name, email) values ("a", "aa", "aa"); query ok, 1 row affected (0.06 sec) mysql> insert student (name, email) values ("a", "aa", "aa"); query ok, 1 row affected (0.06 sec) select * student; +---------+------+-------+ | user_id | name | email | +---------+------+-------+ | 1 | | aa | | 2 | | aa | +---------+------+-------+ 2 rows in set (0.00 sec) how can make fields(id , email) unique? you can use these. here every unique index name should different. create table student(user_id int(20) unsigned not null auto_increment, name varchar(20), ...

Export records to cloudkit -

i need export data dictionary of 12 thousand items cloudkit. tried use convenience api keep hitting rate limit while trying save public database. tried operation api , got similar error. question is: how save large amount of data cloudkit without hitting limits? according docs ckerrorlimitexceeded error code, should try refactoring request multiple smaller batches. so if ckmodifyrecordsoperation operation results in ckerrorlimitexceeded error, can create 2 ckmodifyrecordsoperation objects, each half data failed operation. if recursively (so of split operations fail limit exceeded error, splitting again in two) should number of ckmodifyrecordsoperation objects have small enough number of records avoid error.

azure - Unable to generate WAAD Application Keys -

Image
recently no longer been able generate application keys in waad...(or more specific can generate key never see value) and after save receive unauthorized access error... i directory co-administrator - key appear save, after page refresh there entry keys table. directory full administrator can see value no-longer co-admins. the above issues happens when making modifications "permissions other applications", azure reports unauthorized changes make again committed. i have ruled out different browsers, have tired ie, , chrome. help appreciated. co administrator subscription role not azure ad role. in order perform should have admin privileges in azure ad on you're trying create keys. what azure ad role you're in ?

java - weblogic timeout due to long DB query -

my requirement read records excel sheet (containing 3 columns) , check whether record exists in db. if exists, write them along more data (2 more columns of excel) separate db table. worst case 10000 records. problem facing weblogic times out after reading 50 records. current code logic is: validate method(){ callvalidatemethod 1()----- checks whether first column data exists in db. happens each record. worst case 10000 records callvalidatemethod 2()----- checks whether second column data exists in db. happens each record. worst case 10000 records callvalidatemethod 3()----- checks whether third column data exists in db. happens each record. worst case 10000 records if(validation returns true){ writing valid data arraylist call writedata method---which writes arraylist db. } the ui page gives network error -server slow or busy. in end code runs fine since on console code prints sop statements. have made changes in weblogic jta settings giv...

r - How to convert a table to a data frame -

i have table in r has str() of this: table [1:3, 1:4] 0.166 0.319 0.457 0.261 0.248 ... - attr(*, "dimnames")=list of 2 ..$ x: chr [1:3] "metro >=1 million" "metro <1 million" "non-metro counties" ..$ y: chr [1:4] "q1" "q2" "q3" "q4" and looks when print it: y x q1 q2 q3 q4 metro >=1 million 0.1663567 0.2612212 0.2670441 0.3053781 metro <1 million 0.3192857 0.2480012 0.2341030 0.1986102 non-metro counties 0.4570341 0.2044960 0.2121102 0.1263597 i want rid of x , y , convert data frame looks same above (three rows, 4 columns), without x or y . if use as.data.frame(mytable) , instead this: x y freq 1 metro >=1 million q1 0.1663567 2 metro <1 million q1 0.3192857 3 non-metro counties q1 0.4570341 4 metro >=1 million q2 0.2612212 5 metro <1 million q2 0...

add HBase Timestamp using Phoenix-Spark API -

how add hbase timestamp using phoenix-spark similiar hbase api: put(rowkey, timestamp.getmillis) this code: val rdd = processedrdd.map(r => row.fromseq(r)) val dataframe = sqlcontext.createdataframe(rdd, schema) dataframe.save("org.apache.phoenix.spark", savemode.overwrite, map("table" -> htable, "zkurl" -> zkquorum)) this feature not supported in phoenix. maybe, need use hbase api instead of phoenix.

php - using OutOfBoundsException for non arrays -

say have method takes in values between 0 , x. if parameter greater x or less 0 want throw exception. outofboundsexception reasonable exception throw? http://php.net/manual/en/class.runtimeexception.php says "exception thrown if value not valid key". since i'm not using exception arrays (and henceforth keys) still okay if use it? i mean, on 1 hand, seems doesn't matter. if threw badmethodcallexception exception , person using method knew , either catching or exception seems that'd sufficient, it'd nice have exceptions make sense too. it should fine , appropriate use this. exceptions aren't tightly-coupled original uses. it's "out of bounds" outside range of allowed values, makes sense.

c# - Is there a better way to get a copy of DataRowView? -

i have collection of datarowview bound datagrid . functionalities, need copies of datarowview s. i'm using following method it. public static datarowview getcopyofrowview(datarowview rowview) { datatable table = rowview.dataview.totable(); datarow copyrow = table.newrow(); copyrow.itemarray = rowview.row.itemarray; table.rows.insertat(copyrow, table.rows.count); return table.defaultview[table.rows.count - 1]; } but method prove costly more 1000 rows. there better way this? datatable has copy method copies schema , data. use that? said need copy more 1000 rows...

Python awk command -

import os import sys os.system ('kill "$(ps aux | grep snmp | awk '"{print $2}"' | head -n1)"') i trying kill process in python, have error line: awk: line 2: missing } near end of file sh: 1: kill: illegal number the problem comes awk command, don't know exact syntax. can me please? thank in advance! the ' around awk ' terminates python string, end concatenation of 'kill "$(ps aux | grep snmp | awk ' , "{print $2}" , , ' | head -n1)"' , trying execute: $ kill "$(ps aux | grep snmp | awk {print $2} | head -n1)" where { parsed shell syntax. this should work: os.system('kill "$(ps aux | grep snmp| awk \'{print $2}\' | head -n1)"') a possibly better approach use pkill : os.system('pkill snmp')

java - Create a folder from text contents -

i think challenging , interesting too. have att.txt contents /enumeration/unassigned.gif,/enumeration/unassigned2.gif,/workflow/close.gif, /workflow/defer.gif,/workitemtype/bug.gif,/workitemtype/enhancement.gif.now, need create new folder called attachment inside need sub folders enumeration contains enumeration gif, workflow folder contains workflow gif , same workitem.how can create in java. please me struggling here lot. see if helps. didn't got here below code create subdirectories you. public class main { public static void main(string[] args) throws java.lang.exception { java.io.bufferedreader br = new java.io.bufferedreader( new filereader("att.txt")); string scurrentline=""; while ((scurrentline = br.readline()) != null) { scurrentline= scurrentline.replaceall("gif", "txt"); string[] s = scurrentline.split(","); for(int i=0;i<s...

android - How to disable notification bar and status bar on lock screen? -

i have tried following code still not work me. requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); you may try following, view view = getwindow().getdecorview(); // hide status bar int uioptions = view.system_ui_flag_fullscreen; view.setsystemuivisibility(uioptions); // hide actionbar actionbar actionbar = getactionbar(); actionbar.hide(); or add style in manifest, android:theme="@android:style/theme.holo.noactionbar.fullscreen"

android - Gallery can't display image from internal storage -

i have image stored in internal storage of app. can grab path , can succesfully set image view. when trying let user open using gallery (intent), displays black screen. myintent.setdataandtype(uri.fromfile(file), mimetype); intent = intent.createchooser(myintent, "choose viewer"); startactivity(intent); i pretty sure has permission gallery cant access private storage of app reason. there way "beside moving file external storage" thanks use fileprovider serve file internal storage . quoting documentation: fileprovider special subclass of contentprovider facilitates secure sharing of files associated app creating content:// uri file instead of file:/// uri. a content uri allows grant read , write access using temporary access permissions. when create intent containing content uri, in order send content uri client app, can call intent.setflags() add permissions. these permissions available client app long stack receiving activity active....

jquery - How to switch a div content that has php values -

i have 2 php variables. want create read more button toggle these 2 values, 1 excerpt, other full content. new php , jquery. have spent few hours trying figure out :( appreciated if can help... i tried change id , class achieve goal. believe might stupid. don't know smart way. can give me direction please? right now, alert put in codes returns "undefinied"... php : $trimmed = '<p id="short_desc" class="show_desc">' . chinese_excerpt( get_the_content(), $lenth = 260 ) . '</p>'; $full = '<p id="full_desc" class="hide_desc">' . get_the_content() . '</p>'; echo apply_filters( 'the_resume_description', $trimmed ); echo apply_filters( 'the_resume_description', $full ); echo '<div style="float:right; margin-top:-30px"><div id="show_more">read more...</div></di...

java - Gray bars on bottom and right side while using graphics -

on every game make using usual graphics, end getting gray bars on right side , bottom of window. you can see here: http://i.stack.imgur.com/qtxr6.png any appreciated! edit main(string args[]) method main component = new main(); jframe frame = new jframe(); frame.add(component); frame.pack(); frame.setresizable(false); frame.setlocationrelativeto(null); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); frame.settitle(name); component.start(); render method public void render() { graphics g = screen.getgraphics(); // drawings g.setcolor(new color(255, 255, 255)); g.fillrect(0, 0, screenpixel.width, screenpixel.height); level.render(g); for(entity e:entity.entities){ e.render(g); } g = getgraphics(); g.drawimage(screen, 0, 0, screensize.width, screensize.height, 0, 0, screenpixel.width, screenpixel.height, null); g.dispose(); } answered m...

uisearchbar - How to implement searchBar and its delegate method in ios -

// viewdidload code initialize searchbar code - (void)viewdidload { [super viewdidload]; [self setupinitialview]; [self setinitialview]; self.tblfeedtable.contentoffset = cgpointmake(0, self.searchbarcontroll.frame.size.height - self.tblfeedtable.contentoffset.y); self.searchbarcontroll = [[uisearchbar alloc] initwithframe:cgrectmake(0, 0, 320, 44)]; self.searchbarcontroll.delegate = self; self.tblfeedtable.tableheaderview = self.searchbarcontroll; } - (void)searchbartextdidbeginediting:(uisearchbar *)searchbar { // when curson focuse } - (void)searchbarcancelbuttonclicked:(uisearchbar *) searchbar { // when cancel button click } -(void)searchbartextdidendediting:(uisearchbar *)searchbar { [searchbar setshowscancelbutton:no animated:yes]; } is there other delegate methods 1 want suggest me improve search experience? thanks in advance.

postgresql - Hive Metastore Configurations PostgresSQL -

when start hive metastore service, command line says: "starting hive metastore server" , nothing further. doesn't start server, neither throws error messages hive : 1.2.1 hadoop : 2.7.1 postgres: 9.3.8 hive-site.xml <configuration> <property> <name>javax.jdo.option.connectionurl</name> <value>jdbc:postgresql://localhost:5432/metastore</value> </property> <property> <name>javax.jdo.option.connectiondrivername</name> <value>org.postgresql.driver</value> </property> <property> <name>javax.jdo.option.connectionusername</name> <value>hiveuser</value> </property> <property> <name>javax.jdo.option.connectionpassword</name> <value>*****</value> </property> <property> <name>org.jpox.autocreateschema...

How to show one div and hide another div in javascript on same html page -

i having 1 html page in navigation (lets them tabs) resides. i wrote javascript show 1 , hide 1 on link click. it works on tab want when navigate tabs div showing on bottom. dont want display in other tabs. this javascript code: function displayblock(divname){ if(document.getelementbyid("vend")) { var olddiv = document.getelementbyid("vend"); olddiv.style.display = 'none'; //show div var newdiv = document.getelementbyid(divname); newdiv.style.display = 'block'; } else{ var newdiv = document.getelementbyid(divname); newdiv.style.display = 'none'; } } how modify meet need? html structure: <div class="tab-content"> <div class="tab-pane" id="dashboard"> <div class="container"> <!-- container code --> </div> </div> <div class="tab-pane" id=...

android - send sms from background -

1) uri uri = uri.parse("smsto:" + phonenumber); intent intent = new intent(intent.action_sendto, uri); intent.putextra("sms_body", smsbody); startactivity(intent); this code sending sms. action_sendto not send sms directly other user. action_sendto shows sms box fill other user name , smsbody. how sms send directly other user sms body ? 2) smsmanager smsmanager = smsmanager.getdefault(); smsmanager.sendtextmessage(phonenumber, null, smsbody , null, null); this code not working... add send sms permission manifest

How to understand variadic templates in c++11 -

sometimes use(. . .)to indicate template or function parameter represents pack. pack expansion putting (. . . ) right of pattern. i little confused 2 occasions above. in c++ standard document(14.5.3 item 4): "in function parameter pack (8.3.5); pattern parameter-declaration without ellipsis." there’s 1 example quote: template<typename ...t1> void f1(t1 ...t1) { } according above description,for function parameter pack,the pattern (t1 t1). why can't somethig that, put (...) right of pattern,then can code below: template<typename ...t2> void f2(t2 ...t2...) // f2(t2 ...t2...) -> f2((t2 ...t2)...)->f2((t2 t2)...) { } i confusedly think (...) after t2 mean pack expansion the pattern (t2 t2).then found code compiled success in vs2013.wow, find inspiration yet? i brazenly began new attempt. there’s quote in c++ standard(14.5.3 item 4): "in template parameter pack pack expansion (14.1): — if template parameter pack pa...

c - conio setcolor(BLACK) not working -

the method setcolor(black) not working on white background. if background color black , setcolor(white) displays circle border correctly. doesn't happen other color. #include<graphics.h> #include<conio.h> void main() { int gd=detect,gm; initgraph(&gd,&gm,"c:\\tc\\bin"); setbkcolor(white); setcolor(black); circle(100,100,50); getch(); closegraph(); }

excel - FOR NEXT or FOR EACH LOOP only works for first value -

please in making next loop following code; i'm trying copy each cell in range & past specific (fixed position) cell copy results specific (fixed position) cells , paste cells. want for each cell in range. using macro recorded code below worked perfect want make next or each loop recorded macro, please me. ' ' pastspecialcheck6 macro ' ' l1 activesheet.cells(12, 103).select selection.copy range("b9").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false range("b28:b34").select selection.copy activesheet.cells(40, 103).select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false ' l02 activesheet.cells(13, 103).select selection.copy range("b9").select selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=...

javascript - PHP unicode char face convert to hex for Arabic -

i experiencing problem in converting arabic chars hex values $text = "يي"; $text = mb_convert_encoding($text, "html-entities", "utf-8"); $text = preg_replace('~^(&([a-za-z0-9]);)~',htmlentities('${1}'),$text); result : &#1610;&#1610; actually both chars ي in display changing faces according char position first, middle , end , want code //ﻳ == ي 'beginning' => '&#xfef3;', 'middle' => '&#xfef4;', 'end' => '&#xfef2;', 'isolated' => '&#xfef1;' i need char values face on screen in html, javascript or in php. to fix shaping imagettftext , can use library ar-php : require('../i18n/arabic.php'); $arabic = new i18n_arabic('glyphs'); $text = 'بسم الله الرحمن الرحيم'; $text = $arabic->utf8glyphs(...

javascript - Input value not showing up (AngularJS) -

i've got controller: app.controller('controlformulario', function($scope) { this.formulario = []; this.formulario.fecha = new date(); }); ...this directive: app.directive('formulario', [function() { return { restrict: 'e', // c: class, e: element, m: comments, a: attributes templateurl: 'modules/formulario.html' }; ... , view: <div class="form-group"> <label for="fecha">fecha</label> <input type="fecha" class="form-control" id="fecha" ng-model="fecha" value="{{formctrl.formulario.fecha | date}}" disabled> </div> as may guess, attribute value has date, filtered , so. no problem here. actual problem comes when see website, , find out input doesn't show anything. "value" attribute assigned, it's not showing inside input box. why? doing wrong? tried same ng-init, ng-value... i'm newbye on angula...

php - How to change the environment in Laravel 5.1? -

Image
what understand working of environments in laravel have different environments different, environments. so, if running app locally have .env.local file. if testing or on production, use .env.testing or .env.production . (correct me if wrong.) default .env file can edit. can tell me workflow of changing environments in laravel. tried documentation couldn't it. please me. when install laravel 5.1 2 files .env , .env.example if want work locally set : app_env=local app_debug=true in prod set app_env=production app_debug=false an error message in debug mode an error message production mode note: have 2 .env files .env , .env.example .. can create 1 name .env.production keep in mind in order configuration loaded must rename file .env edit : in case still working in local , need database test, can create file in total have 3 .env files : .env.production .env.local1 .env.local2 whenever want switch configuration rename desired file .env

matlab - Sparse matrix and linear algebra with c++ -

i'm converting program matlab visual c++ (community edition) see how faster can run. original program runs days @ time... although i'm experienced matlab, know basic c++ ask linear algebra functions need. saw thing: http://math.nist.gov/lapack++/ i'm not sure if best option me. my matlab program looks in principal: 1. 30*30 pixel image big pre-loaded list of images. 2. pad image random number of zeros (to 60*60). 3. crop padded image randomly. 4. down-sample cropped image. 5. run line: = + 0.1*(sin(a) + w*a + z*y); 6. repeat 7 million times. where column vector of length 1000. w 1000*1000 sparse matrix. z 1000*30 full matrix. y 30*1 vector. so need functions for: padding matrix cropping matrix down-sampling matrix multiplying , adding matrices , sparse matrices. what specific library / functions recommend? keep in mind know little c++ please give urls if needed.

c# - How to fix missing HTML<open> & <close> tags in middle of HTML string -

i have validate html string in project, i have html : <ul> <li>test 1</li> <ol> <li>test 2</li> </ol> <li>test 1</li> </ul> required output : <ul> <li>test 1</li> </ul> <ol> <li>test 2</li> </ol> <ul> <li>test 1</li> </ul> in html code </ul> , <ul> tags missing. in case how search missing tag , how insert appropriate ending tag , beginning tags in proper places. i tried html agility pack , tidy library, couldn't find better solution issue. using dom manipulation library, need create ruleset describing elements can children of <ul> element. iterate on of children, , when find child ( <ol> ) that's not allowed, move subsequent children, including <ol> child, parent of <ul> element, placing @ index of <ul> element + 1.

sql - Java Inserting into database adds new data and it replaces the first row -

this code button, inserts data has been changed in text boxes of gui, once pressed. i have been getting issue adds new row of data when press insert, replaces first row in table, end having first , last row equal in aspects. may please me? appreciated. private void jtogglebutton1actionperformed(java.awt.event.actionevent evt) { tblstudents stud = new tblstudents(); int row = jtable1.getrowcount(); row++; stud.setstudentid(row); stud.setfirstname(jtextfield2.gettext()); stud.setsurname(jtextfield3.gettext()); string birthd = dated.gettext(); simpledateformat sdf1 = new simpledateformat ("yyy-mm-dd"); try { date date = null; date = sdf1.parse(birthd); stud.setbirthdate(date); } catch (parseexception ex) {} stud.setgrade(jtextfield4.gettext()); stud.sethouseid (integer.parseint(jtextfield6.gettext())); studenthousepuentitymanager.g...

multithreading - Cannot Append to Received String in UDP Listener C# -

i have form create udp object, in udp class udpclient created , received data done in beginreceive method using endreceive. when print string of reveived data, after converting byte[], console within beginreceive method, text appended, received data prints not appended text. so looks received data incomplete. when string prints, newline , appended "done" not shown. any great!! thanks class udp { public eventhandler _datareceived; public udp() { int receiverport = 1248; udpclient receiver = new udpclient(receiverport); string discovery = "<?xml version=\"1.0\"?><servicequery></servicequery>"; receiver.beginreceive(new asynccallback( datareceived), receiver); ipendpoint end = new ipendpoint(ipaddress.broadcast, 1248); receiver.send(encoding.ascii.getbytes(discovery + "\0"), discovery.length + 1, end); } private void datareceived(iasyncresult ar) { ...

java - How to integrate the acknowledgment mails in my app -

in application, notifying users (via smtp) when called new project. the notification email simple template sent spring. the issue have know if user had read email or not. have integrate acknowledgment mails. any !!

Passing variables from php to python and python to php -

i breaking head make work in dead end. have no idea doing wrong. play php , python; trying execute python script through php exec(), return output , pass python script. workflow: 1) through jquery , ajax request pass data php file (exec1.php) looks this: $number = $_post['numberofclusters']; $shape = $_post['shapefilepath']; // execute python script $command = "python ./python/module1.py $number $shape"; exec($command,$out,$ret); print_r($out); print_r($r); //return nicely 1. 2) python file run module1.py looks this: # list of list of tuples cls000 = [[(365325.342877, 4385460.998374), (365193.884409, 4385307.899807), (365433.717878, 4385148.9983749995)]] # return data php print cls000 3) have nested ajax request inside success function of previous ajax request in pass response (in case cls000 list) php script called (exec2.php) this: # pass variables form $number = $_post['numberofclusters']; $shape = $_post['shapefilepath']; $c...

Rails Nested form validation errors -

i have simple scenario articles , comments. article has comments. in article show action display article , form add comment. when comment submitted triggers comments#create action. when save successful redirects article show action. works fine. my question when save not successful action should taken? normally use: "render edit" in case have no comments#edit action. class articlescontroller < applicationcontroller def show @article article.find(params[:id]) @comments = @article.comments.order(created_at: :asc).page(params[:page]).per_page(5) @comment = comment.new end end class commentscontroller < applicationcontroller def create @article = article.find(params[:id]) @comment = @article.comments.new(discussion_params) @comment.user_id = current_user.id if @comment.save redirect_to @article else render ??? end end private def discussion_params params.require(:comment).permit(:content)...

shell - fgrep or grep -F, which one is better for portable script? -

i having controversial commentary on this answer question whether should use fgrep or grep -f switch (i.e grep -f ) portability. points have been came light far are: grep -f : is posix standard. gnu grep has declared fgrep deprecated. fgrep : historically came before grep -f option. even though gnu grep declared fgrep deprecated, seem stick historical use. if consider old (really old) systems, can find of them not having grep -f in them (and think chance of happening rare). need worry very old machines , avoid posix standard that!! if think current situation , include old machines (which supposedly/allegedly don't have grep -f ), there more systems supporting fgrep . on other hand, if future, fgrep going history , grep -f triumph upon posix standard. and isn't accepted practice use posix standard better portability? this question bit opinion based. i'd put 2 cents here :- as mentioned fgrep going history , grep -f posix stan...