Posts

Showing posts from June, 2012

oracle - Doing a calculation in sql without sum -

Image
i have table generated sql using inner join, want calculate total cost of each order_id, example screen shot shows 4 orders order id 127, want combine total costs of each ordered item 127 1 number, same other order ids. price in table haven't specified in query. i thinking of doing quantity* price, not sure how link order ids i've mentioned above. many help:) sql: select p.carrier_id, o.aircraft_id, o.order_id, o.quantity orderline o inner join purchaseorder p on o.order_id = p.order_id; my results far: you want use group by . need know rest of query give complete version, - roughly: select p.carrier_id, o.aircraft_id, o.order_id, sum(o.quantity) -- columns orderline o inner join purchaseorder p on o.order_id = p.order_id -- tables , join group p.carrier_id, o.aircraft_id, o.order_id; you might think need group order id, rule of thumb "group you're not counting (or summing...) also, pointed out other answer, if have record of prices,

Clojure: Require png-extract doesnt work with []'s? -

why work: (ns image-test.core (:gen-class) (:require (png-extract) [clojure.string :as string])) but fails: (ns image-test.core (:gen-class) (:require [png-extract :as png] [clojure.string :as string])) i thought [] ok in require. please edify. (:require (png-extract)) no-op, "succeeding" doing nothing. using parens here means you're starting prefix list, (:require (clojure set string)) require clojure.set , clojure.string ; since don't put namespaces after png-extract , it's not requiring @ all. using [] s correct, it's failing because there's wrong png-extract namespace: perhaps doesn't exist, or broken in way.

java - Big Decimal while loop -

i had while loop used integer converted big decimal since the value high , i'm unsure of how make while loop work big decimal instead of integer code follows. public string getsize() { bigdecimal size = new bigdecimal(mysize); int count = 0; string datatype = ""; while (size > 1000 ) { size = size.divide(size, 1000); count++; } switch (count) { case 0: datatype = "bytes"; break; case 1: datatype = "kb"; break; case 2: datatype = "mb"; break; case 3: datatype = "gb"; break; case 4: datatype = "kb"; break; } return size + datatype ; } the error @ line while (size > 1000 ) since method if size integer. can tell me method using big decimal size? i've had trouble coming it edit: solutions given , unrelated problem popped in division line im getting: "exception in thread "main" java.lang.illegalar

Drupal 7 multi-site install -

i have 2 domains , 1 sub-domain on single virtual host (web hosting company). have ssh access , can create symbolic links. question is: would matter of me creating symbolic link , copying files virtual host path , (if so) files need copied directory make work? for example: 3 domains example.com example2.com demo.example.com drupal installed on example.com . in /sites directory there 4 directories: all example.com example2.com demo.example.com example2.com , demo.example.com symbolic links actual paths on system. copying files these directories such settings.php , install.php , etc. a typical drupal install designed host multiple domains using same code base, in hosting provider point 3 domains same directory root of drupal install , not sites directory of drupal. if drupal file in example.com create symbolic link point exmaple2.com folder example.com's domain directory. in within example.com directory go sites folder , create example2.com fo

windows - trying to get absolute file path's from relative path's from CLI -

cd "c:\path\to\directory\" >nul & echo %cd% say run in c:\dir . i'd expect output c:\path\to\directory since that's if run each command individually , in succession. doesn't that. when 2 commands sorta concatenated outputs current path - eg. c:\dir . any ideas why? alternatively, ideas how can full path relative path via cli? if concenate 2 commands act code block , %variables% can't change value. have use delayed expansion: @echo off & setlocal enabledelayedexpansion cd "c:\path\to\directory\" >nul & echo !cd! output be: c:\path\to\directory

xcode - iOS app crashing every other launch, can't find error -

first time launch app, seems run fine. i'll hit stop button, work , when go launch again, seems crash before can load anything. press stop, hit run again, , works fine. until repeat process. this xcode highlighting error "thread 1:signal sigabrt". nothing useful here. int main(int argc, char *argv[]) { @autoreleasepool { return uiapplicationmain(argc, argv, nil, nsstringfromclass([pokerappdelegate class])); } } the debug console shows nothing besides (lldb) (so suppose stopping, not crashing @ point) so, when perform bt get: (lldb) bt * thread #1: tid = 0x1c03, 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal sigabrt frame #0: 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x99ea1b2f libsystem_c.dylib`pthread_kill + 101 frame #2: 0x04a7057b libsystem_sim_c.dylib`abort + 140 frame #3: 0x01dc0b4e graphicsservices`gsregisterpurplenamedport + 348 frame #4: 0x01dc069f graphicsservice

sql - Why won't my master table column increment in my trigger? -

i need create trigger keep track of number of times movie rented business blockbuster. need separate trigger insert, delete , update. the column tracks number of times rented called num_rentals , has datatype of int. column part of movies table has *movie_id (pk*), movie_title, release_year, movie_description, , num_rentals. customer_rentals table has item_rental_id(pk), *movie_id(fk*), customer_id. i searched , found similar thread here , tried using supplied answer, no avail. executed following string without errors saw no change in num_rentals column when inserted data either movie or customer_rentals table. doing wrong? create trigger dbo.tr_num_rented_insert on dbo.customer_rentals insert begin update m set num_rentals = num_rentals + 1 dbo.movies m inner join inserted on m.movie_id = i.movie_id ; end i added num_rentals field table later , need know how initialize field value 0 records in movies t

extjs - Tab Panel in Panel -

i trying place tabpanel in panel. tabpanel appears functionality broken. displays both tab's content @ same time , clicking different tabs nothing. how adding tabpanel var tabpanel = ext.create('ext.tabpanel', { fullscreen: true, layout: 'fit', defaults: { stylehtmlcontent: true }, items: [ { title: 'home', html: 'home screen' }, { title: 'contact', html: 'contact screen' } ] }); this.add([ toptoolbar, tabpanel, bottomtoolbar ]); solved missing fullscreen: true,

Programatically open a dialog as popup with jQuery Mobile -

so have page , dialog. when user click page button, 1 ajax request open dialog results. simple example without ajax: http://jsfiddle.net/rbbpx/ it works. dialog opens programatically. hides page content, showing dialog if it's page. know popup's can open dialogs in-page links, didn't point in how can programatically. tried change $.mobile.changepage() call that, didn't worked expected: $('#dialog').popup(); $('#dialog').popup('open'); how can show dialog in-page, popup? ever possible? thank in advance! in case use phonegap, there alert plugin: http://docs.phonegap.com/en/edge/cordova_notification_notification.md.html navigator.notification.alert("your ajax result here");

actionbarsherlock - Reference android.R.id.home on pre 3.0 devices -

is there easy way reference home button on devices running less 3.0? i can findviewbyid(android.r.id.home) on 3.0 , later fails work on older devices. don't need listen clicks, need location position view. for clarification i'm referring view: http://developer.android.com/guide/topics/ui/actionbar.html#home i don't know you're doing... sounds hacky :) getwindow().getdecorview().findviewbyid(android.r.id.home)

c - Logic of #define (microchip xc8 compiler) -

i started learning c pic programming , looking @ other people's code , @ includes files provided compiler, fundamental ones (xc.h, pic.h, pic specific headers...) , saw construct (it's found in pic.h) #define __delay_us(x) _delay((unsigned long)((x)*(_xtal_freq/4000000.0))) naturally works, have problems understanding underlying logic of it. understand #define "alias maker", tell compiler substitute code x y every time it's encountered in program. that's it, simple substitution. here see variable, input or argument (x), passed substitute don't how! if me have made function this, , see how useful construct can be, if find code delay macro unnecessarily made (maybe because author didn't know native _delay, or because i'm porting code form compiler) can redefine (hypothetical!) "wait(200)" point native "_delay(200)". question can explain me how construct works? x not declared, wouldn't treated simple character substitu

c# - Grouping related ICommands -

i'm new c# , first wpf project. following this tutorial (using implementation of relaycommand , attempting use mvvm. implementing clone of standard windows calculator. find way group functionality of similar buttons doing seems clumsy. for exmaple, here my xaml of 3 buttons <button content="_7" focusable ="false" command="{binding seven}" style="{dynamicresource numberbutton}" margin="0,134,184,129"/> <button content="_8" focusable ="false" command="{binding eight}" style="{dynamicresource numberbutton}" margin="46,134,138,129"/> <button content="_9" focusable ="false" command="{binding nine}" style="{dynamicresource numberbutton}" margin="92,134,92,129"/> here icommands those: public icommand 9 { { return new relaycommand(nineexecute); } } public icommand 8 { { return new relaycommand(eightexecute); } }

bash - Best to way to add up numbers by ids -

suppose have file, has 2 columns. 12,1 12,2 11,3 11,2 i want add second column first column. output should this 12,3 11,5 is there easy way on linux environments (on command line)? $ cat file 12,1 12,2 11,3 11,2 here awk approach: $ awk -f, '$1 { a[$1]+=$2 } end { (i in a) { printf "%s,%d\n", i, a[i] } }' file 11,5 12,3 and here 1 in bash : $ cat ./id.sh #!/bin/bash ifs=',' while read id value; [ -n "${id}" ] || continue (( a[id] += value )) done < file id in "${!a[@]}"; echo "${id},${a[${id}]}" done $ ./id.sh 11,5 12,3 they both work same principle - read line line field/input separator set , , assemble array indexed first column - values of second column summed up. when hard work done, print array back.

java - Insert value in textfield - struts2+liferay -

in jsp have code: ..... // userid long userid = com.liferay.portal.util.portalutil.getuserid(request); string username = com.liferay.portal.util.portalutil.getusername(userid , "guest"); %> <s:textfield name="user" value="<%=username%>"></s:textfield> i not able display in textfield username value. can me,please. thanks. scriptlets not allowed use struts tags. , cannot access the scripting variable username because it's not on value stack. make available create new variable in value stack has value of scripting variable. <s:set var="username"><%=username%></s:set> <s:textfield name="user" value="%{#username}"/> another approach not expected make use of known containers request accessible struts tags. <% request.setattribute("username", username); %> <s:textfield name="user" value="%{#request.usern

c - Forking with command line arguments -

Image
i building linux shell, , current headache passing command line arguments forked/exec'ed programs , system functions. currently input tokenized on spaces , new lines, in global variable char * parsed_arguments. example, input dir /usa/folderb tokenized as: parsed_arguments[0] = dir parsed_arguments[1] = /usa/folderb parsed_arguments tokenizes perfectly; issue wish take subset of parsed_arguments, excludes command/ first argument/path executable run in shell, , store them in new array, called passed_arguments. so in previous example dir /usa/folderb parsed_arguments[0] = dir parsed_arguments[1] = /usa/folderb passed_arguments[0] = /usa/folderb passed_arguments[1] = etc.... currently not having luck i'm hoping me this. here code of have working far: how i'm trying copy arguments: void command_line() { int = 1; for(i;parsed_arguments[i]!=null;i++) printf("%s",parsed_arguments[i]); } function read commands: void readcommand(char ne

c# - Match occurrences of a character before a control character, match zero if control character not present -

i working on functionality allow user specify "wildcarded" path items in folder hierarchy , associated action performed when item matches path. e.g.: path action ----------- ------- 1. $/foo/*/baz include 2. $/foo/bar/* exclude now example above, item @ $/foo/bar/baz match both actions. given want provide crude score of specificity of wildcarded path, based on "depth" first wildcard character occurs at. path depth win. importantly, * bounded forward slashes ( /*/ ) allowed wildcard (except when @ end /* ) , number specified @ various points in path. tl;dr; so, think regex count number of forward slashes prior first * way go. number of reasons, there no wildcard in path match of forward slashes zero. have got following negative lookbehind: (?<!\*.*)/ which works fine when there wildcards (e.g. 2 forward slash matches path #1 above , 3 #2), when there no wildcard naturally matches forward slashes. sure simple step match none

android - Image view to stretch fit table row width -

i have layout xml want imageview in second row stretch fit row view if possible , textview in first row stuck on left of screen , need in center. imageview being filled image taken camera, appreciated. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" > <tablelayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center" android:layout_weight="1" android:stretchcolumns="*" > &l

javascript - Give element id numbers then insert one at end -

i have changing number of divs , need specific div go @ end.... i'd somehow count number of divs using javascript or jquery, , insert specific div @ end... example <div class="message" id="1"> <div class="message" id="2">.... <div class="message" id="88"> then need final div number , add 1 gets inserted @ end <div class="message" id="89"> how accomplished? var lastid = $('div.message').last().attr('id'); $('div.message').last().parent().append('<div class="message" id="' + lastid + 1 + '">');

mysql - Spatial query using my SQL -

i writing 2 varchar formatted columns named 'lattitude' , 'longitude' point formatted column named 'coordinate' using statement below. "update table_name set coordinate = pointfromtext(concat('point(',table_name.longitude,' ',table_name.lattitude,')'))" i attempting spatial query on coordinate column using following statement. select id , coordinate table_name mbrcontains(geomfromtext('polygon(-126.728566 49.226434, -123.652395 23.586457,-56.679738 23.908252,-53.076223 55.243002)'), coordinate) according tool polygon in query covers entire u.s. know there points in table fall in u.s. still not getting results (note i'm getting null result not error). ideas i'm doing wrong? update. below updated attempt @ executing query per suggestion below. set @g1 = geomfromtext('polygon((23.586457 -123.652395,23.908252 -56.679738,55.243002 -53.076223,55.243002 -53.076223,23.586457 -123.652395))'); sel

java - Checking Chronometer Time from Another Class Shortcut -

i have chronometer in class apple. want check time chronometer @ in class banana. not want create chronometer in class banana, nor want make apple object in class banana. possible? thanks! let me know if can more specific. is there more 1 apple in (presumably) game? if there 1 can make chronometer public static member of apple , read within instance of banana. this: public class banana { public void foo() { system.out.print(apple.chronometer.printvalue()); } } if there multiple apple instances, need 1) put them sort container; 2) pass in, set, or construct instance of banana reference container; 3) access appropriate apple instance in container, , read chronometer's value, call methods, etc. if chronometer private member of apple, need provide accessor method can accessed code in banana instance.

Classes imported in servlet is not resolved in jsp -

in web project, have class a, class b (these classes in other project,but being imported successfully)which imported in compservlet.java . , there listcomp.jsp , importing compservlet.java. problem listcomp.jsp not able see class , b. it's giving error type not resolved type. imports not transitive. if class imports class b, , class c imports class a, class c doesn't automatically import class b. if need use class b without typing quelified name every time (com.foo.bar.b), need import it. it's simple that. that said, concur balusc. having java code in jsps ugly, , should avoided.

garbage collection - Why do I get java.lang.OutOfMemory Error? -

i have server handles requests via socket , spawns thread handle each request. why java.lang.outofmemoryerror , can fix it? force heapdump when out of memory happens. see can force generation of jvm crash log file? . use tools listed there narrow down memory leak: tool analyzing large java heap dumps

ios - titanium.py run fails with error when trying to get instance from custom framework -

hello need create ios titanium module. in case have add framework has other depended frameworks, corelocation,systemconfiguration , libz.dylib, dont think need add xcconfig except custom static library framework using other_ldflags=$(inherited) -framework mycustomframework. anyway, not problem mention cause might take part, problem when use shared instance, singleton, instance returned , while ofcourse custom framework stuff in background error when trying run [error] clang: error: linker command failed exit code 1 (use -v see invocation) [error] [error] error: traceback (most recent call last): [debug] file "/library/application support/titanium/mobilesdk/osx/3.1.0.ga/iphone/builder.py", line 1379, in main [debug] execute_xcode("iphonesimulator%s" % link_version,["gcc_preprocessor_definitions=log__id=%s deploytype=development ti_development=1 debug=1 ti_version=%s %s %s" % (log_id,sdk_version,debugstr,kroll_coverage)],false) [debug] file "/li

mysql - Use of Combobox in C# using SQL -

first of all, in advance answer. i'm complete noob inn c#, , far it's interesting, yet complicated. problem this: i connected sql database c#, display "name" column in combobox, need use "id" column. guess it's more understandable code. (i'm not going put code of connection, because think irrelevant). private void form1_shown(object sender, eventargs e) { conexion.open(); mysqlcommand cm = new mysqlcommand("select * tbestados", conexion); try { mysqldatareader dr = cm.executereader(); while (dr.read()) { combobox1.items.add(dr["nombre"]); } dr.close(); dr.dispose(); } catch (exception ex) { messagebox.show(ex.message, application.productname, messageboxbuttons.ok, messageboxicon.error); } conexion.close(); } private void button1_click(object sende

image - Creating sprites using php -

basically, have default css sprites stored in folder. want allow user upload images , append particular images @ end of default sprites can retrieve different purposes. how can achieve using php? you'll want use gd graphics library load individual images , create combined image. example, see http://sheldon.lendrum.co.nz/php-gd-library-css-sprites_416/08/ (i searched google "making sprites gd" , in top links). picking effective search keywords secret being programmer! ;-)

Struts 1 action not getting called within javascript function in jsp -

i using display tag display list onto table. trying have button delete row based on row id. id getting passed javascript function action not getting called. know value getting passed because when tested using alert output id within function, did. i ran firebug , saying form undefined what have display tag table: <form action="" method="post" id="mainform" name="myformbean"> <display:table requesturicontext="true" requesturi="/unavailability/loadunavailability.action?method=loadform" uid="mylist" name="requestscope.unavaillist" class="simple" pagesize="10" defaultsort="2" sort="list" cellspacing="0" excludedparams="*"> <display:column property="startdate" title="start date" width="18%" decorator="com.mhngs.util.displaytagdatewrapper" sortable="true" headerclass=&quo

regex - Regular expression replace in C# -

i'm new using regular expressions, and, based on few tutorials i've read, i'm unable step in regex.replace formatted properly. here's scenario i'm working on... when pull data listbox, want format csv format, , save file. using replace option ideal solution scenario? before regular expression formatting example. firstname lastname salary position ------------------------------------- john smith $100,000.00 m proposed format after regular expression replace john smith,100000,m current formatting status output: john,smith,100000,m *note - there way can replace first comma whitespace? snippet of code using(var fs = new filestream(filepath, filemode.openorcreate, fileaccess.write)) { using(var sw = new streamwriter(fs)) { foreach (string stw in listbox1.items) { stringbuilder sb = new stringbuilder(); sb.appendline(stw); //piecing list original format sb_trim =

sql - How to properly use a DataGridView in C# -

well, very, broad question. i've done lot of research, , i'm still confused. so, problem have little c# program connected sql database. through c# interface can insert data sql database (i know because checked in mysqlworkbench, , data there), want see it, edit, update , erase needed; , need use datagridview, so, complicated, i've seen lot of info, , confuses me lot more. i'm gonna almost-complete copypaste of c# program: private void form1_shown(object sender, eventargs e) { conexion.open(); textbox2.focus(); try { dataset ds = new dataset(); mysqldataadapter da = new mysqldataadapter("select cveestado, nombre tbestados", conexion); da.fill(ds, "filldropdown"); combobox1.displaymember = "nombre"; combobox1.valuemember = "cveestado"; combobox1.datasource = ds.tables["filldropdown"]; conexion.

c# - How can I open a CMYK tif image and read the pixels CMYK values? -

i have search around , can see many questions on converting values cant find library gives me cmyk values, can see examples rgb values? if there library can open cmyk tif files , this? one option use libtiff.net library (disclaimer: 1 of it's developers). library can provide access data in tiff without conversion of data. following methods might useful you: tiff.readscanline (generic access decoded not converted samples grouped in scanlines) tiff.readencodedstrip (the same above strips) tiff.readencodedtile (the same above tiles) there getting started tutorial , samples .

c++ - User defined hash function for unordered map -

i have defined own hash function unrorderd_map. unable search in container using find function. have tried debugging using print statement within hash function , generates same hash value generated while inserting key/value. great if point out error. using eclipse ide on windows , compiling -std=c++11 typedef struct tree node; struct tree { int id; node *left; node *right; }; class ownhash { public: std::size_t operator() (const node *c) const { cout << "inside_ownhash: " <<std::hash<int>()(c->id) + std::hash<node *>()(c->left) + std::hash<node *>()(c->right) << endl; return std::hash<int>()(c->id) + std::hash<node *>()(c->left) + std::hash<node *>()(c->right); } }; int main() { std::unordered_map<node *,node *,ownhash> ut; node * 1 = new node; one->id = -1; one->left = nullptr; one->right = nullptr; ut.insert({one,one}); node * 0 = new node; zero->id

javascript - Call a method when another one finishes -

i have function in javascript consists of ajax call. let's call search(); then have event onkeyup. in onkeyup event, have enterpressed() function. i want call function after search() finishes. i think callbacks won't here. here's code: function search () { ... } ed.onkeyup.add(function (ed, e) { if (e.keycode == 13) enterpressed(); } function enterpressed() { ... } callbacks way forward. either: bind keyup event handler in callback fires when search finishes or set variable (in scope both functions) , change value when search finishes. before doing in keyup handler, check value and, if hasn't changed, return immediately. (this assumes calling of enterpressed keyup function significant. if including of keyup code red herring shows want call @ other time as well then use callback directly).

javascript - Drawing a polygon with circles using java script canvas -

hi there way draw polygon circles using java script canvas, refer each circle object contains coordinates , index inside. want draw complete k-partite graphs visually. thanks the canvas works lot in ms paint. once draw circle on computer forgets circle , remembers pixels. need keep track of yourself: i haven't tested code below idea. hopefully helps started: http://blog.nihilogic.dk/2009/02/html5-canvas-cheat-sheet.html var canvas = document.getelementbyid("maincanvas"); var ctx = canvas.getcontext("2d"); var circles =[]; function addcircle(arg_x,arg_y,arg_rad){ var newcirc = {}; newcirc.x = arg_x newcirc.y = arg_y newcirc.rad = arg_rad circles.push(newcirc) } function redrawcirc(){ // loop through circles array , redraw entire graph // whenever changes for(var =0;i<circles.length;i++){ ctx.arc(circles[i].x,circles[i].y,circles[i].rad,0,math.pi*2); } }

c - Undefined reference using SLRE lib -

i using slre ( http://slre.sourceforge.net/ ) doing regex checking in c program. including headerfile , following: void checkregex() { struct slre slre; struct cap captures[4+1]; if(!slre_compile(&slre, "regularexpression") { printf("error"); } } i doing compiling command: gcc example1.c -o test.cgi -l. -lconfig , error: example1.c:(.text+0x1af3): undefined reference 'slre_compile' any ideas doing wrong? i looked @ library , consists of slre.c , slre.h compile like gcc slre.c -o slre.o -c gcc example1.c slre.o -o test.cgi -l -lconfig

c++11 - C++ 11 equivalent of java.util.ConcurrentHashMap -

i find myself writing mutex code in order synchronize read/write access std::unordered_map , other containers can use them java.util.concurrent containers. start writing wrapper encapsulate mutex, rather use tested library don't stuff threading. is there such library? intel produced library called threading building blocks has 2 such things: concurrent_hash_map , concurrent_unordered_map. have different characteristics , 1 or other suit needs.

TransBase, Select all tables containing a given column -

i need query statement list tables database containing given column name in transbase. thank in advance. select * syscolumn col inner join systable tbl on tbl.segno=col.tsegno col.cname '%col_name%'; that quick! might need in future.

ruby on rails - How to render devise/registration/new.html.erb files? -

i facing problem. want render registration , sessions new.htm.erb files in layout/application. have tried create partial both registration , sessions new.html.erb. i have tried above answer gives error. code: <%= render :template => "devise/registrations/new", :locals => { :resource => current_user, :resource_name => :user } %> error: undefined local variable or method `resource' #<#<class:0xbd605f0>:0xb221c5c> add application helper def resource_name :user end def resource @resource ||= user.new end def devise_mapping @devise_mapping ||= devise.mappings[:user] end

c - Grab one image frame from MJPEG stream -

i have videosec ip camera, , daemon running on embedded linux npe controler. daemon needs gram images ip camera, part implemented libcurl in standard way, , axis camera working fine: static size_t write_data(void *ptr, size_t size, size_t nmemb, file *stream) { size_t written = fwrite(ptr, size, nmemb, stream); return written; } void refreshcameraimage(char *target, char *url) { curl *image; curlcode imgresult; file *fp; image = curl_easy_init(); if (image) { fp = fopen(target, "wb"); if(fp == null) printf("\nfile cannot opened"); curl_easy_setopt(image, curlopt_url, url); curl_easy_setopt(image, curlopt_writefunction, null); curl_easy_setopt(image, curlopt_writedata, fp); imgresult = curl_easy_perform(image); if( imgresult ) { printf("\ncannot grab image!"); } } curl_easy_cleanup(i

exception - Android - Crash report notification -

how can show notification shows when application crashed (or service crashed), , if user click on it, send stacktrace email? saw applications that. make own class extending interface uncaughtexceptionhandler public class uncaughtexception implements uncaughtexceptionhandler { private context context; private static context context1; public uncaughtexception(context ctx) { context = ctx; context1 = ctx; } private statfs getstatfs() { file path = environment.getdatadirectory(); return new statfs(path.getpath()); } private long getavailableinternalmemorysize(statfs stat) { long blocksize = stat.getblocksize(); long availableblocks = stat.getavailableblocks(); return availableblocks * blocksize; } private long gettotalinternalmemorysize(statfs stat) { long blocksize = stat.getblocksize(); long totalblocks = stat.getblockcount(); return tota

fft - why DCT transform is preferred over other transforms in video/image compression -

i went through how dct (discrete cosine transform) used in image , video compression standards. but why dct preferred on other transforms dft or dst? because cos(0) 1, first (0th) coefficient of dct-ii mean of values being transformed. makes first coefficient of each 8x8 block represent average tone of constituent pixels, start. subsequent coefficients add increasing levels of detail, starting sweeping gradients , continuing increasingly fiddly patterns, , happens first few coefficients capture of signal in photographic images. sin(0) 0, dsts start offset of 0.5 or 1, , first coefficient gentle mound rather flat plain. unlikely suit ordinary images, , result dsts require more coefficients dcts encode blocks. the dct happens suit. there it.

Fetching Data with cURL (JavaScript, PHP, jQuery) -

i learning webdev , programming @ college, , want advance of courses, i'm learning on own. i'm trying figure out how apis work, , have found site habitrpg ( http://habitrpg.com ) has api works curl. i'm new in of this. i know how use curl without client, whether in php, jquery or javascript. here api of site https://github.com/lefnire/habitrpg/wiki/api thank much here's solution .try once ..... a php class habitrpg api. habitrpg

hyperlink - How to handle dom events in controller in extjs4? -

i working in extjs4, , getting stuck on how catch event on hyperlink. worked on couldn't solved. here code: view code ext.define('am.view.user.linkview', { extend: 'ext.panel.panel', alias: 'widget.link', title: 'my cool panel', html: '<div><a href="#" id="linkid">this link open window</a></div><br /> <label for="myinput">type here: </label><input name="myinput" type="text" value="" />', }); controller code ext.define('am.controller.users', { extend: 'ext.app.controller', stores: ['users'], models: ['user','book'], views: ['user.edit', 'user.list','user.create','user.linkview'], init: function() { this.control({ 'link': { afterrender: function(cmp)

jquery - widget CSS conflicts with site CSS -

i build widget website , add css dynamically on loading problem conflicting host website css file . following code widget has css file attached on loading : function main() { jquery(document).ready(function($) { /******* load css *******/ var css_link = $("<link>", { rel: "stylesheet", type: "text/css", href: "http://example.com/widget/green.css" }); css_link.appendto('head'); var txt; txt='<div id="wrapper">'; txt=txt+'<ul class="tabs">'; txt=txt+'<li id="fixtures_tab"><a href="#fixtures">hepsi</a></li>'; txt=txt+'<li id="live_tab"><a href="#live">canlı</a></li>'; txt=txt+'<li id="finished_tab"><a href="#finished">bitmiş</a&g

jquery - JavaScript - extremely confused on removing elements from Container -

Image
i'm making 2d, top-down zelda style web rpg single player in javascript. when player (purple shirt) walks near cat, "rescue" it... removes animalcontainer containerofanimals (thereby removing animalcontainer's bmp stage), , add id of animalcontainer rescuedtotal_array ... the weird thing is, in pic below, i'm able rescue animalcontainer2 , then rescue animalcontainer1 ... if go animalcontainer1 animalcontainer2 , throws uncaught typeerror: cannot read property 'id' of undefined` error. ... basically: working way: id 22, id 21 ->>> 1 thing notice element name doesn't change id... not sure why... broken way... may not able associate element name animalcontainer2 id? don't know how id , name disassociated that.. id in rescued array...: 22, element name: animalcontainer1, rescued array length: 2, elem index pos: 0, index: 0 id in rescued array...: 21, element name: animalcontainer1, rescued array length: 2, elem index

SQL Server : How to make a Insert Into with Condition -

how syntax make inserts conditions? example: verify if value want insert isn't in table? (considering column null) your description brief sounds want merge statement. http://technet.microsoft.com/en-us/library/bb510625.aspx which can used insert/update/delete based on if data exists or not in 1 statement.

python - Get all keys based on time in Redis -

how list of keys based on time in redis, or based on chronological key within dictionary, i.e.: get foo {"time":'thu aug 15 22:37:37 2013', "data":"etc"} and have "time" key within every 1 of redis entries. how fetch list sorted based on time, or better, time when keys created? redis keystore , isn't meant operated you're trying. 'time' key irrelevant redis json string stored in redis string(if i'm understanding correctly). basically, redis doesn't care what's in string, , if did, may full sql db. if absolutely have use time, include in key name. instance, want keys in august: redis 127.0.0.1:6379> mset foo_20130815223737 "{\"time\":'thu aug 15 22:37:37 2013', \"data\":\"etc\"}" foo_20130816123015 "{\"time\":'thu aug 16 12:30:15 2013', \"data\":\"etc\"}" ok redis 127.0.0.1:6379> keys

Windows Batch File and an FTP Datestamp -

i struggling grasp concept of writing batch files. hoping schedule .bat file download file timestamp on daily basis. setting scheduled task etc. straight forward, problem arises when try execute code take fixed part of filename , append datestamp identify appropiate file. from research have done still cannot code pick yesterday date in yyyymmdd format. eg. today 15th of august, batch identify file 20130814. exisitng (static) ftp batch code option confirm off option batch abort open ftp_name lcd "u:\xxxx\yyyy\zzzz" "loansummary__daily.xlsx" whereas batch consider.. get "loansummary__daily_" & yyyymmdd & ".xlsx" thanks. i don't think can dynamically build file names within ftp script. can dynamically build ftp script batch file prior invoking it. the simplest way create ftp script template has variable portion(s) represented environment variable delayed expansion. example !yesterday! refer environment variabl

css - Z-index issue on iOS Safari & Chrome -

Image
i'm having issue responsive dropdown menu, based on wordpress underscores theme. it looks okay on desktop not on ios safari including ipad , iphone. i've tried add z-index other divs doesn't work. please me. thanks. there fourth method, translate3d: -webkit-transform: translate3d(0,0,1px); transform: translate3d(0,0,1px); ios browsers support css3, can use safely.

actionscript 3 - Can you recreate a class with an instance of that class? -

i have database component i'm trying make general possible. possible accomplish this: take in custom class don't have definition recreate class locally foreign instance basically can't include definition of objects stored in database want database process raw data of whatever class passed in, store it, , able provide again object. ideally cast it's custom class when object gets database. it sounds asking serialization . serialzation in as3 possible through few different methods. recommend refer this article describes method quite clearly. to elaborate, once serialize object, send server , pair key in database. can serialize original object downloading server again.

java - Spring MVC encode request from Cp1252 to UTF-8 -

there post request controller json encoded in cp1252 . how can encode request body utf-8 ? use jackson pojo. try add filter web.xml: <filter> <filter-name>characterencodingfilter</filter-name> <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> <init-param> <param-name>forceencoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterencodingfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> i had similar problem , solved it.

Filter in a SQL view to make column show records with current year -

i tried find other questions may have answered nothing related i'm doing. making view has 2 joined tables in it. need records show have current year in date, when make report in visual studio, user able see has been done current year. have experience in access still trying figure out sql. you can use "year" function on datetime variable, this: select * tablename year(date) = 2013 or if current year needs dynamic: select * tablename year(date) = year( getdate() )

vb.net - Handle all of an array's events -

so have class contains few controls easy ui design , has custom event raised whenever combo box inside panel changed: public class batinputline inherits system.windows.forms.panel public event selectionchanged eventhandler protected overridable sub onselectionchanged(byval e eventargs) raiseevent selectionchanged(me, e) end sub private sub nameset(sender object, e eventargs) handles_cboname.selectedindexchanged playername = _playernames(_cboname.selectedindex) selectedindex = _cboname.selectedindex onselectionchanged(eventargs.empty) end sub an array of these declared , user inputs number according how many of these need on screen on new form. redim _batinputs(getnumberofbatsmen()) i want call sub procedure whenever selectionchanged event raised of instances of batinputline in _batinputs(). if try write handler e.g sub dosometing(sender object, e eventargs) handles _batinputs(0).selectionchanged error saying th

c# - Lost in generic classes and inheritance - any anyone lead me out? -

i hope not complicated. have working, wonder if best can be: i want use sql bulk copy class, , more specific overload takes idatareader. have data in several list<> need "translator". found 1 using extension methods - elegant, think! listed here: http://www.differentpla.net/content/2011/01/converting-ienumerablet-idatareader think excellent base build on?! the code shown there not complete, unnecessary overloads never called missing. added them notimplementedexception. completed version can found @ end. you use class calling asdatareader method on ienumerable<> or list<>, , pass number of columns in data, , function step on columns, this: list<nodedb> mylist = new list<nodedb>(); mylist.add(mynode1); mybulk.writetoserver(mylist.asdatareader(3, nodedb.getvalue)); the class nodedb has fields, , static(!?) method getvalue gets iterated position (!?) , column, , returns appropriate item: static object getvalue(nodedb nodedb, int i) {