Posts

Showing posts from July, 2011

linux - Scanning the output of a program at shell -

hello trying make script file in linux has input output of o prgram , scans find how many occurences of words existed. clearer want scan output , store variables how many times words exist in output. new scripitin in linux. tried storing output in file , scan line line in order find words somre reason loop use parse never ends. can me? ./program > buffer.txt while read line echo $line | grep word1 #when use grep command loop never ends done <a.txt edit: in c equivalent program be char* word="word1" while(/*parse lines @ text */) { fgetline("file_a",&buffer) if(strcmp(buffer,word)==0) strcpy(word1,"word") //continue search } the easiest thing skip writing file altogether if ./program | grep -q word1 &>/dev/null; echo "true" fi -q tells grep quiet, can still produce error messages can suppress w/the &>/dev/null. if you'd prefer see error messages, remove part. if want ./program's error

iphone - Delete an ALAsset -

i'm using photo viewer , wan't implement trash button. i have button ready , go following: how delete alasset?? i tried searching in many places couldn't find answer... thanks, for reason i'm not allowed post question i'm adding irrelevant code of trash button: uibarbuttonitem *trash = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemtrash target:self action:@selector(trashbuttonhit:)]; you can't delete alasset , there no api this. an alasset link file in photo library, outside of sandbox of app. assets library allows acces file in photo library read only.

Rails number_with_delimiter return integer without delimiter -

i'm using number_with_delimiter make integer or decimal more easy read, have once problem when using inside controller solved time. don't know happen when put function on view return integer without delimiter . please see simulation create show different. <td><%= number_to_currency(stock.qty) %></td> <td><%= (number_with_delimiter number_with_precision stock.qty, :precision => 2) %></td> <td><%= number_with_delimiter(stock.qty) %></td> <td><%= stock.qty %></td> result: $100,070.00 100070 100070 100070.0 so number_with_delimiter , number_with_precision isn't working also. thing happen project while others projects on local doing fine. , on other branch of project fine. know there broke into. don't know 1 is, since didn't realize , didn't know 1 make broken, can't trace through version control cause there update on it. please help. thank much. than

Twig templates in Laravel 4 -

i use twig templating instead blade, possible? are there plans support twig? part of symfony 2 , laravel 4 relies on symfony seem idea. there exists composer package twigbridge that.

mysql - SQL with AND in the same column -

i have mysql table named 'values' : values: file | metadata | value ________________________ 01 | duration | 50s 01 | size | 150mo 01 | extension| avi 02 | duration | 20s 02 | extension| mkv 03 | duration | 20s 03 | extension| mpeg an user create own query in sql, : select file values (metadata='duration' , value='20s') , (metadata='extension' , value='mkv') i know query bad, can't change 'values' table. don't know how file_id these conditions.. any ideas ? thanks in advance ! like this: select file ( select file, max(case when metadata = 'duration' value end) duration, max(case when metadata = 'extension' value end) extension `values` metadata in ('duration', 'extension') group file ) sub duration = '20s' , extension = 'mkv'; see in action here: sql fiddle demo update if want dynamically, , assuming these met

java - Calculate Android sensor power consumption -

getpower() returns power in ma used sensor while in use: now, need calculate how battery used registration of sensor. does value returned getpower() indicate mah (ma per hour) or else? if yes, there way battery mah in order calculate % of battery used sensor? something quite related has been discussed in google groups not long ago. can find full thread here reference. a small excerpt last reply in thread, should answer question more or less: (...) battery capacity given in terms of mah. (...) matters how long battery can supply given current @ rated voltage. 3800mah means can supply 3800ma 1 hour. knowing makes sense api providing current drain metric of power consumption. can calculate how effect have on battery life function of time.

javascript - Jvectormap highlight Multiple countries -

i using jvectormap , trying highlight multiple countries when hovering on text, have gotten point if hover on word africa, highlight entire map, how filter highlight africa when hovering on content name of africa. currently creating list of continents using jquery.each , returning continentcodes , contains of country codes (za, us) color assigned them... have tried doing following: jquery('.continentlink').hover(function() { jquery.each(mapobject.mapdata.paths, function(i, val) { if (val.continent == "africa"){ continentcodes[i] = "#3e9d01"; mapobject.series.regions[0].setvalues(continentcodes); } }); }); but repeating each statement , can not dynamic continents. here jsfiddle so heres js: jquery(function(){ //json markers var markers = [{latlng: [-34.033333300000000000, 23.066666700000040000], name: 'knysna', info:'its got lake...'}, {latlng: [-33.924868500000000000, 18.424055299999963000], name: 'cape

In Ubuntu how can I execute multiple simultaneous terminals from PHP? -

i have script in php run cli. inside script have following loop: foreach($array $key => $value){ exec("gnome-terminal -e php myscript.php $key $value > /dev/null"); } what expecting happen new terminal pop , run script , related arguments simultaneously in separate terminal windows. being able visualize data debugging. after confirm script working correctly, want run in background command: exec("php myscript.php $key $value" > /dev/null &); however, neither working expected. second command, though runs, still waits first script finish before goes next iteration of loop. i'm using ubuntu 12.04. how can these run simultaneously debugging, , simultaneously , silently in background when not? since you're running php process, have considered using fork? http://php.net/manual/en/function.pcntl-fork.php

sql - Selecting data not matching query -

i want select data not match query. say have 2 tables: cars: id int primary key identity make varchar(255) not null model varchar(255) not null pricegroup varchar(1) not null rentals: id int primary key identity sdate date not null edate date not null car_id int not null sdate in rentals starting date of rental - edate end date. i want find available cars between specified time period. this query works: select * cars id not in (select car_id rentals sdate <='2013-04-28' , edate >='2013-04-30') however, works specific dates. if enter period between 2013-04-25 , 2013-05-30 cars shows up, though of them booked in between period. i use ms sql 2012. you need compare dates other way around: select * cars id not in (select car_id rentals sdate <='2013-04-30' , edate >='2013-04-28') also, using not exists may g

How to make Google Analytics Data public? -

is there way show google analytics data ga account on web site without user authentication? show popular pages, , perhaps popular searches , on. looking way wouldnt need me build proxy service on api , subject quotas , limits , on. ga not offer way access data without user authentication, through api.

.net - Given simple type T, get array type T[] -

this question has answer here: how create instance of array type given elementtype? 1 answer how can type of array of type t given t ? linqpad-friendly snippet below: void main() { type t = typeof(string); type tarray = getarraytype(t); tarray.dump(); // system.string[] } type getarraytype(type t) { ////this cheating !! //return typeof(string[]); } this trick: type.makearraytype() eg: int = 123; type atype = a.gettype(); type aarraytype = atype.makearraytype(); // aarraytype.fullname = "system.int32[]"

asp.net mvc 4 - Textchanged event in mvc for a Textbox -

i beginer in mvc.i working on application need change value of textbox after enter value in , press tab.for example when enter 1 in textbox , press tab should display +1 ie need concatinate + sign text enter.so trying raise textchanged event textbox.how can it.when googled found can done using javascript.but dont know how that,pls give me suggessions. code: @html.textboxfor(m => m.text)--textbox you use jquery , subscribe blur event triggered when input field looses focus: $(function() { $('#id_of_your_textbox').blur(function() { var value = $(this).val(); var newvalue = value + '1'; $(this).val(newvalue); }); }); if don't want use javascript framework such jquery achieve same plain javascript: window.onload = function() { document.getelementbyid('id_of_your_textbox').onblur = function() { var value = this.value; var newvalue = value + '1'; this.value = newvalu

java - Can't Get ActionListener to work -

here code, account basic class doesn't special. have tried action listener work , know missing silly. made gui in jigloo , think problem in actual main? need add something? or going wrong. never done gui stuff before. first programming class have taken , professor seems think should able without issue. ideas? import java.awt.event.actionevent; import javax.swing.jbutton; import javax.swing.jeditorpane; import javax.swing.jtextfield; import javax.swing.windowconstants; import javax.swing.swingutilities; import java.awt.event.actionlistener; @suppresswarnings("serial") public class button extends javax.swing.jframe implements actionlistener { public jbutton loginbutton; public jtextfield bankinfobutton; public jbutton transgerbutton; public jbutton jbutton1; public jtextfield moneytextfield; public jtextfield sendto; public jeditorpane account1; public jtextfield accountpw; public jtextfield accountname; public jbutton bal

aes - Decrypt file in java failing on hash verification -

i using sample code project - c# implementation of encryption, in java http://www.codeproject.com/articles/8633/file-encryption-decryption-with-hash-verification?msg=2175833#xx2175833xx on decryption, file gets decrypted on verifying current hash old hash, last few bytes of old hash zeros , verification fails. my java implementation of decrypt this: private void mdecrypt_file(fileinputstream fin, string outfile) throws exception { fileoutputstream fout = new fileoutputstream(outfile); byte[] iv = new byte[16]; byte[] salt = new byte[16]; byte[] len = new byte[8]; byte[] fc_tagbuffer = new byte[8]; cipher cipher = cipher.getinstance(cipher_instance); datainputstream dis = new datainputstream(fin); dis.read(iv, 0, 16); dis.read(salt, 0, 16); rfc2898derivebytes rfc = new rfc2898derivebytes(default_password, salt, f_iterations); secretkey key = new secretkeyspec(rfc.getbytes(32), "aes"); //decryption code cip

service - Android: How to restrict specific apps -

in app, need block sms, email , phone. not detecting incoming or outgoing calls or sms . simply, have service run in background , check if of 3 processes running. if running activity open when user clicks on dialer or sms app. far, have tried, posting below: service class public class dialerservice extends service { activitymanager am; list<runningappprocessinfo> mappprocessinfoslist; private runnable myrunnable; boolean threaddone = true; handler mhandler; boolean islockedapprunning = false; @override public ibinder onbind(intent arg0) { return null; } public void oncreate() { = (activitymanager) getsystemservice(context.activity_service); mappprocessinfoslist = new arraylist<activitymanager.runningappprocessinfo>(); mhandler = new handler(); log.v("dialer service", "oncreate called"); } @override public int onstartcommand(intent intent, int flags, int startid) { myrunnable = new runnable() { @override

html - src image changer after click with JavaScript -

i have image in html page: <img src="/images/deactivate.png" onclick="act_deact(this);"/> and in javascript code have this: function act_deact(image) { image.src = (image.src=="/images/activate.png" ) ? "/images/deactivate.png" : "/images/activate.png"; } and when click on image deactivated activate in second click doesn't desactivate ! is there probleme code ? from js amateur :) this because when set to(or changes to) /images/activate.png on first click, src attribute no longer /images/activate.png gets prefixed server-address. you can check here: http://jsfiddle.net/hgcqq/ or on own server, use console.log or alert if prefer.

javascript - Dealing with variables in click event -

i've created canvas dynamically using following function : var animating=false; function create_canvas(container,id,width,height) { ...//set width,height //added click event listener document.getelementbyid(id).addeventlistener("click", function () { if(animating==true) { alert("running animation"); //can't reach part return; } else { animating=true; run_canvas(); animating=false; } }); ...//append container } function run_canvas() { ...//some code here } now whenever click on canvas animation starts no matter what. mean global variable animating doesn't it's value changed. hence question : doing wrong , how should deal kind of situation . the run_canvas method presumably executes animation code asynchronously, statement after sets animating property false e

java me - Core Google Map API for J2ME -

i using http url show map in j2me application takes more time draws image on each refresh. since internet speed bit slow in gprs. is there core google map api j2me?? is com.jappit.midmaps.googlemaps.googlemaps authorized google map library j2me application?? waiting reply. regards, parmanand no, there not core google map api j2me. no, jappit library not official authorised product, though attempt mapping library based on technology available @ time. the reason update of map slow in jappit library, underlying static mapping service behind not suited refreshing , updating dynamic map. every time map shifted or updated, image size of screen downloaded leading large amount of data traffic. better solution can found in using map tile service, implement aggressive image caching , adding overlay objects on top of it. doing avoid downloading more images. so in summary use web service static maps api , if need single map image. use dedicated java me mapping l

Parse JSON to java Class -

i have json , i'm trying parse java classes using gson. here json resp = "{"isvisible":true,"image":{"preferenceorder":["rose","lilly","lotus"]}}"; my parse code java this. imageorderresult result = new gson().fromjson(resp,imageorderresult.class); and here class have defined public class imageorderresult { //used general error tracing public string status = ""; public string message = ""; public string errortrace = ""; public class image{ @serializedname("preferenceorder") public arraylist<string> flowers= new arraylist<string>(); } @serializedname("isvisible") public boolean isvisible= false; } here i'm missing out flowers array part. parser not able fetch list of values. how solve it? the problem have type of image defined, class missing reference variable "stor

html5 - Jquery event on close class button in alert of Bootstrap -

i want perform jquery event on clicking close sign on alert block of jquery. view code below:: <div class=' alert alert-block fade in' > <button type='button' class='close' data-dismiss='alert'>×</button> <p>just close me </p> <div> my js code below:: $('button.close').click(function () { var id = $(this).attr('data-id'); alert("deleted list is"+id); }); as per above code not able detect or jquery events on clicking 'x' button. if you're using bootstrap 3, need this: $('#my-alert').on('close.bs.alert', function () { //code });

localization - Where's the 3-way Git merge driver for .PO (gettext) files? -

i have following [attr]pofile merge=merge-po-files locale/*.po pofile in .gitattributes , i'd merging of branches work correctly when same localization file (e.g. locale/en.po ) has been modified in paraller branches. i'm using following merge driver: #!/bin/bash # git merge driver .po files (gettext localizations) # install: # git config merge.merge-po-files.driver "./bin/merge-po-files %a %o %b" local="${1}._local_" base="${2}._base_" remote="${3}._remote_" # rename bit more meaningful filenames better conflict results cp "${1}" "$local" cp "${2}" "$base" cp "${3}" "$remote" # merge files , overwrite local file result msgcat "$local" "$base" "$remote" -o "${1}" || exit 1 # cleanup rm -f "$local" "$base" "$remote" # check if merge has conflicts fgrep -q '#-#-#-#-#' "${1}" &am

c# - Find all articles that contain words with linq -

trying learn linq bumping against wall here. im trying find articles contain multiple strings, not sure how use .contains when passing in list. private void searcharticles() { adminentities db = new adminentities(); var searchstrs = new list<string> {"search_string1", "search_string2"}; var artlistfull = db.view_m02articles_searchpublished(0, "").tolist(); var artlist = artlistfull.findall(n => n.bodytext.contains(searchstrs)); label1.text = artlist.count.tostring(); repeater1.datasource = artlist; repeater1.databind(); } what wold correct syntax here? [edit] supposing bodytext of type string you can try this: //the article body must contain "all" search terms var artlist = artlistfull.where(art => searchstrs.all(art.bodytext.contains)); or //the article body must contain "at least one" of search terms var artlist = artlistfull.where(art => searchstrs.any(art.body

r - read.table reads "T" as TRUE and "F" as FALSE, how to avoid? -

i have file data c("a","t","b","f") . when use: read.csv(myfile,header=f,stringsasfactors=f) r interprets character t true , f false am doing wrong? if columns characters try this: # replace text = . filename read.csv(text="a,b,t,t", header=false, stringsasfactors=false, colclasses = c("character")) else, you'll have pass type of each column in colclasses as: colclasses = c("numeric", "numeric", "character", ...)

javascript - HTML5 currentTime not working in PhoneGap -

i'm using phonegap , making app samsung galaxy tab 2. i'm trying play mp4 video starting @ specific time. using code video starts beginning, , not 20 seconds in. wrong? function ondeviceready() { var playerdiv = document.getelementbyid('player'); playerdiv.innerhtml="<video id='video' src='"+window.localstorage.getitem("selectedvideo")+"' loop='loop' width='1285' height='752'></video>"; document.getelementbyid("video").addeventlistener("loadedmetadata", function() { this.currenttime = 20; }, false); } function playvideo() { document.getelementbyid('video').play(); } i have tried this, still starts beginning: document.getelementbyid('video').addeventlistener('loadedmetadata', function() { this.currenttime = 20; this.play(); }, false); and using canplay insted of loadedmetedata not work. h

python - TypeError: <lambda>() takes no arguments (1 given) -

i newbie python programming , still trying figure out use of lambda. worrking on gui program after googling figured need use buttons work need to this works mtrf = button(root, text = "off",state=disabled,command = lambda:b_clicked("mtrf")) but when same scale does not work leds = scale(root,from_=0,to=255, orient=horizontal,state=disabled,variable =num,command =lambda:scale_changed('led')) scale calls function passed command 1 argument, have use (although throw away immediately). change: command=lambda: scale_changed('led') to command=lambda x: scale_changed('led')

javascript - too many decimals + styling not visible on website -

my script below displays many decimal points in return value also, when posted code onto website, did not display text styling added can please tell me im missing? thanks <html> <head> <style> body {color:rgb(128,128,128);} p.3 {color:rgb(128,128,128);} p.3 {font-size:20px;} </style> <script type = "text/javascript"> function convert() { var amount=document.getelementbyid('amount'); var currency=document.getelementbyid('currency'); var converted=document.getelementbyid('converted'); var choice=document.getelementbyid('choice'); var aed=1; var us=0.27; var qr=0.99; var sr=1.02; var kd=0.0778; var bd=0.102; switch(document.converter.currency.value) { case "us dollars" : document.converter.converted.value=us*document.conver

java.rmi.ConnectException: Connection refused to host with spring RMI -

i trying develop small spring rmi example. i have created remote service interface , service follows, calculation.java package com; public interface calculation { string getname(string name); } calimp: package com; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; public class calimp implements calculation { static void init(){ applicationcontext context = new classpathxmlapplicationcontext("applicationcontext.xml"); context.getbean("calculationbean"); } string names; public string getname(string name){ return names; } } my application context file is <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframew

How do I modify a configuration file using python? -

i have cfg file. in cfg file there line like: [environment] automation_type=gfx ;available options: gem, hexaii i want modify line by: [environment] automation_type=abc ;available options: gem, hexaii i have written below code this: get_path_for_od_cfg = r"c:\users\marahama\desktop\abdur\abc_mainreleasefolder\od\od\odconfig.cfg" config = configparser.rawconfigparser() config.read(get_path_for_opendebug_cfg) sec in config.sections(): attr in config.options(sec): if sec =='environment' , attr == 'automation_type': config.set('environment','automation_type','abc') open(get_path_for_opendebug_cfg, 'wb') configfile: config.write(configfile) after executing code, get [environment] automation_type = abc ";available options: gem, hexaii" line missing. as source code suggests, when reading config files, comments ignored, both on sepa

Nunit-C#: run specific Tests through coding -

i using selenium c# automation, , want invoke nunit through code follows: coreextensions.host.initializeservice(); testpackage testpackage = new testpackage(@"d:\automation\bin\debug\test.dll"); remotetestrunner remotetestrunner = new remotetestrunner(); remotetestrunner.load(testpackage); //testfilter filter = new namefilter(new testname() { name = "test1" }); testresult testresult = remotetestrunner.run( new nulllistener(), testfilter.empty, false, loggingthreshold.off ); i able run tests using category filter below remotetestrunner.run( new nulllistener(), new categoryfilter("mycat"), false, loggingthreshold.off ); but want execute specific tests. how set suite filter? have tried following, not work: testfilter filter = new namefilter(new testname() { name = "test1" }); testresult testresult = remotetestrunner.run( new nulllistener(), filter, false, loggingthreshold.off ); how r

spring mvc - Dynamically put JSP tag on a JSP page -

i’m doing first steps in spring mvc , jsp , i’m trying figure out what’s best way following: i need create dynamic page made static html , dynamic widgets appear on page per business logic. each widget div content: 1 widget might show trend while other widget might show table, etc. need decide on run time widget put on specific position in page , place there. in other words, need dynamically replace place holder in jsp file jsp tag file or else provide widget html. can wrapping each placeholder if or switch statements want know if there cleaner way that. thanks, yosi if want see included when, right away in code, ide code navigation support, list of <c:when> way go. dynamic includes (e.g. <jsp:include page="${widgetname}" /> ) make code shorter sure, less easy understand what's going on.

Parsing Json in Groovy -

i have following json string: [ { id: '123', name: 'bla bla', type: 'source', isleaf: true }, { id: '3425', name: 'test test', type: 'reference', isleaf: false }, { id: '12678', name: 'tags', type: 'source', isleaf: false }, ] i trying parse using jsonslurper getting error: groovy.json.jsonexception: lexing failed on line: 1, column: 5, while reading 'i', no possible valid json value or punctuation recognized. how parse , access id:'3425' ? your json invalid, need use double quote delimit strings , need put quotes around keys in json so: [ { "id": "123", "name": "bla bla", "type": "source", "isleaf": true }, { "id": "3425", "name": "test test", "type": "reference", "isleaf": false }, { "id": "12678", "name&

symfony - REST API and client on same server, need API authentication? -

first, let me describe application: working on web-based software kind of custom desk application. requires user login (we use fosuserbundle ). after login user redirected dashboard. dashboard there no more page reload, frontend build on angularjs , user can anywhere within application without page reload. speak of single page application. so data presented user, fetched rest api (we use fosrestbundle ). works quite @ point. there kind of dilemma. our staff access application (for now). staff member needs login access helpdesk. data pushed frontend via angularjs called via api, user has logged in needs authenticate again on every request because of rest. problem: since backend runs on symfony2 let try user object of logged in user when api call made: $this->get('security.context')->gettoken()->getuser() returns anon. stands anonymous, or $this->getuser(); returns null . so authenticated context seems gone when using rest api. when call action

multithreading - agent based programming using native programming language -

so interested in building agent-based simulation of battleground. there lot of frameworks agent-based models such jade, etc.. due constraint, can implement using native programming language example c++ or java without frameworks or libraries. i've searched in google can't seem find tutorials on agent-oriented programming. where should start? or there tutorials complete beginner in agent-based programming? thx b4 look @ frameworks: relacy , sobjectizer

How can you print any number in words in Python? -

this question has answer here: how tell python convert integers words 12 answers without using library function how can print number in words in python? there answers using library function want core code.. like: 12345 = "twelve thousand 3 hundred , fourty five" 97835200 ="nine core seventy 8 lakh thirty 5 thousand 2 hundred" 230100 = "two lakh thirty thousand 1 hundred" code this: >>>def handel_upto_99(number): predef={0:"zero",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine",10:"ten",11:"eleven",12:"twelve",13:"thirteen",14:"fourteen",15:"fifteen",16:"sixteen",17:"seventeen",18:"eighteen

What's the easiest / most efficient way to pause setInterval while data is loading? JavaScript/Jquery -

so have js interval doing load command on script.. , displays loaded data on div.. everything perfect until put project online , saw issue (in background).. since setinterval needs set @ 1 second interval , , lot of times time takes data load more 1 second, see load stacking happening in background... since setinterval continues fire $.load() calls every second regardless of loaded data.. i thinking of setting global variable "is_loading" add function in interval, skip rest of routine incase "is_loading" true, .. once recent load call completes, sets is_loading = false.. this way interval keeps firing / second w/o load calls stacking in background... however, since have several intervals doing loads on page (pls dont ask why lolz) find quite tedious w/ every interval.. therefore wondering there can "globally" event listener of sort current unfinished loading/get/post happening on page? suggestions great like others have said, use s

c# - How to refer to an object name through a variable? -

i have code open sqllite database, street names, , populate list box attached combo-box can suggest names user types them. want make procedure can call since used on may different combo-boxes. can pass name of control, how modify attributes of contol while referring variable? something like: string = "cbstreets" [a].text = "sets text combo box." if point me in right direction appreciate it. instead of passing name of control, why not pass control (especially if they're comboboxes , same type?) alternatively if reason can't pass control itself, set datastructure dictionary if need use string name: dictionary<string, combobox> comboboxes = new dictionary<string, combobox>(); //use string want refer combobox , combobox item comboboxes.add("bcbstreets", combobox1); //use name defined in previous step reference combobox , //set text comboboxes["bcbstreets"].text = "whatever";

ios - AVMutableAudioMixInputParameters setVolume atTime not working only with kCMTimeZero -

im developing ios app in xcode. still new programming. trying set volume of audiotrack while playing avplayer . working great if set time @ kcmtimezero want set volume 1 second after button pressed. not working - (ibaction)maxvolbuttonpressed:(id)sender { [audioinputparams1 setvolume:1 attime:time1]; [self applyaudiomix]; } working - (ibaction)minvolbuttonpressed:(id)sender { [audioinputparams1 setvolume:0 attime:kcmtimezero]; [self applyaudiomix]; } what should write after attime if want 1 second delay? answer: ok figured out. have add time current item @ moment. use setvolumerampfromstartvolume little time interval instead of setvolume. setvolume fades given volume reason haven't figured out why. works me this: cmtime time1 = cmtimemake(1000, 1000); //2s cmtime time2 = cmtimemake(1001, 1000); //3s cmtime timecurrent = [player currenttime]; cmtime time1added = cmtimeadd(timecurrent, time1); cmtime time2added = cmtimeadd(timecurrent, time2);

How do I convert from Integer Queue to String? -

ok, have simple, inefficient program, that's alright, thing know how print first 5 numbers of queue zeros without changing values of ssn1 through ssn5. for example print 000001111, , not 111111111, still have values stored in queue. me that? hide them. i trying convert integers of queue string, create substring, , print dummyint 5 time followed substring. import java.util.*; public class ssnqueue { public static void main (string args[]) { scanner scan = new scanner(system.in); queue<integer> ssn = new linkedlist<integer>(); int dummyssn = 0; system.out.println("please enter each digit number of ssn"); system.out.print("enter digit number 1: "); int ssn1 = scan.nextint(); system.out.print("enter digit number 2: "); int ssn2 = scan.nextint(); system.out.print("enter digit number 3: "); int ssn3 = scan.nextint(); system.out.print("enter digit number 4: "); int ssn4 = scan.nextint();

python - newline causes SyntaxError: EOL while scanning string literal -

an ipad application sends json me , read request.post.get , pars ast.literal_eval u'[\n {\n "type" : 2,\n "datecreated" : "wed, 24 apr 2013 17:20:50 0100",\n "datestart" : "wed, 24 apr 2013 18:00:00 0100",\n "appointmentid" : 0,\n "withp" : [\n\n ],\n "seentime" : null,\n "ofcwithid" : 2,\n "ofclientwithid" : 68,\n "dateend" : "wed, 24 apr 2013 19:00:00 0100",\n "comments" : "test test test\n.\n( ) \'\' test \'\' \' test \'\n",\n "inlocation" : null,\n ...bla bla bla...]' i error: 'comments' : 'test test test ^ syntaxerror: eol while scanning string literal i can understand newline character problem don't know how solve it. i'm using django 1.4.2 python 2.7.3 i appreciate help try add \'\'\' @ beginning of string , @ e

Close an specific activity android -

just, how can close specific activity of application? for example have activities: a1 > b1 > c1 and in c1 can go activity again new params when open new b (b2), want close older activities: a1, b1, c1. being new result: a2 > b2 where can go a2 after of b2, , finish app a2. you have 2 ways this: you can use activity declaration such single top . or can pass data between activities using start result . on onactivityresult call finish();

Delphi TChart TowerSeries stacked -

i'd have 3d-tchart 2 stacked tower-series. think, possible since 2012 in tchart .net ( http://www.steema.com/entry/87/new_tower_series_stacked_for_teechart_for_.net_ ). is property available in tchart delphi 7? or maybe it'll available in future versions?

mysql - PHP Open Multiple Connections -

i run multiple scripts instances of same script in different browser tabs. , them have different mysql connections. each unique connection. i know mysql_connect has fourth parameter $new_link should open new link, not open new connection, usually. does. i have xampp install on widows machine. the question is: how can absolutely force php/mysql open new connections each instance of script? script runs 2mins. http://localhost/myscript.php here excerpts of mysql code. first load work assignment db , mark in progress: public function loadrange() { try{ $this->db()->query('start transaction'); $this->row = $this->db()->getobject(" select * {$this->tableranges} status = " . self::status_ready_for_work . " , domain_id = {$this->domainid} order sort asc limit 1"); if(!$this->row) throw new exception('could not load

ruby on rails - rails3 user can only vote once per day -

class rate < activerecord::base attr_accessible :image_id, :rate, :user_id belongs_to :image belongs_to :user validate :user_can_rate_after_one_day before_save :default_values def default_values self.rate ||=0 end protected def user_can_rate_after_one_day r=rate.where(:image_id =>image_id, :user_id=> user_id).order("created_at desc").limit(1) if( (time.now - 1.day) < r[0].created_at) self.errors.add(:rate,"you can vote once per day") else return end end end i have 1 rate model, , want user can rate once per day. write user_can_rate_after_one_day method validte it. if delete function, user can rate many time, if add function, user can not rate it. knows what's wrong here? thanks

tsql - Reading Deleted or Update Value from the Open Transaction -

i trying open transaction , delete 1 record need insert deleted record event table. problem can't see result because has been deleted. create procedure [dbo].[testdata] ( @clientid bigint ) begin print ''abc'' insert client_event_log values ( getdate(),0,@clientid,100,''b0ae3162-671c-e211-af2a-00155d051024'',null) begin try begin tran delete access_types -- there record in table. 8559230 abc 101 0 2010-01-01 10:25:25.000 select * access_types -- cann't see deleted record before session. declare @cgtaeventlog bigint select @cgtaeventlog=access_type_id access_types      exec testdata @cgtaeventlog -- passing 8559230 sp insert event table has been delete before can't insert null commit tran end try begin catch rollback tran --error message print 'error: ' + convert(varchar,error_nu

ios - In what format is this date string? -

im trying convert bunch of nsstrings nsdate objects. here example string: 2013-04-25t15:51:30.427+1.00 but can't figure out format in, far have (the question marks bits i'm stumped with): yyyy-mm-ddthh:mm:ss????zzz the main problem i'm having '.427' part although if i'm making mistake elsewhere, let me know :) does have ideas? or point me list of possible date format specifiers? found this: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx useful doesn't appear have specifier '.427' part i'm stuck on. any appreciated, thanks. the proper format yyyy-mm-dd't'hh:mm:ss.ssszzzzz . see unicode date format patterns . also, zzzzz format +00:00 timezone format added ios 6 , not supported under ios 5 or earlier.

android - ImageView with no source does not honor layout, adding source does not repair layout -

my base layout listview of linearlayouts, , each item in grid framelayout below. downloading image imageview. prior image being loaded, there no content , layout shrunk height of small progressbar (first problem), when expect 240dp or 120dp. after image placed in view, layout not adjust (second problem) , height remains shrunken dimension of small progressbar. loading image code: @override public view getview(view convertview) { // ... // set holder // ... new getphototask().execute(holder.my_tile_image, holder.my_loading, my_media_url); holder.my_tile_image.setvisibility(view.invisible); holder.my_loading.setvisibility(view.visible); holder.my_tile_label.settext(activityobject1.track.name); // ... } private final class getphototask extends asynctask<object, void, drawable> { imageview iv; progressbar pb; @override protected drawable doinbackground(object... params) { iv = (imageview) params[0]; pb = (

sql server 2008 - SQL Database Date Ranges -

i have flat table holds status updates. these updates stored in following format: agreementid | statusid | statusdate source data: agreementid statusid statusdate 109 1 14/01/2013 15:00:33 109 2 14/01/2013 15:01:28 109 2 14/01/2013 15:01:28 109 2 14/01/2013 15:02:42 109 2 26/02/2013 16:27:38 109 2 26/02/2013 16:27:45 109 8 19/02/2013 13:57:33 109 8 04/03/2013 16:46:29 109 8 18/03/2013 14:08:12 109 8 18/03/2013 14:47:00 109 8 18/03/2013 14:48:46 109 9 26/03/2013 15:41:51 what needing map agreement status in date ranges, agreement can have multiple status updates of same statusid, once agreement goes onto next statusid cannot step backwards previous status id. for last status date range should statusdate date. i have got following piece of code, resul