Posts

Showing posts from April, 2010

javascript - The "right" way to do synchronous HTTP request -

you came here chide me real use case. in world of online education, there scorm courses. have make old scorm courses work on site. scorm courses "web based" , run in browser, expect run in iframe , expect parent supply getvalue method , setvalue. so these scorm courses doing things parent.setvalue("score", "90") , moving on. function supposed return "false" if there issue. scorm comes 90's, , in modern web know have callbacks/promises , http fails "often". might think solution setvalue writes local data , tries , retries until get's through, scorm course typically set move next screen if setvalue worked, shouldn't letting user advance unless setvalue saved on server. tl;dr assuming syncronous request requirement, right way it? so far know of $.ajax({async:false ... browsers warn , sound they're going ignore request synchronous. thinking maybe using websockets or web workers or right way syncronous

linux - Failsafe Automated Git Update/Add/Commit -

i have website need commit system generated files , folders existing git repository via linux command line. have automated process monitors folder new bash scripts , runs them. website creates scripts , saves them folder. i keep getting issues has changed on either remote repo or local 1 stopping git completing following commands git pull --rebase origin git add [repo path updated file(s)]/* git commit -m "commit message" git push master i need bullet proof process run , can forget it. right now, permissions issues on files pulled down, or merge conflicts, etc... keep getting repo out of sync. how can bullet proof commands above pull down remote changes , commit new ones necessary?

java - App works perfectly fine on Samsung phone but doesn't work on LG -

i've created simple android flashlight app seems working on samsung device i've tried on doesn't seem work lg g series phones. i've tested on lg g3, g4 , g5. the app loads mainactivity fine, when flashlight button clicked, nothing happens. i've plugged in see if there's sort of error message comes when attempt use flashlight, no error occurs. is common problem between device manufacturers? i've done bit of research , i've gathered long code app towards each android os, shouldn't have problem. i've had lg devices work, while others don't. both phones have been on same android version , on same network. else experience this? edit i learned have setpreviewtexture(0) on phones in order app turn torch on properly. however, i'm running issue of app lagging when trying use burst mode.

oracle - How to raise sql query for trigger after update and get old and updated values? -

how can old , newly updated values after update trigger??? please me guys. yes can, if trigger set for each row option. by default, new values referenced :new.column_name , old values :old.column_name , aliases can changed referencing keyword. see the oracle documentation more details.

.net - format date in c# -

how can format date dd/mm/yyyy or mm/dd/yy ? like in vb format("dd/mm/yy",now) how can in c#? it's same, use datetime.tostring() method, e.g: datetime.now.tostring("dd/mm/yy"); or: datetime dt = getdate(); // getdate() returns date dt.tostring("dd/mm/yy"); in addition, might want consider using 1 of predefined date/time formats, e.g: datetime.now.tostring("g"); // returns "02/01/2009 9:07 pm" en-us // or "01.02.2009 21:07" de-ch these ensure format correct, independent of current locale settings. check following msdn pages more information datetime.tostring() method standard date , time format strings custom date , time format strings some additional, related information: if want display date in specific locale / culture, there overload of tostring() method takes iformatprovider : datetime dt = getdate(); dt.tostring("g", new cultureinfo("en-us")); // re

How do time periods in Facebook insights work? -

in example pasting below, first request insights data daily last month. second 1 weekly, , third per 28 days (let's call monthly). problem data days_28 same day, whereas should @ least weekly data (i.e. data last 28 days should @ least 61, not 1). why happen? interpreting data wrong? the urls below: https://graph.facebook.com/1404223219793416/insights/page_stories/day?since=-1month https://graph.facebook.com/1404223219793416/insights/page_stories/week?since=-1month https://graph.facebook.com/1404223219793416/insights/page_stories/days_28?since=-1month here daily data: { "data": [ { "id": "1404223219793416/insights/page_stories/day", "name": "page_stories", "period": "day", "values": [ { "value": 0, "end_time": "2013-07-19t07:00:00+0000" }, { "value": 0,

arrays - Incorrect behavior of a pointer in function in C -

i have problem following program. the main function calls function returnarrayofwords(arrs1, &ptrarray1) twice. on first call, array parsed perfectly, , afterward pointer points first word. on other hand, after second call, pointer of first array points second word, third word, or first word, should point first word -- else. why function misbehave when called second time? #include <stdio.h> #include <string.h> #include <stdlib.h> void returnarrayofwords (char *str4parsing, char *arrayparsed[]) { char seps[] = " ,\t\n"; // separators char *token1 = null; char *next_token1 = null; int = 0; // establish string , first token: token1 = strtok_s( str4parsing, seps, &next_token1); // while there tokens in "str4parsing" while (token1 != null) { // next token: if (token1 != null) { arrayparsed[i] = token1; printf( " %s\n", token1 );

Why the bitrate shown during processing differs so much from the final bitrate after processing using ffmpeg? -

Image
using ffmpeg, why bitrate shown during processing differs final bitrate after processing? this command on 1080p source: ffmpeg -i "$name" -i "$subname" -map 0 -map 1 -vf scale=-1:720 -c:v libx264 -preset veryslow -crf 21 -c:a aac -b:a 256k -c:s:0 srt -disposition:s:0 default -metadata:s:s:0 language=eng -metadata:s:v:0 title="$title" "$new" shows output: which averages 1300-1400 kbit/s. when calculate bitrate of resulting video using mkvinfo -t bitrate shown sits @ ~970-1000 kbit/s , that's not close averaging ~1300 kbit/s shown throughout processing. causing disparity? from documentation of mkvinfo: mkvinfo -t show statistics each track in verbose mode. i guess, see bitrate video track, while ffmepg output average bitrate whole mkv (audio track + video track). difference notice round 300kbit/s near audio bitrate, 256kbit/s

MP4 Video on MediaWiki -

i have mp4 videos have been produced in-house host on our internal mediawiki (1.26.3). can't seem find extension compatible version. doing wrong looking appropriate extension (meaning, there native way display video) or out of luck until 1 of extensions gets updated? use videoplayer extension (compatible v1.26.3) html5 provider. to install videoplayer extension follow instructions in https://www.mediawiki.org/wiki/extension:videoplayer : 1) in wiki folder, copy following php code extensions/videoplayer/videoplayer.php (create file if not exist yet): <?php // see http://www.mediawiki.org/wiki/extension:videoplayer more information. $wgextensionfunctions[] = 'videoplayer'; $wgextensioncredits['parserhook'][] = array( 'name' => 'videoplayer', 'description' => 'display video players youtube, dailymotion, vimeo, google, etc...', 'author' => 'joachim chauveheid',

c# - Is there any Event for select text from mail body? -

i try catch selection text change event on mail body. idea text when selection changed , show in textbox. i got document object there event selection change ? outlook.mailitem mailitem = item outlook.mailitem; outlook.inspector inspector = mailitem.getinspector; microsoft.office.interop.word.document document = (microsoft.office.interop.word.document)inspector.wordeditor; i think looking similar this. text selection change event in outlook inspector window you'll want application document , attach windowselectionchanged event. outlook.mailitem mailitem = item outlook.mailitem; outlook.inspector inspector = mailitem.getinspector; word.document document = (microsoft.office.interop.word.document)inspector.wordeditor; word.application app = document.application; app.windowselectionchange += new microsoft.office.interop.word.applicationevents4_windowselectionchangeeventhandler(your_method_here);

c - A few assembly instructions -

could please me understand purpose of 2 assembly instructions in below ? (for more context, assembly + c code @ end). ! movzx edx,byte ptr [edx+0xa] mov byte ptr [eax+0xa],dl =================================== assembly code below: push ebp mov ebp,esp , esp,0xfffffff0 sub esp,0x70 mov eax,gs:0x14 mov dword ptr [esp+0x6c],eax xor eax,eax mov edx,0x8048520 lea eax,[esp+0x8] mov ecx,dword ptr [edx] mov dword ptr [eax],ecx mov ecx,dword ptr [edx+0x4] mov dword ptr [eax+0x4],ecx movzx ecx,word ptr [edx+0x8] mov word ptr [eax+0x8],cx movzx edx,byte ptr [edx+0xa] ; instruction 1 mov byte ptr [eax+0xa],dl ; instruction 2 mov edx,dword ptr [esp+0x6c] xor edx,dword ptr gs:0x14 je 804844d <main+0x49> call 8048320 <__stack_chk_fail@plt> leave ret =================================== c source code below (without libraries inclusion): int main() { char str_a[100]; strcpy(str_a, "

SpriteKit bodyWithTexture gap between sprites when colliding -

Image
i'm new spritekit , i'm trying create game, blocks fall top of screen , land on bottom of screen or on top of block. here sample code gamescene.m: - (void)didmovetoview:(skview *)view { self.size = cgsizemake(view.frame.size.width, view.frame.size.height); self.backgroundcolor = [uicolor whitecolor]; self.physicsbody = [skphysicsbody bodywithedgeloopfromrect:self.frame]; skspritenode *redrect = [skspritenode spritenodewithimagenamed:@"redrect"]; redrect.position = cgpointmake(cgrectgetmidx(self.frame), self.frame.size.height); redrect.physicsbody = [skphysicsbody bodywithtexture:redrect.texture size:redrect.texture.size]; redrect.physicsbody.affectedbygravity = yes; skspritenode *bluerect = [skspritenode spritenodewithimagenamed:@"bluerect"]; bluerect.position = cgpointmake(cgrectgetmidx(self.frame), self.frame.size.height); bluerect.physicsbody = [skphysicsbody bodywithtexture:bluerect.texture size:bluerect.t

javascript - Collect Selected fields from UI -

i new developing ui components. have requirement collect selected elements ui , should passed spring controller. for example, have person.java has fields , display these fields along checkbox in ui , list user can select of fields. when ever click submit button need pass these values controller , there operations. how can achieve these functionality spring + jquery. can me on this... thanq amar

assembly - How do I link this execlp program using ld in Windows? -

i'm using gas mingw (gcc, as, , ld specific) compile following to-be shellcode in windows... .text .globl _main .def _main; .scl 2; .type 32; .endef #.extern _execlp .def _execlp; .scl 2; .type 32; .endef _main: push %ebp movl %esp, %ebp pushl $0 pushl $0x00657865 pushl $0x2e646d63 call _execlp movl %ebp, %esp pop %ebp that compiles fine using... as -o ex.o ex.s where ex.s assembly source file. but during linking... ld -o ex.exe ex.o it gives error... ex.o:fake:(.text+0x10): undefined reference 'execlp' so tried make extern putting... .extern _execlp ...above definition (the comment). meanwhile had .c file code (which generated ex.s file (using gcc -s -m32 -o ex.s ex.c))... #include <process.h> int main(int argc, char *argv[]) { execlp("cmd.exe", 0); return 0; } when compiled with... gcc -o exc.exe exc.c where exc.c c file. compiles , runs desired function

gradle - Disable ART runtime (vmSafeMode) and dex2oat for an Android Library targeting SDK 22+? -

so, disable art runtime, add android:vmsafemode="true" application's manifest tag. the issue having develop android library, , not have application tag. this means debugging extremely slow when using instant run (dex2oat has run on everything), or when using library using instant run. i attempted use manifestplaceholders = [vmsafemodeenabled: "true"] in build.gradle, has no effect. anyone have insights? similarly, dexoptions { predexlibraries false } yielded no difference in results. still seeing dex2oat taking significant amount of time on each app startup. of course, of these options work fine on applications, not @ library/sdk development. as mention on comment, believe you're mixing concepts i'll take time explain them separately. instant run that feature of ide (that android studio) , compatible (in different amounts) way devices running api 15. affects code used during debug/development of application. it

python - After installing django in virtual environment, still can't import module -

i trying use django web dev, after install it, try use import in interpreter , says gives me import error. here do. virtualenv venv --distribute source venv/bin/activate so in virtual environment (venv) pip install django python import django then importerror import django traceback (most recent call last): file "", line 1, in importerror: no module named 'django' import django traceback (most recent call last): file "", line 1, in importerror: no module named 'django' original poster here. i installed django using pip in python 2.7 binaries while working python 3.5. using pip3 install django solved it.

css - Transform/translate errors that occur exclusively in Mozilla -

i've issue transform/translation glitches within animation. errors occur exclusively within mozilla, obviously, functioning in chrome. realize repeated issue, first did research @ css3 , mdn , reviewed these questions , , ensured functionality of transform here . in tow, remain confused. body { overflow: hidden; background: #e8e8e8; } .floor { height: 90px; width: 450px; border-bottom: 1px solid #e8e8e8; position: absolute; top: 50%; left: 50%; margin-top: -50px; margin-left: -250px; } .box { box-sizing: border-box; width: 90px; height: 90px; border-radius: 2px; background: #d0d0d0; -webkit-transform-origin: 100% 100%; -moz-transform-origin: 100% 100%; -o-transform-origin: 100% 100%; transform-origin: 100% 100%; -webkit-animation: turnmove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1); -moz-animation: turnmove 3500ms infinite alternate cubic-bezier(0.75, 0, 0.175, 1); -o

javascript - Allow just one click in class JQUERY -

i have link load via ajax content. my problem is, don't want remove text "load comments", want not allow more clicks in class. <a href="javascript:;" class="showcomments" id="'.$idf.'">load comments</a> jquery var progressajax = false; $(function() { $(".showcomments").click(function(){ if(progressajax) return; progressajax = true; var element = $(this); var id = element.attr("id"); progressajax = false; alert("ok"); $(data).hide().prependto('.varload'+id).fadein(1000); //$(element).remove(); $(element).removeattr("href"); $(element).removeclass('showcomments'); }); }); i want see ok first time. how can remove class? $(element).removeclass('showcomments'); this not working... http://jsfiddle.net/qsn1tuk1/ use jquery's o

Laravel, mysql - return same row mutiple times -

how return same row mutiple times? tried using wherein('table' , \session::get('memory')) aswell, returned non-duplicates. far understood possible union, quite confused how implement it. could me out? session array: array:5 [▼ 0 => "addon-0a65729-aak" 1 => "visiontek-900379" 2 => "addon-0a65729-aak" 3 => "addon-0a65729-aak" 4 => "addon-0a65729-aak" ] query have far $memory = \db::table('memory')->leftjoin('price', 'price.part_number' , '=', 'memory.part_number')->groupby('memory.part_number') ->select( 'memory.part_number part_number', \db::raw('min(price.price) price'), 'price.url url', 'memory.slug slug'); foreach (\session::get('memory') $key) { $memory = $memory->union($memory)->where('memory.slug', $key); } $m

html - get jquery plugin targeted object DOM -

to honest i'm not sure how technically ask current need, i'll try show using pseudo code. i'm building jquery plugin , need return 'targeted element's dom' - this: plugin usage: $('div.targeted-dom-element').myplugin(); and inside plugin want return/reuse somewhere 'div.targeted-dom-element' string (not object please!) - there jquery/js built-in function such thing? edit : property deprecated, matt pointing out. jquery objects has selector property can like myjqueryobj.selector

php - how go to next page in yii2 from listview? -

i having problem on yii2 please how move 1 page in listview that's nothing try seems working. want when listview clicked takes page , carries datas of colon click. next page this index.php <?php use yii\widgets\listview; use yii\data\arraydataprovider; use app\models\myprofile; use app\models\likediscussion; use yii\widgets\activeform; use common\models\topic; use yii\widgets\pjax; use yii\helpers\html; use frontend\assets\appasset; $this->title = 'my yii application'; ?> <?php $query = topic::find()->all(); $dataarr = array(); foreach ($query $detail) { $dataarr[] = array( 'topic_id' => $detail->topic_id, 'topic' => $detail->topic, 'created' => $detail->created, 'creator' => $detail->creator, 'views' => $detail->views ); }

How can I count how many times I get a result in neo4j? -

Image
currently, have following graph database in neo4j, hundreds of thousands of "customers" (so there's hundreds of thousands of layout in neo4j database). currently, running following query: match (m:member)-[r:activity{issue_d:"16-jan"}]->(l:loan) match (m)-[:activity]->(p:payments) match (m)-[:history]->(c:credithistory) not p.total_pymnt=0 return l.funded_amnt, p.total_pymnt, (l.funded_amnt)-(p.total_pymnt) amountowed, r.issue_d dateissued, l.installment monthlypayment, l.int_rate interestrate, c.dti debt order (l.funded_amnt)-(p.total_pymnt) desc limit 50000; and results following (except january "dateissued") 2 i want count how many times monthlypayment greater 1000, count(x) query in cypher works count things related single node, not across nodes. how can count across data? count is counting things "across nodes". this simple query should give count of number of

Polymer-cli : The localhost page isn’t working -

$ polymer serve -o chrome says : the localhost page isn’t working localhost didn’t send data. err_empty_response but if use : http://127.0.0.1:8080/ or http://api.local.host:8080/ (custom host in host file) the polymer app rendered. node : 4.3.0 polymer-cli : 0.11 bower : 1.7.9 osx : 10.11.5 chrome : 50.0.2661

R How to compare Rows and Delete by Matching Strings -

match date points opponent points reb opponent reb dal vs den 8/16/2015 20 21 10 15 den vs dal 8/16/2015 21 20 15 10 i have dataframe sports data. however, have 2 rows every game due way data had collected. example 2 rows above same game, again data had collected twice each game in case: once dal , 1 den . i'd find way delete duplicate games. figure 1 of conditions compare have game date. how else able tell r check delete duplicate rows? assume should able tell r to: check game date matches if game date match , if "teams" match delete duplicate. (can done though strings not exact match, i.e. since den vs dal , dal vs den not matching string?) move on next row , repeat until end of spreadsheet. r not need check more 50 rows down before moving on next row. is there function test matching individual words? example not want have tell r: "if cell contains den ... or "if cell

Where do I put rails Transactions and how do I execute them -

i have case need create 10000 entries in table , after research decided use transaction it. my problem haven't found documentation or guide tell me put transaction or how execute it this can achieved easily: activerecord::base.transaction ... code ... end the code inside block run within database transaction. if error occurs during execution, changes rolled back.

Saving a spinner position to a text file [Android] -

i'm trying save selected location of spinner in text file when click save button. currently have. spinner works fine when try add part save spinner position (savesettings) problems lie. i getting following errors: error:(56, 85) error: incompatible types: string cannot converted file error:(61, 40) error: method getposition in class arrayadapter<t> cannot applied given types; required: charsequence found: no arguments reason: actual , formal argument lists differ in length t type-variable: t extends object declared in class arrayadapter error:execution failed task ':app:compiledebugjavawithjavac'. compilation failed; see compiler error output details. i think problem tried combine 2 different approaches i'm still learning i'm confusing myself correct method saving selected spinner position. public class mainactivity extends appcompatactivity { spinner spinner; arrayadapter<charsequence> adapter; string selectedserver;

c - expression must be a pointer to a complete object type from macro -

i'm attempting integrate libbeanstalkd embedded system i'm having make minor changes. far i've been able replace/fix os specific code came error. i've fixed these type of errors before "expression must pointer complete object type" what's getting me aside fact i'm sure header macro , used objects macro used few lines before compiler error thrown. can me understand issue is? source arrayqueue.h #ifndef arrayqueue_h #define arrayqueue_h #define aq_define_struct(struct_name, node_type) \ struct struct_name { \ node_type *nodes; \ size_t size; \ size_t used; \ off_t front; \ off_t rear; \ } #define aq_nodes_free(q) ( (q)->size - (q)->used ) #define aq_full(q) ( (q)->used == (q)->size ) #define aq_empty(q) ( (q)->used =

angular - How can I "monkey patch" an Observable for Zone.js? -

i'm creating angular 2 component, , angular's change detection isn't working me when using observable pattern. looks this: let getresult$ = this.http.get('/api/identity-settings'); let manager$ = getresult$ .map((response) => /* -- create manager object -- */); let signinresponse$ = manager$ .flatmap(manager => manager.processsigninresponse()); this.readytologin$ = manager$.map(() => true).startwith(false); this.isloggedin$ = signinresponse$.map(() => true).startwith(false); then in template: <h1>ready log in: {{readytologin$ | async}}</h1> <h1>logged in: {{isloggedin$ | async}}</h1> since readytologin$ observable based on synchronous set of operations happen in response http.get() (which angular "monkey patches" ensure knows when needs detect changes), "ready log in" message switches true @ appropriate time. however, since processsigninresponse() produce

html - justify-content property is not working as expected -

i'm trying align "previous" left, align "next" right, , figure out how center page numbers. i've been looking @ tutorials , articles on flexbox i'm having hard time understanding it. .nav-links { display: flex; } .prev.page-numbers { justify-content: flex-start; } .next.page-numbers { justify-content: flex-end; } <div class="nav-links"> <a class="prev page-numbers">previous</a> <a class="page-numbers">1</a> <a class="page-numbers">2</a> <a class="page-numbers">3</a> <a class="next page-numbers">next</a> </div> the justify-content property applies flex containers, although aligns flex items. in code, because you're applying justify-content flex items, being ignored. here 2 working examples: example 1 - justify-content .nav-links { display: flex;

javascript - Why does If Else statment not output anything? -

attempting have user input 4 numbers, are, , destination. have output direction heading. no matter values enter same thing happens. how can make code use results of prompts? var output = document.getelementbyid("output"); var number=prompt ("what current latitude?"); var number=prompt ("what current longitude?"); var number=prompt ("what destination latitude?"); var number=prompt ("what destination longitude?"); var intcurrentlatitude = 0; var intcurrentlongitude = 0; var intdestinationlatitude = 0; var intdestinationlongitude = 0; if ( (intcurrentlatitude<=intdestinationlatitude) && (intcurrentlongitude<=intdestinationlongitude) ) { output.textcontent = "we'd headed north east, capt'n!"; } else if ( ( intcurrentlatitude<=intdestinationlatitude) && (intcurrentlongitude>=intdestinationlongitude) ) { output.textcontent = "ye'd best head north west, captain!"; } else

hibernate - How to use existing java data bindings in grails? -

i need add new datasource grails project wich uses musicbrainz postgresql database. http://musicbrainz.org/doc/musicbrainz_database i found project on github data bindings ready use spring project: https://github.com/lastfm/musicbrainz-data am able use these data bindings in grails 2.2.3 project? if yes, how can this? (because there no hibernate xml needed grails (regarding grails documentation: hibernate mapped domain classes)) i don't think be. setup additional datasource , model out tables or objects need. how access 2 databases in grails once that, can use of gorm methods , dynamic finders data. plus validation criteria, transactions, etc. unless there specialized criteria make necessary bypass gorm, suggest leveraging it.

c - How to design a function which identifies when "+IPD," is arrived from UART? -

i'm working tiva launchpad ek-tm4c123gxl , esp8266 wifi module. when module gets wifi packet, sends microcontroller through uart port. the format used esp8266 send packet (to uc via uart) is: +ipd,n:xxxxx\r\nok\r\n where: n length (in bytes) of data packet : indicates next byte first data byte xxxxx data packet \r\nok\r\n 6 bytes , useless me. for example: +ipd,5:hello\r\nok\r\n here situation: i'm working on existing project, can't change these 2 things: 1- uart module configured generate interrupt when receive fifo (of 16 bytes) half-full. 2- isr (interrupt service routine) handles interrupt: reads 1 byte uartdr (uart data register) saves variable calls function (called rx_data() ) handle byte. now, have write function, called rx_data() , in c language. so, message coming form esp8266 module passed function, rx_data() , 1 byte @ time, , function must able to: identify header +ipd, read length n of data packet save data pa

java.util.NoSuchElementException while starting an OSGi framework programatically -

i trying programatically start osgi framework (preferably equinox) java , load bundles. so going through article says how that. getting java.util.nosuchelementexception everytime @ below line everytime serviceloader.load(frameworkfactory.class).iterator().next(); below code- import java.io.file; import java.util.hashmap; import java.util.linkedhashmap; import java.util.map; import java.util.serviceloader; import java.util.logging.logger; import org.osgi.framework.bundle; import org.osgi.framework.bundlecontext; import org.osgi.framework.bundleexception; import org.osgi.framework.frameworkutil; import org.osgi.framework.launch.framework; import org.osgi.framework.launch.frameworkfactory; public app() { try { frameworkfactory frameworkfactory = serviceloader.load(frameworkfactory.class).iterator().next(); map<string, string> config = new hashmap<string, string>(); //todo: add config properties framework framework = f