Posts

Showing posts from August, 2012

python - What does pip do with the files in doc directory -

i'm newbie. downloaded markdown tar.gz file pypi. install using pip: root@machine:/home/user# pip install markdown-2.4.tar.gz unpacking ./markdown-2.4.tar.gz running setup.py (path:/tmp/pip-dv31i7-build/setup.py) egg_info package file:///home/irwan/markdown-2.4.tar.gz installing collected packages: markdown running setup.py install markdown changing mode of build/scripts-2.7/markdown_py 644 755 converting docs/release-2.1.1.txt -> build/docs/release-2.1.1.html converting docs/index.txt -> build/docs/index.html converting docs/release-2.1.0.txt -> build/docs/release-2.1.0.html converting docs/release-2.0.2.txt -> build/docs/release-2.0.2.html converting docs/reference.txt -> build/docs/reference.html converting docs/release-2.0.txt -> build/docs/release-2.0.html converting docs/cli.txt -> build/docs/cli.html converting docs/test_suite.txt -> build/docs/test_suite.html converting docs/siteindex.txt -> buil

php - Call to undefined function error -

i getting call undefined function error, when have defined function. here code: foreach($db->query("select * 'members' username = '$user'") $row) { echo "rank: ".get_rank_tag($user)."<br>"; } here class get_rank_tag() function include('password.php'); class user extends password { private $_db; function __construct($db) { parent::__construct(); $this->_db = $db; } public function get_rank_tag($user){ try { $stmt = $this->_db->prepare('select rank members username = $user '); $stmt->execute(); $row = $stmt->fetch(); if($row['rank']==0){return "<span class='label label-default'>default</span>";} elseif($row['rank']==1){return "<span class='label label-success'>vip</span>";} elseif($row['rank']==2){return "<span class='l

Framesize issue while minimising and maximising java swing -

i have set frame size of java swing application to: frame.setsize(700, 500); whenever maximise window, want ui elements adjust , take full application size. right when maximise, frame occupying full window remains blank, ui elements remain @ same position before. how should change code whenever maximise window, ui elements should occupy window ? this sample code can app, gridbagconstraint work re size need set weightx or weighty property non zero. import java.awt.*; import javax.swing.*; public class app extends jframe{ public app(string title){ super(title); gridbaglayout layout = new gridbaglayout(); gridbagconstraints constraints = new gridbagconstraints(); getcontentpane().setlayout(layout); constraints.anchor = gridbagconstraints.west; jlabel l1 = new jlabel("first name:"); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0;

iphone - iOS app image / icon bit depth -

it's first time posting iphone app apple. after research have not been able find out answer questions , don't want app bounced due silly thing. referring link below create images/icons: icons/image diamensions the 2nd last line on link says "the standard bit depth icons , images 24 bits—that is, 8 bits each red, green, , blue—plus 8-bit alpha channel." mean total bit depth should 32? i have of images in app bit depth less 32. question are there chances app rejected because of this? must have images/icons of bit depth 32? my last icons submitted described "24 bit" , didn't have alpha channel. app accepted. (it submitted , accepted in february of 2014) looking @ of our icons , screens, 24 bit. we've submitted half dozen apps 3 or 4 times each. none of them failed or questioned.

Mysql Merge 2 queries -

i trying merge below queries in single row such results come in same row. company_id common in both queries. need suggestion ??? 1st query: select c.id company_id, avg(datediff(cdr.created_at,cd.send_to_brand_date)) avg_time_taken_for_first_comment complaint3 c3, complaint3_details cd, complaint3_diary cdr, company c c3.id=cd.complaint_id , cd.send_to_brand=1 , c.id=c3.company_id , cdr.complaint_id=c3.id , cdr.id in( select min(id) complaint3_diary complaint_id=c3.id , user_id in( select id user3 user_type=2)) , c.id=351 , c3.created_at>='2014-01-01' , c3.created_at<='2014-01-30' , cdr.created_at>='2014-01-01' , cdr.created_at<='2014-01-30' 2nd query: select c.id company_id, avg(datediff(cs.created_at,cd.send_to_brand_date)) avg_time_closure complaint3 c3, complaint3_status cs

Update ClearCase view config spec with command line with changed load rules -

i have base clearcase snapshot view being updated automatically overnight based on config spec file using command cleartool setcs -overwrite -ptime d:\cs.cs the problem config spec load rules being changed , if run command ask confirmation update load rules r:\>cleartool setcs -overwrite -ptime d:\cs.cs cleartool: warning: 1 objects eliminated new config spec's load rules: "\qa\qtp" continue, , unload these objects? [no] so there way tell clearcase using command line automatically continue update without getting confirmation ? as mentioned in " batch script automate dos program options ", write right answer in file, , redirect command. cleartool setcs -overwrite -ptime d:\cs.cs < yes.txt that way, if command stops getting input, have immediately. you find similar approach in " how userinput without typing batch file ".

c++ - How does structure works? -

i confuse how structure works. ask how information stored in structure number via r[i]. how value quotient initialize? how value stored in quotient/ remainder in first place via r[i]. in advance! // file processing + array of structures // 1. create data file describe // property of struture // 2. transfer information stored in 1 // array of structures // 3. process array // 4. array output file #include <iostream> #include <fstream> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; // maximum size of array const int max = 100; struct rationalno { int numer; int denom; int quotient; int remainder; float value; }; // task 1 void createinputfile (fstream&, const char []); // task 2 int filetoarray (fstream&, const char [], rationalno []); // task 3 void processarray (ra

Node.js (npm) accessing files inside installed module -

i implementing node module , i'd users optionally able require files part of module. example : var m = require('my-module'); var foo = require('my-module/foo'); considering module structure : ./my-module +- lib | +- foo | | +- index.js | +- index.js +- package.json and basic package.json file : { "name": "my-module", "version": "0.0.1", "description": "my own super fun module.", "main": "lib/index.js" } note : unecessary keys omitted clarity, ex: dependencies , keywords , author , etc. how package.json can modified allow "feature"? change module structure this: ./my-module +- lib | +- foo | | +- index.js | +- index.js +- index.js +- foo.js +- package.json or better, change require('my-module/foo') require('my-module').foo of modules do. setting main in package.json wrong thing (becaus

URL returned a bad HTTP response code / 401 authorization required in Facebook Share -

here's tried facebook debugger tool: https://developers.facebook.com/tools/debug/og/object?q=http%3a%2f%2fdevstmaws.linesofphp.com%2fvideo%2findex%2f52f0fd544eab99ae28000106 scrape information: response code 401 fetched url http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106 canonical url http://devstmaws.linesofphp.com/video/index/52f0fd544eab99ae28000106 warning critical errors must fixed bad response code url returned bad http response code. warning errors must fixed missing required property 'og:type' property required, not present. notice open graph warnings should fixed inferred property 'og:url' property should explicitly provided, if value can inferred other tags. inferred property 'og:title' property should explicitly provided, if value can inferred other tags. urls graph api https://graph.facebook.com/1419346681640654 scraped url see our scraper sees url the url share is: http://devstmaws.linesofphp.com/v

c# - Text of the anchor tag passed to the controller -

is possible text of anchor tag passed controller? <a href="@url.action("searchstudent","home")">student information</a> this in view. when click link, want use "student information" (the inner text) in controller. how can programmatically? (no hard coding) i using c#. thanks in advance. you can pass routevalues . in view: <a href="@url.action("searchstudent","home", new { innertext = "student information" })">student information</a> in controller: public actionresult searchstudent(string innertext) { // thing. return view(); }

Perl Multiple Subroutines -

it may simple question perl expert - i trying run script should logically this> main { while (true) call sub call sub b call sub c } sub { go execute method whatever needs --- before next time method runs need wait atleast 60 seconds still want call method b in these 60 seconds. } sub b { go execute method b whatever needs --- before next time method b runs need wait atleast 60 seconds still want call method c in these 60 seconds in mean time. } sub c { go execute method c whatever needs --- before next time method c runs need wait atleast 60 seconds @ moment control should in main , wait first 60 seconds of expire sub can called } my question: q: best , optimized way can -? q: if put sleep 60 in each sub next sub not called till 60 seconds expire , delay overall processing. q: want 3 subs called every 60 seconds in sequential order q lastly if need call 2 subs in every 60 seconds , last sub every hour - how do it? comment - thought take utc variabl

python - Get Title and Description of external URL using Django -

i know how can extract title , metadescription of external site using it's url. i've found solutions not django/python. currently code adds link database , make go link after added , update entry corresponding title , metadescription . it nice able retrieve og tags such meta property="og:url . thank you. to access title or description of external site have 2 things. 1) need fetch html external site. 2) need parse html , title element , meta elements. the first part easy: import urllib2 opener = urllib2.build_opener() external_sites_html = opener.open(external_sites_url).read() the second part more difficult, need use external library parse html, library called beautifulsoup because has nice api. (it easy programmers use.) from bs4 import beautifulsoup soup = beautifulsoup(external_sites_html) # can tags of external site soup variable. title = soup.title.string however, important remember external site may respond when fetch it, wise make

how to repalce the bigger index of upper triangular matrix by lower index.and according to that want to change matrix label number. MATLAB -

i m having vector of detected speaker change point` scp=[10 25 43]; from made mtrix seg_result= start-time end-time speaker1 1 10 speaker2 10 25 speaker3 25 43 speaker4 43 end-time of audio wav(for ex: 50) after did homogeneous speaker clustering.result of matrix in lower triangular matrix zero,matrix follows, cluster_result= 0 -567 345 324 0 0 567 768 0 0 0 534 0 0 0 0 then detected negatives number in matrix. for i=2:length(cluster_result) j=(i+1):length(cluster_result) if cluster_result(i,j)<0 here value @ cluster_result(i,j),means distance value between speaker(i) , speaker(j),for ex:cluster_result(1,2) means distance value between speaker1 , speaker2. .now ones negative numbers cluster_result,i need following 1) index of negative numbers. 2) want replace j i,means want speaker2 should become speaker1.and want create(or u can replace previous seg_resu

asp.net - Retrieve data from one table that is not in another one -

sq = "select roomno,blockname roommanage roomno not in( select *from availableroom)"; ds = dc.filldata(sq); gridview1.datasource = ds.tables["t1"]; gridview1.databind(); there error: only 1 expression can specified in select list when subquery not introduced exist . how can solve this? in "not in" should return 1 column. try below code. sq = "select roomno,blockname roommanage roomno not in( select id availableroom)"; ds = dc.filldata(sq); gridview1.datasource = ds.tables["t1"]; gridview1.databind();

c++ - Using _wopen() under windows shell namespace extension -

i'm developing kind of windows shell namespace extension(ne). extension provides custom context menu element file , folders. among other things need create new file under ne. i'm trying create file like: auto flags = o_wronly | o_creat | o_trunc | o_binary | o_cloexec; auto fd = _wopen(l"c:\\test.txt", flags , 0666); i tryed use "\\?\" prefix: auto flags = o_wronly | o_creat | o_trunc | o_binary | o_cloexec; auto fd = _wopen(l"\\\\?\\c:\\test.txt", flags , 0666); anyway returned file descriptor negative , errno eacces - 'permission denied' missing? users cannot create files in c:\ (without elevation). the shell extension runs credentials of current user, cannot create files there.

javascript - Display Image in GridFS -

Image
i using gridfs-stream https://github.com/aheckmann/gridfs-stream & on displaying image gridfs. when reading data gives me following output. when append data <img src="data:image/jpeg;base64,(data)"> , image doesn't show. gfs // create read stream gfs... .createreadstream({ filename: 'error1.png' }) // , pipe express' response .pipe(res); output res :- edited :- i tried :- img.src = 'data:image/jpeg;base64,' + btoa(res); output rendered :- <img src="data:image/jpeg;base64,w29iamvjdcbpymply3rd"> no image shown. i use file stream demonstrate: var rstream = fs.createreadstream('test.png'); var bufs = []; rstream.on('data', function(chunk) { bufs.push(chunk); }).on('end', function() { // done var fbuf = buffer.concat(bufs); var base64 = (fbuf.tostring('base64')); res.send('<img src="data:image/jpeg;base64,' + base64 + '&qu

python - How do I connect mitmproxy to another proxy outside of my control? -

the process browser send request mitmproxy , generate request gets sent target proxy server isn't controlled us. proxy server send response mitmproxy relay response browser. how go doing this? you can -f flag mitmproxy, forwards proxy requests upstream server. take @ docs here: http://mitmproxy.org/doc/features/forwardproxy.html

php - Laravel redirect issue -

i using laravel 4. when "logged_in_id" found in session want continue parse through bellow written routes. route::get('/{anything}', function($anything) { if(!session::has('logged_in_id')) { return view::make('user.login'); } else { //continue check route::get written bellow routing } })->where('anything', '[a-za-z0-9\/?=]+'); if write redirect::to('/'.$anything) enters same route , keeps on redirecting in loop. there way solve problem? i create filter , apply routes need it. remember put first routes more restrictive , last more generic ones. see example: route::filter('logged_in', function() { if(!session::has('logged_in_id')) { return view::make('user.login'); } }); route::get('testing', array( 'before' => 'logged_in', function() { return view::make('user.testing'); } ));

javascript - making a noty notification a clickable hyperlink -

noty({ layout: 'topright', type: 'alert', text: 'number of alerts:'+count, template: '<div class="noty_message"><span class="noty_text"></span></div>', closewith: ['button'], dismissqueue: true, animation: { open: {height: 'toggle'}, close: {height: 'toggle'}, easing: 'swing', speed: 500 }, timeout: false }); is there way of making notification clickable hyperlink. have considered callback onclose() don't want notification close can't use this. there callback onclick ? or have way. putting hyperlink text? you make use of buttons option create button open url in new window. noty({ layout: 'topright', type: 'alert', text: 'number of alerts:'+count, template: '<div class="noty_message"><span class="noty_text"></span></div>', closewith:

java - Scanner - Ignore new line at end of file -

i need quitting when coming to/ignoring last new line in file reg.txt. of right error when reaches last line, containing nothing. public string load() { list.removeallelements(); try { scanner scanner = new scanner(new file("reg.txt")); while (scanner.hasnextline()) { string lastname = scanner.next(); string firstname = scanner.next(); string number = scanner.next(); list.add(new entry(firstname, lastname, number)); } msg = "the file reg.txt has been opened"; return msg; } catch (numberformatexception ne) { msg = ("can't find reg.txt"); return msg; } catch (ioexception ie) { msg = ("can't find reg.txt"); return msg; } } sample reg.txt: allegrettho albert 0111-27543 brio britta 0113-4

java - Two RadioGroups with only one selected RadioButton in each of them -

i have 2 radiogroups in layout. want 1 radiobutton should checked @ time in radiogroup. i've tried many methods, none of them work properly. can check every radiobutton in radiogroups. public class mainactivity extends actionbaractivity implements view.onclicklistener, radiogroup.oncheckedchangelistener { string x; char y; int c=1; string num,n,type; int d,b,o,h; string dec,bin,hex,oct; edittext number; edittext result; button convert, clear; radiogroup rgfrom, rgto; int convertedresult; int from=r.id.r10from; int to=r.id.r2to; string stnumber; //liczba przed przeliczeniem - string int numbresult; //już int string iterresult; //liczba po przeliczeniu - string int convresult; //już int //int id = ((radiogroup).findviewbyid( r.id.rgfrom )).getcheckedradiobuttonid(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); initialize(); } private void initialize() { n

r - Getting a vector of differences of a vector -

suppose have vector v of length n ; wish create new vector of length, contain na in first k cells, , in cell number m contain difference v[m]-v[m-k] . i can create for-loop accomplishes task: diffs <- rep(na, length(v)) (i in k+1:length(diffs)) { diffs[i] <- v[i] - v[i-k] } but i've heard loops in r slow, , looks bit cumbersome that. actually, goal create list of diff vectors , not single 1 - 1 each k in range. loops solution? example on input v <- 1:5 , k=2 i'd expect output [1] na na 2 2 2 (however, turns out, output of snippet above [1] na na 2 2 2 na na ...) ?diff vec <- data.frame(v=c(1,3,5,15,21)) vec$dif <- c(na, diff(vec$v, lag = 1, differences = 1)) > vec v dif 1 1 na 2 3 2 3 5 2 4 15 10 5 21 6 for other lag interval or magnitude of differences, change lag , differences arguments accordingly

javascript - Move a object (this case a ball) with acclerometer in JS and Cordova -

i'm trying move ball accelerometer. i'm stuck getting ball moved. i values of accelerometer, how combine them ball can move? waiting accelerometer... <div id="heading">waiting heading...</div> <div id="ball"></div> <script src="cordova.js"></script> <script src="static/js/app.js"></script> #ball { display: block; border-radius: 50%; width: 50px; height: 50px; background-color: rgb(0,0,0); color: rgb(0,0,0); } //self-invoking anonymous function (function () { 'use strict'; // watch id references current `watchacceleration` & 'watchheading' var watchid = null; // initialize app controller object literal var app = { // init method, cordova ready used init: function () { accelerometer.begin(); compas.begin(); }, } var accelerometer = { begin: function () { // update accelera

jquery - FullPage.js - add active class to menu anchor when on a nonematching section -

okay, title might bit hard understand, i'll try , explain. so i'm using fullpage.js i have in total 9 sections: home about(about has 6 "undersections" continuation of first section) contact in menu there 3 navigation options home, about, contact. i've made menu active class added when on corresponding section - done ready made options. when scroll , leave first section active class remove , menu item not highlighted. here's thing want active class remain on "undersections" of about. menu item "about" highlighted until contact section. i thought i'd make work "outside" js depending on url class added anchor id "all-about": $(document).ready(function () { if (location.href.match(/#about1/ig) || location.href.match(/#about2/ig)){ $('#all-about').addclass('active'); } }); this not work. in fullpage js change or how change code work? thanks

html - css align ul to form -

Image
hi i'm doing live search ajax. want align form , ul. here form <div align="right"> <form method="post" action="" id="search" class="kb-search"> <input type="text" id="kbsearch" name="kbsearch" placeholder="knowledge base" autocomplete="off"> <input type="hidden" name="action" value="searchkb"/> </form> <ul id="results"></ul> </div> and here css .kb-search { width: 250px; } #results { text-align:left; width: 250px; background: #ffffff; padding: 5px 10px; max-height: 400px; overflow: auto; position: absolute; z-index: 99; border: 1px solid #a9a9a9; border-width: 0 1px 1px 1px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3); -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3); -box-shadow: 5px 5px 5px rgba(

python - How to set Postgres username and password in the Flask Peewee ORM? -

i'm building website using python flask framework , peewee orm , postgresql database. worked fine when developing on mac. moved installation ubuntu 12.04 desktop testing on linux , run trouble postgresql. on mac, postgres server didn't seem require user , password (good devving, bad production). on ubuntu says operationalerror: fatal: role "kramer65" not exist kramer65 normal username in ubuntu , should obvious postgres doesn't know it. can log psql using postgres user, don't know how add peewee. i've got config file in have: database = { 'name': 'mydb', 'engine': 'playhouse.postgres_ext.postgresqlextdatabase' } i tried adding 'password': 'mypassword' , 'username': 'myusername' it, says operationalerror: invalid connection option "username" . any idea how can add username , password peewee connect postgresql database? tips welcome! i never heard of

google gdk - How can I know Glass is connected to wifi and battery is charging -

i'm developing needs upload whole load of images, think it's better when glass both connected wifi , battery charger. also, if in idle mode it'll best. where can put image upload code requirement fulfilled? as mentioned in comment, should same other android devices. you can try this: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); card card = new card(this); card.settext("wifi " + mainactivity.iswificonnected(this) + " charger " + mainactivity.ischargerconnected(this)); setcontentview(card.toview()); log.v("test", "wifi " + mainactivity.iswificonnected(this)); log.v("test", "charger " + mainactivity.ischargerconnected(this)); if(mainactivity.iswificonnected(this) && mainactivity.ischargerconnected(this)) { // whatever... } } public static boolean iswificonnected(context context) { conne

javascript - failed to load / invalid sound zero-length duration reported chrome, firefox -

failed load / invalid sound zero-length duration reported chrome,firefox result in ie10. in other browser, shows error message "failed load / invalid sound zero-length duration reported" my code below foo = soundmanager.createsound({ id: 'bar', url: '../music/_mp3/xx02.mp3' }); try check flash version , if necessary update @ flashversion: 9 if doesn't work, it's possible you're using mp3 encoded in particular way browser can't read. so try encode again mp3 file in standard way. (i've solved same issue in way) source: https://getsatisfaction.com/schillmania/topics/zero_length_duration_reported_in_firefox_ie9_but_not_webkit

initialization - c++ member array not initialized -

i have following constellation: class base {...}; class derived : public base { public: unsigned int* a; derived(size_t num = 1) : a(0), _b(0) { = new unsigned int[num]; _b = new unsigned char[num]; } private: unsigned char* _b; } all fine doing this: derived* instance = new derived(); but doing this: base* instance = new derived(); _b stays 0x0 , errors occur later when try use _b. what happening here? update: the problem caused windows / linux cross platform issue - values filled incorrect pointers. first: why need initialize a , b twice? use explicit initialization only, or standard member initialization not both... derived(size_t num = 1) : a(new unsigned int[num]), _b(new unsigned char[num]) { } this should trick. second: if create instance of derived base , members , functions of derived useless. except members , functions of base, common in both classes.

Generic Web Service client in java -

i have list of wsdl urls in text file. have invoke of these wsdl in java program. each wsdl has 1 opertaion. tried create webservice client in netbeans 1 wsdl url. want have generic client. kindly suggest api(jar) , easy tutorial doing this. perhaps this project suitable. have never used seems have instructions , therefore call in loop, giving wsdls argument. hope helped!

how to escape values for writing a CSV file using C language -

i working on project write data csv file. how escape values writing csv file using c language. void writetofile(struct radatastructure data) { file *fp; fp = fopen("result.data", "a"); fprintf(fp, "%s,", data.long); fprintf(fp, "%s,", data.lat); fprintf(fp, "%s,", data.city); fprintf(fp, "%d,", data.pobox); fprintf(fp, "%s,", data.bio); fprintf(fp, "%d,", data.bnumber); fclose(fp); } the filed data.bio may contain character including comma, quote , slashes. how can escape before writing file make valid csv file. this should give starting place. note need free() value returns when done it. char* escapecsv(char* in) { int in_len = strlen(in); char *out_buf = malloc(in_len*2+3); int out_idx = 0; int in_idx = 0; out_buf[out_idx++] = '"'; for(in_idx=0; in_idx < in_len; in_idx++) { if(in[in_idx] == '"') {

From PostgreSQL to Postgis -

i've got trouble here. have 2 tables in postgres columns 'lat' , 'lon'. how convert them postgis geom(point) , calculate distance between points? i'm newbie, me please :) in general, see answer (or this one ). -- add spatial column epsg:4326 (wgs84) alter table some_table add column geom geometry(point, 4326); -- use coordinates create point geometries update some_table set geom = st_setsrid(st_makepoint(lon, lat), 4326); then calculate distances of each point point, use this: select t1.gid, t2.gid, st_distance(t1.geom, t2.geom) some_table t1, some_table t2 t1.gid > t2.gid; be aware distance cartesian, based on degrees, non-sense. consider either using geography type (instead of geometry ) distance result in metres, or use st_distance_sphere or st_distance_spheroid geometry .

python - How to plot Counter object in horizontal bar chart? -

i have counter object. i'd plot horizontal bar chart http://matplotlib.org/examples/lines_bars_and_markers/barh_demo.html how can that? this example page mentioned modified use counter object: """ simple demo of horizontal bar chart. """ import matplotlib.pyplot plt; plt.rcdefaults() import numpy np import matplotlib.pyplot plt # counter data, counter counter object keys = counter.keys() y_pos = np.arange(len(keys)) # counts each key, assuming values numerical performance = [counter[k] k in keys] # not sure if want :s error = np.random.rand(len(keys)) plt.barh(y_pos, performance, xerr=error, align='center', alpha=0.4) plt.yticks(y_pos, keys) plt.xlabel('counts per key') plt.title('how fast want go today?') plt.show()

ruby on rails - Refactor repetitively progress-bar's code segment -

i showing progress bar user tasks needs finishing profile. i have code-segment on several html.erb files: <% if progress < 100 %> <div> <div class="progress progress-info progress-striped active"> <div class="bar" style="width: <%= progress %>%"></div> </div> <div align="right"><u>next</u>: <%=link_to nextusertask, determinedpath %></div> </div> <% end %> i think ugly repeat code on these files. there way refactor this? example putting application_helper... i tried not sure how handle html in there. thanks you put in partial, example shared/_progress_bar.html.erb , render with: <%= render 'shared/progress_bar', progress: progress, nextusertask: nextusertask, determinedpath: determinedpath %> more partials: http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials

android - How to override setImageResource correctly so that it keeps the rotation of an ImageButton? -

i have created custom view class extends imagebutton. did because there new button class allowed me animations. the actual problem have following: when click on button, want change image drawable. however, when set new image this private void setcustombuttonicon() { if (menabled) { mycustombutton.setimageresource(r.drawable.mybutton_off); } else { mycustombutton.setimageresource(r.drawable.mybutton_on); } } then rotation had, since may have been rotated during animation, not preserved. now, obvious idea override setimageresource in custom button class. how can rotation of button preserved? i think problem related issue: most likely, using animation class animations. used rotationanimation superclass, did rotateanimation animation = new rotateanimation( fromdegrees, todegress, pivotx, pivoty); and applied animation custom button. however, turns out, only animates bitmap representation of button. or, in other words, actual b

cmd - MSYS sh.exe breaks when trying to make -

i ran msys's sh.exe , tried make, after g++ execution got cmd.exe window. here screenshot: https://dl.dropboxusercontent.com/u/11635312/%d0%91%d0%b5%d0%b7%d1%8b%d0%bc%d1%8f%d0%bd%d0%bd%d1%8b%d0%b9.png how can solve problem? thanks.

bash - cd in pipe after getting folder path -

when run command, folder of local gem installed: e.g. bundle show gem /users/user/projects/project/vendor/cache/gem-856752cd48f0 can use pipe cd folder path? e.g. bundle show gem | ??? what replace question marks with? you can use cd output of command: cd "$(bundle show gem)" if want pipe, make use of xargs this: bundle show gem | xargs cd

html - 3 divs next to each other of size 100% with another one as background that contains fluid photos -

i want create web page has photo background, background 300% screen wide , in every 33.33333% there photo centered responsive can maintain ratio aspect. my html code: <!doctype html> <html> <head> <title>aj</title> <link href="design.css" rel="stylesheet" type="text/css"> <body/> <div id="background"><img src="background.png"/> </div><!--these background image should displayed behind other 3 images 1523x993 , don't know how make stretch 3 time size of of window --> <div id="dvscreen1"><img src="2(1).png"/></div><!--these 1 of 3 photos displayed above background image, want make centered in window , responsive if window height changes wide should change , position should remain centered won't display next photo if user makes height of window small , wide large --> <d

php - Need to fetch table so that every row has Primary ID for key (ZEND) -

need fetch database in order can key primary key of feched table (or column select point out). example select id, name account; array( 0 => array(id => 12345, name => dude), 1 => array(id => 12356, name => other dude) ) and need is array( 12345 => array(id => 12345, name => dude), 12356 => array(id => 12356, name => other dude) ) thanks! if not tied zend_db_table can use more direct approach , more control on queries. $db = zend_db_table::getdefaultadapter(); $select = $db->select()->from('users',array('id', 'login')); //select id, login users $result = $db->fetchassoc($select); //this magic happens if can array can transform using function: /** * transforms associative array 'id'=>$column (or 'id'=>array(columns)) * @param array $array - associative array * @param string|array $value - column use value (or array of columns) * @param string - optional colu

vector - Save selected regions on jvectormap -

i using jvectormap. this exact concept used in program . please check link first. this test map link (cant upload here) http://test.rst-mt.com/screenshot.png i want save/hold on name of region. ticket system selecting seats(multiple select allowed). want process php , mysql(selected seats , pricing). want way know have selected can read php , can process it.

drupal 7 - JQuery class check on mouseup -

Image
i have following code works when detecting mousedown , mouseup. problem begins within mouseup trying check if target element has class. the code within if-statement never executes. $(this).find('td:first a.tabledrag-handle').mousedown( function(){ $(this).mouseup( function(){ console.log('mouseup detected'); $(this).parents('tr').css('background', 'red'); if( $(this).parents('tr').hasclass('drag-previous') ){ console.log('dragged'); $(this).parents('tr').css('background', 'blue'); } } ); } ); the if( $(this).parents('tr').hasclass('drag-previous') ) ... code never executes. can suggest better technique or work around solve problem, please? update: what i'm trying achieve detecting drag-&-drop events on foll

asp.net - Unable to pass custom datatype as parameter to wcf service -

i created 1 custom library project , have employee class hold employee information. namespace test.samplelib { public class employee { public string employeename { get; set; } public double employeesalary {get; set; } } } i added employee class library wcf service public test.samplelib.employee getdatausingdatacontract(test.samplelib.employee composite) { return composite; } i tried consume service , access method getdatausingdatacontract() servicereference1.service1client objserviceref = new servicereference1.service1client(); test.samplelib.employee objemployee = new samplelib.employee(); objemployee.employeename = "kumar"; objemployee.employeesalary = 30000; objserviceref.getdatausingdatacontract(objemployee); //gives errror the error is 'argument 1: cannot convert 'test.samplelib.employee' 'test.web.servicereference1.employee' you need have [datacontract] , [datamember] attributes on c

javascript - no command 'gulp' found - after installation -

after installing gulp.js via npm receive no command 'gulp' found error when running gulp command same directory installed into. when looking under node_modules/.bin/ directory can see gulp executable there. is there wrong npm installation? that's normal. if want gulp-cli available on command line, need install globally. npm install --global gulp-cli see the install instruction . also, node_modules/.bin/ isn't in $path . automatically added npm when running npm scripts (see this blog post reference ). so add scripts package.json file: { "name": "your-app", "version": "0.0.1", "scripts": { "gulp": "gulp", "minify": "gulp minify" } } you run npm run gulp or npm run minify launch gulp tasks.

symfony - Custom ExceptionListener picks up 403 & 404, but not 500 errors -

Image
exact same problem unanswered question symfony 2.4: why 500 errors not caught kernel.exception listener . i have implemented custom exception "handler" works awesomely 403 , 404 issues, 500 errors (which want handle, want send email myself system when happens) not trigger custom "handler" , continues behave if custom "handler" not there. code relatively straight forward: extract app/config/config.yml: services: core.exceptlistener: class: pmb\licensingbundle\listener\exceptionlistener arguments: ["@service_container", "@router"] tags: - { name: kernel.event_listener, event: kernel.exception, method: onkernelexception, priority: 200 } entire \pmb\licensingbundle\listener\exceptionlistener.php: <?php namespace pmb\licensingbundle\listener; use symfony\component\httpkernel\event\getresponseforexceptionevent; use symfony\component\httpfoundation\response; use symfony\component\http

c++ - What could be the format specifier for the below program? -

void task(task100ms_raster) { int a,b,c; struct timespec start, stop; uint32 starttime, stoptime; uint32 duration100ms; if( clock_gettime( clock_realtime, &start) == -1 ) { perror( "clock gettime" ); } starttime =start.tv_sec + 0.0000001 * start.tv_nsec; printf("start time %lu", starttime); printf("value %d",c); printf("etas1\n"); if( (stoptime = clock_gettime( clock_realtime, &stop)) == -1 ) { perror( "clock gettime" ); } stoptime = stop.tv_sec + 0.0000001 * stop.tv_nsec; printf("stop time %lu", stoptime); duration100ms = stoptime -starttime; printf( "time difference is= %lu\n", duration100ms ); } i created timer calculating start time, stop time , difference between time. confused format specifier start time, stop time , suration100ms. struct timespec start, stop; of type http://www.qnx.com/developers/docs/6.3.0sp3/n

Converting java JSONObject to javascript -

i have jsonobject i'm sending through ajax. jsonobject obj = new jsonobject(); obj.put("nblike", result); obj.put("username", "bill"); then in success function want access obj properties . eg : username i'have tried json.parse(obj) got error : uncaught syntaxerror: unexpected token ' server side log shows : {"username":"bill","nblike":1} //log.info(obj) client side log show : ['username':'bill', 'nblike':1] //console.log(result) i'd : console.log("username : " + obj.username) thank you convert jsonobject string before sending frontend , add "application/json" content-type of response. can use simple js object, don't need convert it.

c++ - how to insert a vpii in vector<vector<pair<int,int> > > -

how insert vector pair in vector< vector < pair < int,int > > > i beginner of stl please me this how insert vpii in vector<vector<pair<int,int> > > : vector<vector<pair< int,int> > > vvpii; pair<int, int> pii(1, 2); vector<pair<int, int> > vpii; vpii.push_back(pii); vvpii.push_back(vpii); // or if compiler supports c++11, // can use brace-enclosed initializer lists vvpii.push_back({ // vector initializer {1, 2}, // pair initializer {2, 3}, // pair });

java - Who can access to method with @PermitAll annotation -

framework (spring + jpa + ejb3 + hiberrnate + jboss5 + jaas) i want know, if method on ejb3, have @permitall(javax.annotation.security.permitall) annotation accessible roles defined on application security constraint or accesible roles of applications deployed @ server too. regards! it means any one (even without role) can access methods. second option right (by roles of applications deployed @ server too.)

android - ExpandableListView custom design -

Image
i want customize expandablelistview, can't customize childs. how can make border , fill background (example below src code) what have: expandablelistview <expandablelistview android:id="@+id/explistviewservices" android:layout_width="match_parent" android:divider="@color/white" android:dividerheight="10dp" android:childdivider="@color/white" android:layout_height="match_parent" /> list_fragment_services_groups.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:paddingleft="50dp" android:background="@drawable/expandblelistview_background" android:paddingtop="10dp" android:paddingbottom="10dp" android:layout_height="wrap_content"> <imageview android:layout_width="wrap_content"

c++ - why my admob doesn't show? -

there no errors in console, , seems work. bannerview_ didn't show. here admobobject.h #import "admobobject.h" #import "rootviewcontroller.h" #import "gadbannerview.h" @class rootviewcontroller; @class gadbannerview; @interface admobobject : uiviewcontroller{ rootviewcontroller * viewcontroller; gadbannerview * bannerview_; } + (admobobject *) shared; - (void) addadmob; - ( void) hideadmob; @end here admobobject.mm #import "admobobject.h" #import "appcontroller.h" #import "rootviewcontroller.h" #import "eaglview.h" #import "cocos2d.h" @implementation admobobject static admobobject* instance; +(admobobject *) shared{ @synchronized(self){ if( instance == nil ){ instance = [[self alloc] init]; } } return instance; } - (void) adda

bootstrapping - Error in copying jars to /home/hadoop/lib emr -

i copying external jars /home/hadoop/lib directoy in emr bootstrap process. showing following error during bootstrap process exception in thread "main" java.lang.incompatibleclasschangeerror: class com.google.common.cache.cachebuilder$3 has interface com.google.common.base.ticker super class @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:792) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:449) @ java.net.urlclassloader.access$100(urlclassloader.java:71) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclas