Posts

Showing posts from July, 2010

Using the Google Users Service with jQuery Mobile -

i wondering better way let jquery mobile app "know" user of app after completing registration process.since handlers in python google app engine app expect username, decided store username in localstorage , use part of request made server.but don't think design idea (?).after lot of search, have found jquery mobile not support google login (please correct me if wrong) have decided use users service server end.i confused on how implement this, since users service google has it's own sign-in form. possible use same service jquery? if so, can change design of sign-in form blend in design of jquery app? jquery mobile template designer created directly mobile web applications using mobile web browser. not possess connections server side scripting automatically. you need create connection using server side scripting. once login in using google login, app associates google account. jquery browser scripting. not have automatic connection server unless co...

callback jquery plugin printThis -

i trying find solution using search , google, couldn't find , hope can me. i'm using printthis plugin print parts of page (in case div=modal dialog). plugin-page: https://github.com/jasonday/printthis after print-dialog called , printed document want close modal dialog automatically, therefore need callback function. so that's code working printing: $(".printable").printthis({ debug: false, printcontainer: false, pagetitle: $("#info-modal .short-info .panel-headline-wrapper h1").html(), formvalues: true, printdelay: 0 }) now thought add "done()" function jquery "catches" callback... tried following, didn't work: $(".printable").printthis({ debug: false, printcontainer: false, pagetitle: $("#info-modal .short-info .panel-headline-wrapper h1").html(), formvalues: true, ...

count method in 'if' doesn't work - python -

i don't it, i'm trying count 2 in list , when this: hand=['d2', 'h5', 's2', 'sk', 'cj', 'h7', 'cq', 'h9', 'd10', 'ck'] f=''.join(hand) count2=f.count('2') print count2 it works , prints me 2 number of times 2 in list. when i'm putting in if doesn't work: def same_rank(hand, n): if hand.count('2')>n: print hand.count('2') else: print 'bite me' hand=['d2', 'h5', 's2', 'sk', 'cj', 'h7', 'cq', 'h9', 'd10', 'ck'] f=''.join(hand) n=raw_input('give n ') print same_rank(hand,n) if user gives n=1 supposed print 2 because number 2 twice in list , want more 1 is! why doesn't return that? raw_input() returns string; strings sorted after numbers, 2 > '1' false: >>> 2 > '1' false c...

android - map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap() keeps giving me an error -

i'm beginner @ using maps on android. i'm facing problem when try add following statement code: map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap() the app keeps crashing when starts up. can please me find solution this? main.java package com.example.myfirstapp; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v7.app.actionbaractivity; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import com.google.android.gms.maps.cameraupdate; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.model.latlng; public class mainactivity extends actionbaractivity { private final latlng location= new latlng(49.27645, -122.917587); private googlemap map; @override ...

vb.net - Input array is longer than the number of columns -

Image
in event dragdrop of datagridview got error: here's whole code of dragdrop event : private sub datagridview1_dragdrop(sender object, e system.windows.forms.drageventargs) handles datagridview1.dragdrop dim clientpoint point = datagridview1.pointtoclient(new point(e.x, e.y)) dim hit datagridview.hittestinfo = datagridview1.hittest(clientpoint.x, clientpoint.y) dim dgvr datagridviewrow = directcast(e.data.getdata(gettype(datagridviewrow)), datagridviewrow) dim celldata object() = new object(dgvr.cells.count) {} col integer = 0 dgvr.cells.count - 1 celldata(col) = dgvr.cells(col).value next dim dt new datatable() dt = ds_data.tables(0) dim colcheckbox datacolumn = dt.columns.add("column1", gettype(boolean)) dim row datarow = dt.newrow() row.itemarray = celldata dt.rows.insertat(row, hit.rowindex) dgvr.datagridview.rows.remove(dgvr) dim sqlcmd sqlcommand sqlcmd = con.createcommand() sql...

java - How to do a method search programmatically in Eclipse -

i wrote eclipse plugin ends method name , want display method search results user have gotten built-in java search dialog if typed the method name themselves. way when users click on method in results, method revealed in editor. ideally, want use existing functionality. i know how use searchengine gui'less , learned bit newsearchui.runqueryinforeground(null, query) , started implementing isearchquery , isearchresult , leading toward having implement isearchresultpage writing own gui. way overboard eclipse well. i missing something. should trivial. grateful advice.

javascript - Remove data from form Data in java script -

this question has answer here: how remove value formdata 2 answers how can remove appended data form data in java script? using form data uploading file , passing handler. code: var formdata = new formdata(); var uploadfiles = $("#imagesupload").get(0); var uploadedfiles = uploadfiles.files; (var = 0; < uploadedfiles.length; i++) { formdata.append('file', uploadedfiles[i]); } you can't remove data you've appended formdata object. there nothing exposed in api allow this. create new formdata .

c# - Why does visual studio set the access modifier of a new class to internal -

this question has answer here: why visual studio doesn't create public class default? [duplicate] 9 answers using visual studio create windows form application. there multiple projects contained in solution, each project having multiple folders. when use context menu in solution explorer add/create new class inside of folder, set access modifier internal. namespace namespace.name { internal class classname { } } any ideas why default in case? because default access modifier class, not nested. further documenation on this, please have here .

javascript - Using Handlebars custom helper method to hide HTML -

i have following custom handlebars helper: handlebars.registerhelper('isnewuser', function (userid) { return (userid < 1); }); and following html in view: {{#isnewuser id}} <div> <input name="isactive" id="user-active" type="checkbox" checked /> active </div> {{/isnewuser}} i can see function being hit, userid parameter passed correctly, , return true of type bool instead of showing block shows text 'true'. how can html block hide handlebars without error'ing out? i able fix after gaining insight stackoverflow question . changed helper method following: handlebars.registerhelper('isnewuser', function (userid, options) { if (userid < 1) return options.fn(this); else return options.inverse(this); });

javascript - How to write JSONP Ajax request on pure js? -

this question has answer here: making , handling jsonp request using javascript 1 answer $.ajax( { url : '', data: {}, datatype:'jsonp', jsonpcallback: 'callbackname', type: 'post' ,success:function (data) { console.log('ok'); }, error:function () { console.log('error'); } }); how write same functionality in pure js? in particular case, aren't making ajax call @ all, instead you're making jsonp request. luckily, these incredibly easy replicate , work in browsers. var s = document.createelement("script"), callback = "jsonpcallback_" + new date().gettime(), url = "http://forexplay.net/ajax/quotes.php?callback=" + callback; window[callback] = function (data) { // worked! console.log(data); }; s.src = ...

using newPosition() with Google Document -

i’m having problem document .newposition( element , offest ). according api spec., https://developers.google.com/apps-script/reference/document/document#newposition(element,integer) , the element contain new position; must either text element or container element paragraph i’ve tried both .gettext , .editastext text element: var d=documentapp.getactivedocument(); var t1=d.getbody().editastext(); var t2=d.getbody().gettext(); and then var position = d.newposition(t1,ix); var position = d.newposition(t2,ix); where ix integer within text size. using t1 (editastext), : we're sorry, server error occurred. please wait bit , try again. (line 32, file "testcode”) where line 32 “var position=... line. using t2 (gettext), get: cannot find method newposition(string,number). (line 32, file "testcode") does know how newposition text element? from docs appear method should work, know, throws errors. have several othe...

javascript - Making async calls inside Jasmine it() function -

i'm getting hard time trying figure out how can async call inside it function. tried this, fails. var = 0; it("test async", function(done) { settimeout(function() { = 1; done(); }, 1000); expect(i).toequal(1); // fails. 0 expected equal 1. }) it possible?

c++ - std::unordered_map::emplace object creation -

i in process of selecting 1 of 2 methods of putting things unordered_map: std::unordered_map<key, value> map; map.emplace( std::piecewise_construct, std::forward_as_tuple(a), std::forward_as_tuple(b, c, d)); vs std::unordered_map<key, differentvalue> map; auto& value = map[a]; if (value.isdefaultinitialized()) value = differentvalue(b, c, d); i did experiments see 1 perform better find when inserting unique elements, behaviour (as in efficiency) equivalent. however, in case of inserting duplicate items, , consider construction of value or differentvalue not trivial, surprised find emplace constructs object regardless of whether insert or not. so, second method seems win far in case since default constructor has isdefaultinitialized_(true) in there , not more. for emplace, code seems be: ... _m_emplace(std::true_type, _args&&... __args) { __node_type* __node = _m_allocate_node(std::forward<_args>(__args)...); const key_type...

email - Set anonymous authentication into setJavaMailProperties in Spring -

i'm trying send email spring, received exception mail server connection failed; nested exception javax.mail.messagingexception: not connect smtp host: host, port: 25; nested exception is: java.net.connectexception: connection refused: connect. failed messages: javax.mail.messagingexception: not connect smtp host: mailhub, port: 246; nested exception is: java.net.connectexception: connection refused: connect caused connection refused. for this, need set the connection anonymous authentication right now, have this @configuration public class mailconfig { @value("mailhost") private string host; @value("25") private integer port; @bean public javamailsender javamailservice() { javamailsenderimpl javamailsender = new javamailsenderimpl(); javamailsender.sethost(host); javamailsender.setport(port); javamailsender.setjavamailproperties(getmailproperties()); return ...

knockout.js - knockoutjs child object trigger change in parent computed -

is there easier way parent object's 'subscribe' fire changes of lower level observables? the following code , sample fiddle working, requires me duplicate masteroptions in optionset. smaller version manageable, masteroptions set can become quite large make maintenance of both masteroptions , optionset difficult , error-prone. sample jsfiddle found here: fiddle html: <div> setting1a: <input data-bind="value: masteroptions.group1.setting1a" /><br /> setting1b: <input data-bind="value: masteroptions.group1.setting1b" /><br /> setting2a: <input data-bind="value: masteroptions.group2.setting2a" /><br /> setting2b: <input data-bind="value: masteroptions.group2.setting2b" /><br /> <br /> span1: <span data-bind="text: ko.tojson(optionset)"></span><br/> <br /> span2: <span id="myspan"></sp...

exponentiation - Store and work with Big numbers in C -

i need working big numbers. according windows calc, exponent 174^55 = 1.6990597648061509725749329578093e+123 how store using c (c99 standard)? int main(){ long long int x = 174^55; //result 153 printf("%lld\n", x); } normal types in c can store 64 bits, you'll have store big numbers in array, example, , write mathematical operations yourself. shouldn't reinvent wheel here - try gnu multiple precision arithmetic library purpose. and comments pointed out, ^ operation binary xor. exponentiation, have use mathematical functions pow .

python 2.7 - List of keywords for title/person/character objects? -

is there list of keywords can used? i.e.: in examples in docs, has print item['long imdb canonical title'], item.movieid where list of keywords indexes in data (like "['long imdb canonical title']") , list of attributes (like ".movieid")? the imdbpy objects emulate behavior of dictionaries, can list of keys with: item.keys() , introspect attributes: dir(item)

ios - heightForRowAtIndexPath setting height for wrong row -

Image
i have weird problem heightforrowatindexpath function. need height 3rd row higher, sets height next (in case 4the) row. i'll explain: - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { int height = 40; if(indexpath.row == 3) height = 120; nslog(@"cell %i [height = %i]", indexpath.row, height); return height; } it logs this: (seems good) cell 0 [height = 40] cell 1 [height = 40] cell 2 [height = 40] cell 3 [height = 120] cell 4 [height = 40] cell 5 [height = 40] ... and looks this: ** (to clear: gray row not section different cell style.) am missing badly or wrong? thanks! as requested, added cellforrowatindexpath code. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"frontendcell"; int celltype = [[self.celltypes objectatindex:indexpath.row] in...

iphone - IBM Worklight 6.1 - Unlock generated files with buildtime.sh script -

Image
i using ibm worklight 6.1 , trying copy file iphone/native/www/worklight folder file trying copy/erase cordova_plugins.js, purpose edited buildtime.sh shell script adding line: cp "${srcroot}/cordova_plugins.js" "${srcroot}/www/default/worklight/cordova_plugins.js" this not work after deploying iphone, , returns permission denied error. after unlocking file cordova_plugins.js (manually), script works without errors. so, tried unlock file same script shell, adding chflags nouchg "${srcroot}/www/default/worklight/cordova_plugins.js" just before cp instruction, not seems change (no additional error, issue remains same.) is there way unlock /www/worklight files in project settings or programatically? how buildtime.sh script ? other workaround? in worklight, file not meant played around (per our discussion in question of yours). to work around it, try this: go xcode preferences , unlock files selecting "automatically unloc...

ios - How to properly end an AVCaptureSession? -

i have app qr code reader. set scanner in viewwillappear: // create new avcapturesession. _session = [avcapturesession new]; avcapturedevice *device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; nserror *error = nil; avcapturedeviceinput *input = [avcapturedeviceinput deviceinputwithdevice:device error:&error]; // connect input. if(input) { [_session addinput:input]; } else { nslog(@"error: %@", error); return; } // connect output. avcapturemetadataoutput *output = [avcapturemetadataoutput new]; [_session addoutput:output]; nslog(@"%@", [output availablemetadataobjecttypes]); [output setmetadataobjecttypes:@[avmetadataobjecttypeqrcode]]; [output setmetadataobjectsdelegate:self queue:dispatch_get_main_queue()]; // connect preview layer. _previewlayer = [avcapturevideopreviewlayer layerwithsession:_session]; _previewlayer.videogravity = avlayervideogravityresizeaspectfill; _previewlayer.bounds = self.view.bounds; _previewlay...

eclipse - Loading native libraries in java -

i have eclipse project 2 classes. class "someclass1" has native method: someclass1 public class someclass1 { static { system.loadlibrary("libname"); // load native library. } public native void some_method(); // implemented in library // .... other non methods .... } the other class "someclass2" uses native method of "someclass1". like: someclass2 public class someclass2{ public static void main(string[] args) { someclass1 s = new someclass1(); s.some_method(); } // ....other methods.... } however when calls method throws error this: exception in thread "main" java.lang.unsatisfiedlinkerror: no libname in java.library.path .... @ java.lang.system.loadlibrary(unknown source) @ x.x.x.someclass1.<clinit>(someclass1.java:128) @ someclass2.main(someclass2.java:10) i think error has java not knowing native library. question1 when use: -djava.library.path="c...

c# - Saving to DATABASE MVC pattern -

i new programming please bear me. have written following code in different classes throughout project, , wondering why input not stored in database. hope can me, since have been struggling problem few days now, scavenging darkest corners of web. first of should tell application using wcf - therefore methods should called through wcfservice client. appreciated! ps: if helps here screenshot of solution overview: http://imgur.com/jv9xl3k client code: using client.wcfserviceref; //my wcf service reference namespace client { public partial class mainwindow : window { private wcfserviceclient client; public mainwindow() { initializecomponent(); client = new wcfserviceclient(); } public string getmoviename() { string moviename = txtname.text; return moviename; } public string getmovielength() { string movielength = txtlength.text; ...

go - GoLang, "hash.Write" , where did the "write()" function come from? -

func hash(s string) uint32 { h := fnv.new32a() h.write([]byte(s)) return h.sum32() } for code piece. understand type h. hash. hash type, didn't see write() method. http://golang.org/pkg/hash/ write()? thanks the hash interface embeds writer interface. therefore, type wants implement hash interface, needs implement writer interface containing write method. the reason write method can calculate hashes of can written. example, can calculate hash of formatted representation of object (by using fmt package), or can calculate hash of json representation (by using json package), etc. h := fnv.new32a() fmt.fprint(h, myobject) // alternatively: // json.newencoder(h).encode(myobject) // etc. return h.sum32()

mysql - Join 3 tables with a limit -

i have created query select entries table timeline , enrich data users table. select (1) entry media.filename media table media.album = '0', result of query returning want returns entries media table , need one. put condition or limit 1 ? select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, media.filename timeline join users on users.user_id = timeline.userid2 join media on users.user_id = timeline.userid2 (timeline.user_id = '25') , (dat between date_add(now(), interval -1 day) , now()) thanks lot put limit clause in subquery. select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, media.filename timeline join users on users.user_id = timeline.userid2 cross join (select filename media album = 0 limit 1) media or can put subquery in select clause: select dat, sourceinfo, users.firstname, users.lastname, users.token, users.prof, (select fi...

c# - Setting DataContext in XAML in WPF -

i have following code: mainwindow.xaml <window x:class="sampleapplication.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" datacontext="{binding employee}"> <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="200" /> </grid.columndefinitions> <label grid.row="0" grid.column="0" content="id:"/> <label grid.row="1" grid.column="0" content="na...

javascript - Cannot pass token to a form in AngularJS -

i'm new angular , i'm doing wrong. i'm using 2 angularjs applications don't want have log in logic in main application. i'm trying submit regular html form doing: document.getelementbyid("loginform").submit(); this form: <form method="post" id="loginform" action="main.html"> <input type="hidden" name="token" value="{{regdata.token}}"/> </form> the problem on server "i'm not getting last regdata.token value. here js code: $scope.login = function () { $scope.regdata.token = "very old data"; $http .post('/authenticate', $scope.user) .success(function (data, status, headers, config) { $scope.regdata.token = "very new data"; document.getelementbyid("loginform").submit(); }) .error(function (data, status, headers, config) { delete $window.sessionstorage.token; ...

php - Don't match the URL's between BBCode tags -

as title says want pattern match url's in string, except ones between bbcode tags. so far have made pattern doesn't match url's between [img] tags, have no enough regex skills make work tags more advanced onces ( [url=xxx]yyy[/url] , such). clear: nothing between [ , ] should match. here working example not match url's between [img] tag: http://regexr.com/v1?38mae (may have paste below pattern due encoding being messed up) pattern: (?<!\[img])(((http|ftp|https):\/\/)|www\.)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#!]*[\w\-\@?^=%&/~\+#]) i'd appreciate kind of help! you can add @ begining of pattern: \[[^]]*](*skip)(*fail)| this subpattern find between square brackets, make pattern fail , force not retry substring. example pattern (with ~ delimiter): $pattern = '~\[[^]]*](*skip)(*fail)| (?<!\[img]) (?:(?:ht|f)tps?://|www\.) [\w-]+ (?:\.[\w-]+)+ ...

php - redirect adding %20HTTP to end of the url -

im redirecting this: example.com/category/name-of-title/number to this: example.com/name-of-title/number everything working perfect except adding %20http end of url after redirect so: example.com/name-of-title/number%20http here code: rewritecond %{the_request} /category/(.*)/(.*) [nc] rewriterule ^ /%1? [r=301,l] because as documentation states , the_request is “[t]he full http request line sent browser server (e.g., "get /index.html http/1.1")” – in case, get /category/name-of-title/number http/1.1 , , applying pattern /category/(.*)/(.*) onto results in part name-of-title/number http first match (and remaining 1.1 second), because of greediness of regular expressions. it nonsense anyway use rewritecond , value the_request – simple rewriterule should work fine: rewriterule ^category/(.*)/(.*)$ /$1/$2 [r=301,l] and if want match anything behind category/ anyway, don’t need 2 capturing subpatterns, use rewriterule ^categor...

java - Android JSON names order -

i'm using following code parse info site , works expect older in last loop goes out of whack. names() comes out ["569","570","565","566","567","568","562","563","564"] those number should in numeric order aren't. there way fix this? import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.stringwriter; import java.io.unsupportedencodingexception; import java.net.httpurlconnection; import java.net.url; import java.util.arraylist; import java.util.hashmap; import java.util.iterator; import java.util.linkedlist; import java.util.list; import java.util.map; import java.util.sortedmap; import java.util.treemap; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import org.xmlpull.v1.xmlpullparser; import org.xmlpull.v1.xmlpullparserfactory; import android.annotation.suppresslint; import android.util...

android - how can i invoke NDK's method in arm linux? -

i have ndk 'so' file aes encryption, unpacked apk. don't know ase key. file used send encrypted commands , decrypt response. want use file on other platform except android(for example, arm base ubuntu).how can that? it should possible fake android rt environment on ubuntu. first, unresolved symbols in so, , dynamic libs expects. then, write custom implementation of these functions using native arm based ubuntu toolchain.

How do you find the cartridge short names in Openshift? -

the documentation using openshift environment variables tells insert "cartridge short name" in variable string number of available environment variables. how know cartridge's short name is? for instance, log path environment variable supposed this: openshift_{cartridge}_log_dir the environment variable documentation page can found here: https://www.openshift.com/developers/openshift-environment-variables you control cartridges installed, it’s you. if you’re making own cartridge, specify short name in manifest.yml . example linked documentation: name: php cartridge-short-name: php similarly, each cartridge’s manifest.yml lists short name. here’s relevant section cron cartridge : name: cron vendor: red hat cartridge-short-name: cron

delphi - How to always set the same charset? -

i have application developed in delph7. (not unicode) unable change new delphi , not want use tn .. or other components. is possible make changes in graphics.pas or other unite in each control charset easteurope_charset or symbol_charset. so when text: -loaded file -saved file -pasted clipboard -copied clipboard -typed on keyboard etc. need change in easteurope_charset except when symbol_charset. simply put, font.charset can easteurope_charset or symbol_charset

c# - How to make a program restart itself -

been trying make program restart button click in program , codes "restart()" , "recreate()" dont exist. idea code work? you can this: system.windows.forms.application.restart(); // exist... application.current.shutdown(); // if using wpf, otherwise see below... use application.exit() or this.close() second line in windows forms app.

upload - Python CGI - How can I get uploaded file in TCP server? -

i made tcp server this serverport = 8181 serversocket = socket(af_inet, sock_stream) serversocket.bind(('', serverport)) serversocket.listen(5) and can receive user's login data this elif path == '/login': header, query = message.split(b'\r\n\r\n') fp = io.bytesio(query) form = cgi.fieldstorage(fp, environ={'request_method':'post'}) connectionsocket.send(b'http/1.1 200 ok\r\n') connectionsocket.send(b'content-type: text/html\r\n\r\n') connectionsocket.send('<p>hello {}!</p>'.format(form.getvalue('id')).encode('utf-8')) but can't receive multipart upload data!!t^t i wrote html upload file <html> <body> <form enctype="multipart/form-data" action="http://127.0.0.1:8181/upload" method=post> file process: <input name="file" type="file"> <input type=...

python - Getting a MemoryError because list/array is too large -

problem i have download object_x . simplicity's sake, object_x comprises series of integers adding 1000 . download irregular. receive groups or chunks of integers in seemingly random order, , need keep track of them until have 1000 make final object_x . the incoming chunks can overlap, instance: chunk 1: integers 0-500 chunk 2: integers 600-1000 chunk 3: integers 400-700 current method create object_x list containing of comprising integers 0-1000 . when chunk downloaded, remove of integers comprise chunk object_x . keep doing until object_x empty (known complete then). object_x = range(0,1000) # download chunk 1 chunk = range(0, 500) number in chunk: if number in object_x: object_x.remove(number) # repeat every downloaded chunk conclusion this method memory intensive. script throws memoryerror if object_x or chunk large. i'm searching better way keep track of chunks build object_x . ideas? i'm using python, language doesn...

html - How do people have long segmented web pages? -

i apologise in advance if obvious , noobish question, how segment web page multiple portions, each portion of webpage filling screen in it's entirety? a example of wish similar treehouse's homepage when segment webpage multiple portions e.g "home","about us", etc.. i've tried right clicking on webpage , having through css did not see height and/or width applied on page. how treehouse, , others segment webpages?do make use of background image or there other method of doing so? when give html, body elements css property's: html, body { height: 100%; width: 100%; } and in html makke couple of div's this: <div class="fitscreen"> content 1 </div> <div class="fitscreen" style="background-color: red"> content 2 </div> <div class="fitscreen" style="background-color: blue"> content 3 </div> <div class="fitscreen" styl...

c# - Is it possible using `ffmpeg.exe` in a shared hosting server? -

i use ffmpeg.exe convert video files flv but not work in shared host. possible using ffmpeg in shared host @ all? code: private bool returnvideo(string filename) { string html = string.empty; //rename if file exists int j = 0; string apppath; string inputpath; string outputpath; string imgpath; apppath = request.physicalapplicationpath; //get application path inputpath = apppath + "originalvideo"; //path of original file outputpath = apppath + "convertvideo"; //path of converted file imgpath = apppath + "thumbs"; //path of preview file string filepath = server.mappath("~/originalvideo/" + filename); while (file.exists(filepath)) { j = j + 1; int dotpos = filename.lastindexof("."); string namewithoutext = filename.substring(0, dotpos); ...

laravel - Get the model ID when updating a resource -

i have form submit patch request controller's update method. update method requires have $id, can see below whenever try no query results model [item]. since update method did not receive $id of model public function update($id) { $item = item::findorfail($id); $update = input::all(); // codes save changes return redirect::route('items.index'); } another thing whenever submit form, url turns this: mw.dev/items/%7bitems%7d edit routes.php route::resource('items','itemscontroller'); itemcontroller public function edit($id) { $item = item::findorfail($id); return view::make('items.edit')->with('item',$item); } i have included code on edit.blade.php {{form::open(array('route' => 'items.update', 'method'=>'patch'))}} {{form::text('barcode', $item->barcode, array('placeholder' => 'ba...

javascript - Dispatch event with data -

i trying dispatch event pass custom data event listeners listen on event. considering function fires event: function click() { var x = "foo"; document.dispatchevent(new customevent("clicked")); } click(); how can pass custom data event listener? document.addeventlistener("clicked", function(e) { console.log(x); // logs "foo" }); perhaps looking event.detail new customevent('eventname', {'detail': data}) instead of data use x , in event listener can access x using event.detail function getselectionbounds() { var x =(bounds["x"].tofixed(2)); var y= "xyz"; var selectionfired = new customevent("selectionfired",{ "detail": {"x":x,"y":y }}); document.dispatchevent(selectionfired); }; document.addeventlistener("selectionfired", function (e) { alert(e.detail.x+" "+e.detail.y); });

c# - How to Send Mail Async -

i running issue when trying send email async, found out no of post on stackoverflow none of them helpful. have following block of code public class emailservice : iidentitymessageservice { public task sendasync(identitymessage message) { // plug in email service here send email. var mailmessage = new mailmessage ("me@example.com", message.destination, message.subject, message.body); mailmessage.isbodyhtml = true; var client = new smtpclient(); client.sendcompleted += (s, e) => client.dispose(); client.sendasync(mailmessage,null); return task.fromresult(0); } } i got email getting exception when block of code run an asynchronous module or handler completed while asynchronous operation still pending. any suggestion? use sendmailasync instead of sendasync : public class emailservice : iidentitymessageservice { public async task sendasync(identitymessage message) ...

Rails actions based on number of characters -

how if / else statement in rails based on number of character (ex: 100)? sample code appreciated! maybe helps? phrase = "hello world" if phrase.length > 100 //do somthing end this execute if your phrase string longer 100 characters.

qt - Get keypresses in QSplashScreen on OSX -

i trying keypresses qsplashscreen before main window opens. splash class inherits qsplashscreen , overrides keypressevent method. the code below works on windows on osx keypresses not intercepted until main window opens. is there workaround this? this using qt 5.2.1, think issue in earlier (4.x) versions too. splash.cpp: ... void splash::keypressevent(qkeyevent *evt) { std::cout << evt->text().tostdstring() << std::endl; } main.cpp: ... void delay(float seconds) { qtime dietime= qtime::currenttime().addsecs(seconds); while( qtime::currenttime() < dietime ) qcoreapplication::processevents(qeventloop::allevents, 100); } int main(int argc, char *argv[]) { qapplication a(argc, argv); splash *splash = new splash; splash->setpixmap(qpixmap(":/images/splash_loading.png")); splash->show(); splash->grabkeyboard(); // on osx no keypresses captured here, on windows keypresses captur...

java - Newline not being replaced in regex match? -

i have following code attempting parse lines starting # , replacing each line empty string, newline not getting stripped: -- input -- # remove this. # remove # remove line keep # line keep # line -- actual output (the . represents blank line) -- . . . keep # line keep # line -- expected output keep # line keep # line -- code -- string text = "# remove this.\n# remove this\n# remove line\n" + "keep # line\nkeep # line too"; system.out.println(text); pattern pattern = pattern.compile("^#(.*)$", pattern.multiline); matcher m = pattern.matcher(text); if (m.find()) { text = m.replaceall("").replaceall("[\n]+$", ""); system.out.println(text); } how can remove \n's in regex match? use ^#.*[\n] select lines including newline character.

c - What is the replacement of mod operator? -

this question has answer here: is there alternative using % (modulus) in c/c++? 12 answers i have code segment requires remainder of 2 ints. using modulus operator usual hearing takes more time. asking there way remainder more efficiently mod operation... following code int rem=gid%bpp gid being int , bpp being 2,4,8,16,32. it appears question bpp power of 2, in case can use instead: int rem = gid & (bpp - 1); however should not optimise prematurely - unless have profiled , know mod operation bottleneck should leave in original, more readable form.

javascript - How to fire an event after a kendo comboBox has finished a filter -

i need fire event after combo box finishes filter i have extended widget , have tried chuck .done on end of call. search: function(word) { word = typeof word === "string" ? word : this.text(); var = this, length = word.length, options = that.options, ignorecase = options.ignorecase, filter = options.filter, field = options.datatextfield; cleartimeout(that._typing); if (length >= options.minlength) { that._state = state_filter; if (filter === "none") { that._filter(word); } else { that._open = true; that._filtersource({ value: ignorecase ? word.tolowercase() : word, field: field, operator: filter, ignorecase: ignorecase }); // .done here not work :( } } }, i...

c# - Lock on Dispatcher -

lock { dispatcher.begininvoke(dispatcherpriority.send, (sendorpostcallback)delegate(object o) { dosomething(); } } does lock remains acquired until dispatcher completes execution or released after sending dosomething(); execution dispatcher? lock remains acquired until code under lock {} section completes execution. in case means: until dispatcher.begininvoke completes execution. and dispatcher.begininvoke executes asynchronously, means lock gets released "immediately" - dosomething() might start in moment when lock has been released.

mysql - How to design table schema for storing values from <select multiple> -

i have select-multiple list html control, enables end user select multiple items. currently, stored user selected values "truck, heavy truck, others" mysql varchar field. both truck , heavy truck searched out if user select truck on select multiple control. sql statement query "select trucktype table tracktype '%truck%'". seems way solution put selected values table. is there other way handle issue in 1 table? add , end , start so value becomes , truck, heavy truck, others, use query select trucktype table tracktype '%, truck,% note: , in like '%, truck,%'

Android how to stop AsyncTask -

this question has answer here: android - cancel asynctask forcefully 6 answers i working on asynctask . trying stop asynctask . authenticationarrows mtask = new authenticationarrows(); mtask.execute(); i trying stop by mtask.cancel(true); but not stop. my asynctask code below. class authenticationarrows extends asynctask<void, void, boolean> { @override protected void oncancelled() { super.oncancelled(); cancel(true); // ask if user wants try again } @override protected boolean doinbackground(void... params) { return null; } protected void onpostexecute() { } @override protected void onpreexecute() { if (!iscancelled()){ handler.post(new runnable() { @override public void run() { centerimage.setvisibil...

linux - Open MPI Virtual Timer Expired -

i'm using open mpi 1.8 on gentoo 3.13 manage data transfer 1 program via server/client concept. both server , clients launched via mpiexec separate processes. after days (this quite heavy computation...), receive error mpiexec noticed process rank 0 pid 17213 on node xxx exited on signal 26 (virtual timer expired). unfortunately, error not reproducible in reliable way, i.e., error not appear , not @ same point in program flow. experienced error on other machines. tracked issue down itimer_virtual which, upon expiration, delivers sigvtalrm (see, e.g., http://man7.org/linux/man-pages/man2/setitimer.2.html ). in bugs section of man page, says under heavy loading, itimer_real timer may expire before signal previous expiration has been delivered. second signal in such event lost. i wonder if similar might hold itimer_virtual ? did experience similar problems , can confirm error? the workaround can think of invoke setitimer(...) , try manipulate timer myself. howeve...

String to int java.lang.NumberFormatException -

i have java program convert string int , rang of string 190520141618013381 (above rang of int ) when convert int java.lang.numberformatexception: thrown stringbuffer stringbuffer = new stringbuffer(); stringbuffer.append(format.format(date)); stringbuffer.append(demandcount); int test_int = integer.parseint(stringbuffer.tostring()); // exception has been fixed putting //long abc_i = long.parselong(abc); log.info("test_int: "+test_int); my question compiler should throw numberoutofrangexception (if exception available in api) instead java.lang.numberformatexception: , format of number( 190520141618013381 ) right. the string 190520141618013381 outside range of int doesn't match accepted format of int because long. the compiler doesn't throw error, thrown @ runtime. i believe correct comply documentation method. btw don't use stringbuffer, replaced stringbuilder ten years ago. imho storing date integer i...

java - Jacoco tcpserver reset dump -

i'm trying coverage data remotely jacoco agent , reset execution info on server reset=true; jacoco java agent on server: java_options="${java_options} -javaagent:applications/jacoco/lib/jacocoagent.jar=output=tcpserver,address=*,port=36320" ant task on local machine: <project name="ant report build jacoco" default="get_data" xmlns:jacoco="antlib:org.jacoco.ant"> <property name="result.exec.file" value="test_data.exec"/> <property name="server" value="my-server.com" /> <property name="port" value ="36320" /> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> <classpath path="jacoco\lib\jacocoant.jar"/> </taskdef> <target name="get_data"> <jacoco:dump address="${server}" port="${port}" reset="t...