Posts

Showing posts from June, 2014

python - PyQtGraph : how to change size (height and width) of graph in a ScrollArea -

Image
i'm trying plot graph in scroll area i've no idea how change size of graphs. here example of have: as can see, in scrollarea (in red) size want, have graph (well, in reallity have more graphs , want see more 1 (at least two) in area). so, want height of graph (a) smaller , width of graph (b) expanding. somine can me ? thanks ! it looks plot inside layout "hide emg" button. widget holding layout must resized fit scroll area. you'll need provide code sample if want more that.. also consider using pg.multiplotwidget, provides similar functionality.

php - Why can I only add data in my database when I hash it to md5? -

i have function enter data html form in database. when try , submit function doesn't enter value. when hash variable md5 enter value database? know why might be? here function: function damage() { require 'mysql.php'; $today = date("y-m-d"); $cost = $_post["cost"]; $damage = $_post["damage"]; $query = "insert schade values (null, '$cost', '$damage', '$today')"; mysql_query($query, $db) or die ("vul alle velden in!"); echo("gelukt"); } damage(); thanks!

html5 - Extending dart:html classes in dart -

i new dart , wonder if can, example, extend divelement class create custom elements in 1 line of code. looking this; class redbox extends divelement { redbox(text) { this.text = text; this.style.background = "red"; } } redbox mybox = new redbox("hello world"); document.body.append(mybox); of course have more complex elements custom functions. in general, possible? when try run this, get: implicit call super constructor 'divelement()' you can extend html elements, there few requirements. 1 you're running need redbox.created constructor, , can redirect super class. created must generative constructor, though can add factory constructors. another requirement element registered document.registerelement . try adding this: class redbox extends htmlelement { redbox.created() : super.created() { style.background = "red"; } factory redbox(text) => new element.tag('my-redbox')..te

Compiler code optimization: AST vs. IR -

, define ir 3-address code type representation (i realize 1 can mean ast representation well). it understanding that, when writing best-practice compiler imperative language , code optimization happens both on ast (probably best using visitor pattern), , on ir produced ast.  (a) correct? (b) type of optimization steps best handled on ast before producing ir? (reference article/a list online welcome long deals imperative language)  the compiler i'm working on decaf (which might know) has deep cfg (single) class inheritance; i'll add features not part of such type coercion. hand-coded (using no tools whatsoever). not homework; writing fun.  (a) yes. (b) constant folding 1 example; cse another; in fact expression evaluation. ir-phase optimizations more results flow analysis.

android - adding log.e in the catch -

this error log when put log.e in catch,but don't know causes error occur. try{ ... } catch(ioexception e ){ log.e("my_app_error!", "error!", e); } here result of logcat 04-06 09:12:28.698: e/my_app_error!(4825): error! 04-06 09:12:28.698: e/my_app_error!(4825): java.io.eofexception 04-06 09:12:28.698: e/my_app_error!(4825): @ libcore.io.streams.readasciiline(streams.java:203) 04-06 09:12:28.698: e/my_app_error!(4825): @ libcore.net.http.httpengine.readresponseheaders(httpengine.java:579) 04-06 09:12:28.698: e/my_app_error!(4825): @ libcore.net.http.httpengine.readresponse(httpengine.java:827) 04-06 09:12:28.698: e/my_app_error!(4825): @ libcore.net.http.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:283) 04-06 09:12:28.698: e/my_app_error!(4825): @ libcore.net.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:177) 04-06 09:12:28.698: e/my_app_error!(4825): @ com.example.logintest.adduser$asscrountask.doinbac

Mysql how to join these tables -

i have following tables , sample data. schedule table fightno day_of_week orgin dest depart_time arrive_time totalfare aq2131 wed blr kta 04:30 11:00 6000 flight_stops (if have stops) flightno day_of_week airport_code arrival_time departure_time stopmilesfare aq2131 wed bom 02:17 05:40 3000 aq2131 wed coh 03:17 06:40 3000 aq2131 wed goy 04:17 08:40 3000 the flight route blr -> bom -> coh -> goy -> kta how can join these tables if user enters of these source , destination , retrieve flightno. example if user enters blr source , coh destination or coh source , goy destination, can find flight number. first, lets step moment. flights intended 1 direction d, or d 2 different flight numbers. have have proper correlation of direction proper flight. grins, imaginary international

c++ - How to declare a function which creates an object which will never be null? -

i have function creates object qmenu (in heap) qmenu* createmenu(qwidget* parent); // parent takes ownership of menu the function never return null pointer. think declaration don't tell point because returns pointer. when using method, need if (qmenu* m = createmenu(parent)) m->... which annoying. if returns reference, tells point. qmenu& createa(qwidget* parent); i never see code declares way. okay? there better declaration point? yes, it's fine return created object reference, if function makes own arrangements ownership of object's lifetime. one big example of function this: v& std::map<k,v>::operator[](const k&); .

android - Crop images in circle shape with border around it -

i want have image in circle shape , stroke around it. i use code crop bitmap in circle, don't know how put border/stroke around it. public static bitmap getcroppedbitmap(bitmap bitmap) { bitmap output = bitmap.createbitmap(bitmap.getwidth(), bitmap.getheight(), config.argb_8888); canvas canvas = new canvas(output); final int color = 0xff424242; final paint paint = new paint(); final rect rect = new rect(0, 0, bitmap.getwidth(), bitmap.getheight()); paint.setantialias(true); canvas.drawargb(0, 0, 0, 0); paint.setcolor(color); // canvas.drawroundrect(rectf, roundpx, roundpx, paint); canvas.drawcircle(bitmap.getwidth() / 2, bitmap.getheight() / 2, bitmap.getwidth() / 2, paint); paint.setxfermode(new porterduffxfermode(mode.src_in)); canvas.drawbitmap(bitmap, rect, rect, paint); //bitmap _bmp = bitmap.createscaledbitmap(output, 60, 60, false); //return _bmp; return output; } paint

php - Why does my echo not work given no results found? -

i performing routine check if books exist in database given range. want echo if no books found. have following: $search = mysqli_query($con,$query); while(list($book_id, $title, $authors, $description, $price) = mysqli_fetch_row($search)){ if(!empty($book_id)) { echo "book id: " . $book_id . "<br/>"; echo "book title: " . $title . "<br/>"; echo "authors: " . $authors . "<br/>"; echo "description: " . $description . "<br/>"; echo "price: " . $price . "<br/>"; echo "<br/>"; } if(empty($book_id)){ echo "fail"; } } if no books found nothing printed. echo not work? how come? thanks because if no records returned, won't enter in while @ all, $book_is contain value false , while(false)... know in situation may use mysqli_num_rows check if there rows found

sd card - Sending SD commands from Android app even for Rooted Phones -

is possible send sd commands android app sd card ? commands read sd card, write sd card etc (cmd18, cmd24). even rooted phones.. i think doing in sending sd commands android app any appreciated. thanks

python - Calculating the time complexity of this specific code -

im trying figure out time complexity of following code. lst_of_lsts contains m lists lengths @ n . this think: runs in o(m*n) , minimum = o(m*n) , remove = o(m*n) . overall o(m*n)*o(m*n) = o(m^2*n^2) am right? def multi_merge_v1(lst_of_lsts): = [e lst in lst_of_lsts e in lst] merged = [] while != []: minimum = min(all) merged += [minimum] all.remove(minimum) return merged def multi_merge_v1(lst_of_lsts): # m lists of n = [e lst in lst_of_lsts e in lst] # messy. enumerate n*m list items --> o(nm) merged = [] # o(1) while != []: # n*m items initially, decreases in size 1 each iteration. minimum = min(all) # o(|all|). # |all| diminishes linearly (nm) items, o(nm). # can re-use work here. should use sorted data structure or heap merged += [minimum] # o(1) amortized due table doubling all.remove(minimum) # o(|all|) return merged # o(1) the overall complexity appears o(

php - How to concatenate a constant similar to concatenation of strings? -

define('household_child1','custom_16'); define('household_child2','custom_14'); define('household_child3','custom_13'); define('household_child4','custom_12'); function household_function() { $vari = array(); $var['household'][household_child1] = $_session['household_membership'][1]; $var['household'][household_child2] = $_session['household_membership'][2]; $var['household'][household_child3] = $_session['household_membership'][3]; } i want implement above code in foreach loop similar concatenate. it should similar this foreach($_session['household'] $key => $value) { $var['household'][household_childi] = [i];//i need concatenate constant //to similar string } the constant function serve purpose: define('household_child1','custom_16'); define('household_child2','custom_14'); define('household_c

c# - Text file reader not reading until end of file -

i have following text file use position , length rule substring value of give string. id b element name element c length position key2 01 pn pnfn user mid nam usr 1 1 2 ....about 60 rows here how reading the text file , apply position , length value of text file string input. string input = "aaaaabbbbccccddddgggg......" **edit** var values = file.readlines("file") .skipwhile(string.isnullorwhitespace).skip(1) .select(l => l.split(new[] {' ', '\t'}, stringsplitoptions.removeemptyentries)); var array1 = offsets.select(split => new { element = split[5], length = int.parse(split[7]), position = int.parse(split[8]) }); foreach (var info in array1) { string substring = inpu

Python/Django with REST Framework - Error on POST {"non_field_errors": ["Invalid data"]} -

i'm starting out django , rest framework , i'm getting error when trying post entity. there error is: {"non_field_errors": ["invalid data"]} . happens @ line serializer.is_valid() this is view class looks like: from django.http import httpresponse django.views.decorators.csrf import csrf_exempt rest_framework.renderers import jsonrenderer rest_framework.parsers import jsonparser api.models import payload api.serializers import payloadserializer api.services import payloadservice class jsonresponse(httpresponse): """ httpresponse renders content json. """ def __init__(self, data, **kwargs): content = jsonrenderer().render(data) kwargs['content_type'] = 'application/json' super(jsonresponse, self).__init__(content, **kwargs) @csrf_exempt def payload_list(request): if request.method == 'post': model = payload(code="754d

preg match - return shell_exec then preg_match -

here's pretty weird: $txt = '/some/dir/some/file.txt'; $content = shell_exec('cat "'.$txt.'"'); then: preg_match_all("![some regex]!", $content, $matches); but preg_match returns nothing/false since $content "seems" empty (while it's txt file being filled infos: wget output of download in progress). weird thing is, if do: echo $content; exit; it shows current content of txt file. when f5/refresh, content accurately updated , print again. preg_match still can't parse it... $content = shell_exec('cat "'.$txt.'"' 2>&1); isn't doing better. nb: path file correct, chmod correct, etc... i tried following: $content = file_get_contents(dirname(__file__).'/'.$txt, true); or $ch_txt = curl_init(); curl_setopt($ch_txt, curlopt_url, dirname(__file__).'/'.$txt); curl_setopt($ch_txt, curlopt_returntransfer, 1); curl_setopt($ch_txt, curlopt_followlocat

java - how can i make this printf print the method without formatting errors -

how can make printf output method without errors in printf code. teacher did not go on formatting simple example. public static void printreportheadings(int [] employeeid, int [] dependents, double [] hours, double [] payrate ) { system.out.println(" abc payroll system "); system.out.println(" employeeid " + " gross pay " + " federal tax " + " state tax " + " net pay "); (int = 0; <7;i++) { float gross; double federal =0.0; double state = 0.0; double net = 0.0; gross = (float)(hours[i]*payrate[i]); federal = .2 * (gross-(dependents[i]*38.46)); state = .032*gross; net = gross - (federal+state); system.out.printf("%-15d %.01f % 15f%n", employeeid[i], gross, federal , state, net) ; } you've got 3 placeholders , 5 things you're trying bind placeholders. observe: sy

jquery - Retrieve certain object from an array and act upon retrieval -

i hadn't received concrete answer previous thread: retrieve "id" array in jquery so i'll try explain in more detail , show did. i'm working on small game , have several obstacles in array so: obstacles = [ { id: '#car' }, { id: '#house' }, { id: '#door' }, ]; in second part of code, have: jquery: $('#alert').hide(); (index in obstacles) { object = $(obstacles[index]["id"]); obj_left = object.position().left + parseint(object.css("margin-left")); obj_top = object.position().top + parseint(object.css("margin-top")); if ((((posx > (obj_left - me.width() / 2)) && (posx < (obj_left + object.width() + me.width() / 2)))) && (posy > (obj_top - me.height() / 2)) && (posy < (obj_top + object.height() + me.height() / 2))) { // cannot walk return false; } // it's starts ug

javascript - How to use Angular JS with Leaflet.js -

i working on dashboard using node.js/leaflet.js. started learning angular js few weeks ago. @ medium step in project. i building interactive map dashboard using: node.js/express.js process data on backend leaflet.js map visualization other libraries d3.js. now, trying add widgets dashboard, click on points , fetch information related each point db using node.js. i'd simplify problem , consider example. http:jsfiddle.net/8qhfe/128/ when hover mouse on shape, chart related every polygon/point on map. i confused! question is: should re-create app embed leaflet angular js code, example link or use angular leaflet directive . read not stable library yet. is best choice use angular.js in such scenarios? so great question. struggle understanding how implement mapping packages angular. the plunker below shows 1 way of doing it, not sure "angular way". love hear other people weigh in. in last mapping application did not use angularleafle

java - how to create jar file? -

i trying create jar file .java program followed steps step 1. create 'mywork' folder step 2: put xyz.java , gson.jar file under mywork folder step 3. use javac -cp .:gson.jar xyz.class step 4. create jar file -> jar cf xyz.jar xyz.class step 5. create manifest.txt , modify include mainclass:xyz step 6. modify manifest.txt include classpath gson.jar step 7. run command-> jar cfm xyz.jar manifest.txt xyz.class argument1 argument2 when doing step 7 getting "java.io.ioexception: invalid header field" error where going wrong, please me solve problem. my manifest.txt like manifest-version: 1.0 class-path:gson.jar created-by: 1.7.0_06 (oracle corporation) main-class: xyz main method: public static void main(string[] args) throws exception { // enter values arguments string dirstr = args[0]; string logfiledirstr = args[1]; xyz data = new xyz(); data.method1(dirstr,logfiledirstr); } you need prefix value space

http status code 404 - 404 Errors on asp.net site -

i have asp.net website continually throws 404 errors. here couple of examples: > exception has occurred on website. message: file '/products/products/products/services/quote/quote/checkout/checkout/checkout.aspx' not exist. <<<< > '/products/products/products/services/products/quote/products/services/quality-assurance.aspx' <<<< we have products folder, not have '/products/products/products/ folder. it appears though concatenating real folders site together, putting on .aspx page site. any ideas may happening? and, how fix problem? thanks, tlf

html - Disobedient Div! (Not floating correctly) -

i trying put 2 divs next each other contain lists of buttons button below both of them having problems. have added float: left both nav-left , nav-right nav-right not next nav-left? lower button #lower not staying inside parent div of #container? here fiddle i have tried know fix (which not lot!) no avail. thank : ) here code: #container{width: 100%; border: 1px solid red;} #nav-left, #nav-right{width: 50%; border: 1px solid black; display: block; padding: 10px 0px 10px 0px;} #nav-left{position: relative; float: left;} #nav-right{position: relative; left: 50%;} #lower{width: 100%; border: 1px solid black; display: block; padding: 10px 0px 10px 0px;} li {list-style: none;} ul a, #lower {color: black; text-decoration: none; text-align: center; background-color: yellow; display: block; margin: 10px; padding: 9px; border: 1px solid black; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px;} ul a:hover, #lower:hover {background-color: #fff;} <div

introspection - How to check in Python from which class methods is derived? -

i have 2 classes: class a(object): def a(self): pass class b(a): def b(self): pass print dir(a) print dir(b) how can check class methods derived in python? for example: getmethodclass(a.a) == getmethodclass(b.a) == getmethodclass(b.b) == b interesting question. here how i'd go it. (this works in python2. haven't tested in python3, won't surprised if not work...) you can iterate on "nominees" using reversed(inspect.getmro(cls)) , , returning first (by fetching next value of iterator) satisfy condition has relevant attr , , attr same method of relevant cls . method identity-comparison done comparing im_func attribute of unbound method. import inspect def getmethodclass(cls, attr): return next( basecls basecls in reversed(inspect.getmro(cls)) if hasattr(basecls, attr) , getattr(basecls, attr).im_func getattr(cls, attr).im_func ) getmethodclass(a, 'a') => __main__.a getmethodclass(b, &#

mysql - php select records from database -

need : i have 4 columns in css/html, , need show records database (100 records) based on id number ( or sorted rows) following configuration : column1.......column2......column3......column4 ....id-1..............id-2..............id-3...............id-4 ....id-5..............id-6..............id-7...............id-8 ....id-9..............id-10............id-11..............id-12 ....id-13.............id-14...........id-15.............id-16 and on. from 100 records, every column have 25 rows respectively. the problems comes rule column1 should first filled out, continued next column. how can use php if condition rule? i have tried , found confused : <?php $row=0; foreach ($ads $ad) { $row++; if (($row==1) or ($row%4==0)) { ?> <div style="border: 1px solid #ddd; width: 200px; font-size: 10px; line-height: normal; padding: 3px; text-align: justify; margin-left: 5px;

c# - How to execute an URL with Windows Phone? -

i need execute url button in wp app: i tried code doesn't work more once: private void btnledon_click(object sender, routedeventargs e) { var request = httpwebrequest.create(new uri("http://192.168.0.1/?ledon")); request.begingetresponse(new asynccallback(ongettingresponse), request); } private void ongettingresponse(iasyncresult ar) { var req = ar.asyncstate httpwebrequest; var response = (httpwebresponse)req.endgetresponse(ar); var responsestream = response.getresponsestream(); } i don't need response just url executed led turn on/off. easier way or reset request work more once? you should use httpclient (check link) . it's modern approach http of modern .net framework , works better rest-style requests since you'll find direct shortcuts perform get, post, put, delete, head , other verbs' resource requests.

sql - Running PostGIS Commands on Clustered DB -

using postgresql in clustered database (stado) on 2 nodes, want test query: select id,position,timestamp table t1 id!=0 , st_intersects ((select st_buffer_meters(st_setsrid(st_makepoint(61.4019,15.218205), 4326) ,1160006)),position) , timestamp between '2013-10-01' , '2013-12-30'; when run in command line or psql (on coordinator), error: encountered ")" @ line 1, column 171. while other sql commands (insert, update, select... etc) working fine. geometry columns seems okay in table don't think there problem installing postgis. generally-speaking, don't buffer geometry proximity search. above attempt, 1 point geometry, in other queries potentially buffering geometries of table, make query expensive since need create new geometries , not able use indexes. use st_dwithin instead . st_dwithin geometry types use same distance units the spatial reference system. srid=4326, in degrees, not helpful in way. however, if position geograph

android - MySQL relation and entities -

i have 2 tables: place , discount n<->n relation. have table called place_discount has 2 foreign keys ( idplace , iddiscount ). when add discount place, e.g. discount bar, add in place_discount table. so issue is: have android app queries on database. when want list places have loaded, want show star on have discount. list select * place . there way query? tip: can not use triggers because not have super privileges. why not use join? select place.*, if(ifnull(min(place_discount.iddiscount),0)>0,1,0) hasdiscount place left join place_discount on place.id=place_discount.idplace group place.id will give 1 in hasdiscount if discount available, 0 if not. on side note: not need super privilege trigger on table own.

Bootstrap 3, Haml, and Rails 4 - Create dropdown from model attributes -

i have 2 models, notification , notificationpath . each notification has area attribute maps notificationpath areas. so notificationpath has_many notifications . i have following haml code in notification/new view: = f.input :area, :required => false, label: false, :autofocus => true, placeholder: 'notification area', input_html: { class: 'form-control' } this creates text field can type into, , functions correctly. however, want display dropdown of of available notificationpath areas. when select choice, dropdown box should filled selected text. how can using haml , bootstrap 3? use collection_select tag or select_tag create dropdown as: = collection_select :dropdown, :notification_id, notification.all, :id, :area, { allow_blank: "select area..." }, { class: 'dropdown_notification' } note have used dropdown first parameter instead of :notification or f.collection_select , because do not want parameter nes

firebase - list only items you have access to -

background i have set of items user may append to, may read/write items own. this simplified version of i'm working on. can't make $uid part of path because these items shared specific other users. "session": { "$other": { ".validate": "(!data.child('owner').exists() && newdata.child('owner').val() == auth.uid) || newdata.child('owner').val() == data.child('owner').val()", ".read": "data.child('owner').val() == auth.uid", ".write": "newdata.child('owner').val() == auth.uid" } } given above rules user may push({ owner: my_uid }) list. have verified user may read , write newly created record. question how can user find of records has access to? "session": { "index": { "$uid": { ".read": "$uid == auth.uid", "$sessionid": {

java - Updating list after insert new items through a JSP form -

in spring project, passing list jsp page controller in way: mav.addobject("tipos", tipo.listatipos()); mav.addobject("campos", atributo.listakey()); in jsp page, besides display items, can add new items too, demonstrated in code below (both html , jquery): html <table class="bordered campos" id="edit_campos"> <thead> <tr> <th>campo</th> <th>#</th> </tr> </thead> <tfoot> <tr> <td> <input type="text" name="nome_campo"> </td> <td> <button type="button" id="incluir_campo" class="btn btn-link">incluir</button> </td> </tr> </tfoot> <c:foreach var="item_key" items="${campos}"> <tr id="linha_${item_key.id}"> <td> <input type="text" name="${item_key.nome}" va

java - JRadiobutton ActionListener not responding -

i'm registering events 2 jradiobuttons, nothing happens! no errors thrown, i'm not being able trace problem.. when selecting first radio button, should print out text. when selecting second button, should print out different text.... import java.awt.flowlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class num2 extends jframe { private static jlabel type; private static jlabel days; private static jlabel amt; private static jradiobutton checkstandard; private static jradiobutton checkexecutive; private static jtextfield txtdays; private static jtextfield txtamount; private static jbutton btncalculate; private static buttongroup group = new buttongroup(); public num2(){ super("testing events"); jpanel p = new jpanel(); jlabel type = new jlabel("room type : "); jlabel days = new jlabel("number of days : ");

html - How to set up minimal vertical height for website? -

Image
here site - http://www.aspenwebsites.com/majesticpines/about/ i noticed if reduce height of viewport bottom area of sidebar (the 1 email subscription field) overlaps site's navigation. i wondering if there way set minimum height site, if reaches value shows scroll-bar on right , doesn't reduce further, email subscription form doesn't overlap navigation links. i tried set min-height:700px , overflow-y:auto body tag , .header-sidebar , didn't make difference. could advise doing wrong here? you use css media queries. // css queries inside @media applied when viewport height lesser 1001px @media screen , (max-height: 1000px) { // reduce menu paddings , margins here // example: .menu li { padding:2px 0; margin-top:3px; margin-bottom: 3px; } }

git - How do I use GitHub to create version 2 of a repository, but keep both versions active? -

i have repository small group of files in. script used number of live websites. i want create 'version 2' of repository, or make updates (e.g. version 2), key thing want introduce version 2 small number of live websites initially. would case of creating 'version 2' branch? doesn't sound right may want keep both versions around forever , see 'branch' arm developing feature - , merge in master when completed. i want websites using tried , tested original, whilst test new one. also, how ensure web server had files required 'version'? might mean setting git on web server downloads version, or there better way? imo, it's fine use branch alternate version. i'd suggest - create branch. to right version on "other" web servers simple git checkout version2 onto right branch (assuming you've got full copy of repo on each web server - if you're deploying in other way, you'll need give details...)

java - non-static method count(int) cannot be referenced from a static context -

this question has answer here: non-static variable cannot referenced static context 11 answers this n queens problem try solve ,but have problem of non-static method .. how can solve ..... * > @ count(int) method .. don't understand how solve problem error: non-static method count() cannot referenced static context import java.util.*; public class nqueens { static int n; int[][] board = new int[n][n]; public static void main(string[] args) { //int result; int col = 0; scanner input=new scanner(system.in); n=input.nextint(); if(n < 4) system.out.println("the result 0"); else count(0); } int cnt=0; void count(int col){ if(col == n){ cnt++; system.out.println("the result " + cnt); } else{ for(int row=0 ; row<n ; row++){ if(placequeen

awt - Java weird render on images -

allow me begin mentioning description may not understandable. have trouble finding words describe problem, compiled code executable jar may run try understand saying. here link: http://www.mediafire.com/download/r1n0ox8ioyzwb2n/work.jar as image moved (via arrow keys) direction image have weird effect. can describe effect image being drawn top left bottom right slow enough visibly noticeable. if had guess believe may have sleeping being done in game loop. here game loop , render method. public void gameloop() { final int fps = 60; int frames = 0; lasttime = system.nanotime(); long lastfps; lasttime = lastfps = system.nanotime(); init(); while (running) { long deltatime = system.nanotime() - lasttime; lasttime += deltatime; if (!frame.isfocusowner()||!isfocusowner()) update(deltatime); else{ updatefocus(deltatime); } // must setup these do-while loops according // buf

Configure Mac native Clang with Macports paths -

when compiling projects make use of libraries installed via macports (boost, opencv, etc) need pass clang library , include file locations via -i , -l arguments. is there "official" way direct apple native clang in these locations default. i guess make bash script effect of clang -i/opt/local/include -l/opt/local/lib %@ and call instead of compiler, there cleaner way point clang these locations automatically? i not looking xcode based fix, instead able compile command line without having manually type above arguments in each time. any suggestions? i had similar question answered on macports mailing list[0]. export these environment variables. export cppflags='-isystem/opt/local/include' export ldflags='-l/opt/local/lib' p.s. hope you've not been waiting long answer :) [0] https://lists.macports.org/pipermail/macports-users/2017-july/043562.html

sed - copying every nth line to a new line -

i have txt file need copy 1st line of every 4 lines , print onto 3rd line of every four. , print new txt file. e.g @cr5sm:00004:00029 ttttctctttctttctt + >>>/>@99419baaabb @cr5sm:00005:00026 attatagagggatag + ;969999999-4;bb change this: @cr5sm:00004:00029 ttttctctttctttctt +cr5sm:00004:00029 >>>/>@99419baaabb @cr5sm:00005:00026 attatagagggatag +cr5sm:00005:00026 ;969999999-4;bb i have tried using awk cant seem find correct commands this. have solutions? thanks using awk : $ awk '/^@/{a=substr($0,2)}/^\+/{$0=$0 a}1' file @cr5sm:00004:00029 ttttctctttctttctt +cr5sm:00004:00029 >>>/>@99419baaabb @cr5sm:00005:00026 attatagagggatag +cr5sm:00005:00026 ;969999999-4;bb you can redirect output file saying: awk '/^@/{a=substr($0,2)}/^\+/{$0=$0 a}1' file > newfile we use substr function capture lines start @ second character onwards until end of line. we lines start + (notice escape since meta-character). on

how to submit value to another page without using form tag [JAVASCRIPT] -

hii can me ? how submit value page without using form tag (method=post), using javascript. function runscript(e) { if(e.keycode==13){ var text=document.getelementbyid('edtsearch').value // bla bla must filled function submit value } return false } with jquery library: you can use jquery post request. $.ajax({ type: "post", url: url, data: data, success: success, datatype: datatype }); without library, plain javascript. window.location = "http://www.page.com"; //this page form=document.getelementbyid('formname'); //this fills form form.target='_blank'; form.action='whatever.html'; form.submit(); form.action='whatever.html'; form.target='';

Notepad++ change all 'xx' for 'xx++' -

have way numerate following text ('xx', 'link 001'), ('xx', 'link 002'), ('xx', 'link 100'); to ('001', 'link 001'), ('002', 'link 002'), ('100', 'link 100'), like while while($x = 001; $x <= 100) { $xx == $x++; } assuming text laid out exactly posted: ('xx', 'link 001'), ('xx', 'link 002'), ('xx', 'link 100'); the following regex search should work: find: '\w+', 'link (\d+)' replace: '\1', 'link \1' breaking down bit-by-bit you, ' - searches ' \w - searches alphanumeric character or underscore. + - instructs notepad++ find preceding sequence 1 or more times. in combination \w , looks 1 or more alphanumeric characters/underscores. match xx . ' - ' . @ point, we're looking ' , followed 1 or more alphanumeric

php - Complicated situation. Getting input name from ajax select dropdown for mysql data -

i have locations dynamic dropdown(country,region,city) done ajax. works great. my goal retrieve data(posts) mysql table, based on location selections. have posts in mysql table correspond locations. now issue having query won't retrieve data based on region , city. work $_get country. comes understanding reason because region , city queries in separate php files , called through js code in head section, unable use $_get method inputs. here form setup. <form action="" method="get" enctype="multipart/form-data > <div id="countrydiv"> <select id="country" name="country" onchange="showregion(this.value);"> <option value="0">--select country--</option> <?php $getcountry = db::getinstance()->query("select * countries"); if(!$getcountry->count()) { echo 'n

c++ - 2 Link Errors, 1 from a virtual functions, 1 from a derived class -

i'm getting lnk 2019 , 2001 error every time compile. lnk2019 states: public: __thiscall colmbr::colmbr(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0colmbr@@qae@iv?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@z) referenced in function "public: __thiscall alumni::alumni(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0alumni@@qae@iv?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@hhh0@z so there kind of error linking colmbr class alumni. lnk2011 says: "public: virtual void __thiscall alumni::addclass(unsigned int,unsigned int)" (?addclass@alumni@@uaexii@z) so there's issue virtual function call. understand lnk errors means there variable neede

integer - Having trouble casting a stack object number to int (Java) -

i'm writing program converts expression infix postfix. have conversion part down when comes evaluating postfix expression, run problems converting char int using stack. i keep getting error: "exception in thread "main" java.lang.classcastexception: java.lang.character cannot cast java.lang.integer" it might in part of code below problem i'm not sure: integer x1 = (integer)stack2.pop(); integer x2 = (integer)stack2.pop(); thank you! public class calc { /** * @param args command line arguments */ public static void main(string[] args) { system.out.println("please enter infix expression: "); scanner scanner = new scanner(system.in); string input = scanner.nextline(); string postfix = ""; stack<character> stack = new stack<character>(); for(int = 0; < input.length(); i++){ char subject = input.charat(i); if (subject == '*'||subject == '+'||subject == '-'||subject ==

uploading sql ddl file to postgresql database -

i relatively new working on databases. created sql file , want upload ddl (data definition language) file postgresql server. server runs on ubuntu 12.04. create database *; --create tables create table user( user_id varchar(36) not null, username varchar(36) not null, user_type varchar(36) not null, name varchar(36) not null, email varchar(36) not null, picture varchar(36) not null ); create table product( product_id varchar(36) not null, product_name varchar(36) not null, product_type varchar(36) not null, product_price varchar(36) not null, product_available varchar(36) not null ); create table transaction( transaction_id varchar(36) not null, user_id varchar(36) not null, product_id varchar(36) not null ); create table inventory( product_id varchar(36) not null, prod

php - Error on url rewrite .htaccess -

actually, i'm not fluent in use. htaccess file, following lines of code fetched me using internet. gets unexpected error. first bug: when entered http://localhost/giccos/wall/username (pretty showing , error when add rear .php moment http://localhost/giccos/wall/username?username=username , if can fix remain http://localhost/giccos/wall/username?username=usernames2312312s page time) how fix this? want kind of facebook, if add .php normal operation. and here mess: options +followsymlinks -multiviews rewriteengine on rewritebase /giccos/ rewritecond %{request_filename} -d [or] rewritecond %{request_filename} -s rewriterule ^.*$ - [l] rewriterule ^status/(.*).php status.php?status_id=$1 rewriterule ^hashtag/(.*).php hashtag.php?hashtag=$1 rewriterule ^wall/(.*).php wall.php?username=$1 rewriterule ^blog/(.*).php blog.php?url=$1 rewriterule ^verify/user/(.*).php verify.php?user=$1 rewriterule ^groups/(.*).php groups.php?groups_id=$1 #rewriterule ^life/(.*) $1.php rewrit

equivalent non-opensource database of postgresql -

actually have been asked not use open source databsae. so, have use proprietary database. doubt best equivalent proprietary database of postgresql , should cost effective. please give suggestion the decision maker here has weird ideas - not open source, don't care use long don't have source code? that's nuts . maybe don't understand open source licenses , confusing gplv3 the simple bsd/mit-like license postgresql under ? might have images of "open source" meaning kind of terrible viral license takes patents , forces them open source code touches (which isn't true of gplv3, btw). try sending them the wikipedia article , freebsd's article on license , , of openbsd . should read the osi faq . if they're still determined waste money after reading , doing little basic research, there's no saving them. in case, take postgresql source code, rename "proprietarydb", whack on restrictive all-rights-reserved license, , s

Regex to replace text between two strings c# -

i have following string : <span><style> .g9ct{display:none} .q-bv{display:inline} </style><span class="g9ct">74</span><span style="display:none">100</span><span class="g9ct">100</span><div style="display:none">100</div><span style="display:none">122</span><span class="g9ct">122</span><div style="display:none">122</div><span style="display:none">178</span><span class="g9ct">178</span><span class="165">189</span><span class="g9ct">202</span><div style="display:none">202</div><span style="display:none">214</span><span class="g9ct">214</span><div style="display:none">214</div><span style="display:none">230</span><div

Having trouble with Java exercise for University (Strings) -

so learning java @ university, , still @ beginner level bare me. have encountered problem describes following... given 2 strings, print true if either of strings appears @ end of other string, ignoring upper/lower case differences (in other words, computation should not "case sensitive"). ok have established need allow input of 2 strings. assume need if/else statement, if checks both strings see whether or not characters of other string occur @ end of string using ignorecase. if either string has characters of other string @ end, print true and else, print false. i know how input 2 strings, , implement if else statement, problem is, how scan string see if contains contents of string? , how specify has found @ end of string. ie. "hiabc", "abc" -> true "abc", "hiabc" -> true "abc", "abxabc" -> true

CSS Media query for different devices -

i have basic css 2 column layout. works fine desktop browser resize liquid layout. here code: html: <div id="wrapper"> <div id="headerwrap"> <div id="header"> <p>header part</p> </div> </div> <div id="contentliquid"><div id="contentwrap"> <div id="content"> <p>this body/content part</p> <div class="test"> </div> <div class="test"> </div> <div class="test"> </div> <div class="test"> </div> <div class="test"> </div> <div class="test"> </div> <div class="test">