Posts

Showing posts from September, 2010

.net - Convert Bitmap to BitmapSource -

i have problem converting bitmap bitmapsource, write http://www.codeproject.com/kb/wpf/bitmaptobitmapsource.aspx?msg=3590727 , exceptions: first chance exception of type 'system.invalidoperationexception' occurred in windowsbase.dll :/ must convert bitmap bitmapsource, beacouse use aforge.net caputer image webcam. know why exception ? ( works winforms ) or mayby know library looking similarity aforge can use wpf? my code: private void newframehandler(bitmap bitmap) { bitmapsource bitsrc = null; var hbitmap = bitmap.gethbitmap(); bitsrc = system.windows.interop.imaging.createbitmapsourcefromhbitmap( hbitmap, intptr.zero, int32rect.empty, system.windows.media.imaging.bitmapsizeoptions.fromemptyoptions()); image1.source = bitsrc; } the code looks me, though need use pinvoke method deleteobject release memory used hbitmap. the reason can think of failing, there wrong bitmap being converted.

sql - mysql error 150 Foreign keys -

whenever insert table xxx: alter table xxx add index fk68c3166c7b556202 (my_yyy_id), add constraint fk68c3166c7b556202 foreign key (my_yyy_id) references yyy (yyy_id) ...i get: 19:27:44,355 error schemaupdate:212 - unsuccessful: alter table xxx add index fk68c3166c7b556202 (my_yyy_id), add constraint fk68c3166c7b556202 foreign key (my_yyy_id) references yyy (yyy_id) 19:27:44,356 error schemaupdate:213 - can't create table 'mydb.#sql-2f1b_657' (errno: 150) why? how resolve issue? it's hard guess wrong without details, there common mistakes might make : 1. yyy.yyy_id not unique/primary key 2. yyy.yyy_id , xxx.my_yyy_id have different types (e.g. yyy_id unsigned int , xxx.my_yyy_id int )

rest - What protocol to use in client-server app communication with python? -

i need client-server application, client made python-gtk, procedures on server-side free client of workload. so did search on google client-server protocols , found corba , rpc closer had in mind, want made app ready accept web , mobile clients, found rest , soap. from reading found myself doubts, should implement 2 different protocols, 1 gtk-client (like rpc or corba) , web , mobile (rest or soap)? can use rest or soap all? i've implemented webservices using soap/xmlrpc (it easy support both, framework using @ time made pretty trivial) before; had thought using standard http without soap/xmlrpc layer (before aware rest had name :) decided against in end because "i didn't want write client-side code handle datastructures". (the perl client had easy soap/xmlrpc apis.) in end, regretted decision made: have written code handle datastructures myself in afternoon (or @ day) -- or if had chosen use json, 2 hours. burden of soap/xmlrpc api , library depe...

c++ - Programming problem with a continuous loop and buttons? -

i have design program uses main loop keep track of time , perform continuous checks. have gui system can alter things in system. question is: if run continuous loop doesnt stop until system exits, user able interact gui have set up, or loop have stop running effect of pressing button take place? in other words, have pause loop, run button command, restart loop, everytime user interacts gui? , if so, there way around this? , answer since didn't state platform, term reply generically. there 2 patterns can use: polling or interrupt / event driven. polling the polling involves checking semaphore or flag see if happened. common in embedded systems. background loops until interrupt sets flag processes event. interrupt / event driven. in pattern, function executed when event occurs. example, function may executed when user clicks on button. on desktop platforms (mac, linux, windows, etc.), situation resolved using multiple threads (of execution). gui ope...

ClassNotFoundException on a JUNIT ant script -

i have written few test scripts using junit 4 , selenium. have added jar files junit , selenium eclipse , if run tests through eclipse ide working expected. i trying run these tests through ant script below: <project name="junit" default="test"> <property name="src" value="./src" /> <property name="classes" value="./classes" /> <property name="test.class.name" value="alltests" /> <path id="test.classpath"> <pathelement location="${classes}" /> <pathelement location="c:/program files/eclipse 3.5/plugins/org.junit4_4.5.0.v20090824/junit.jar" /> <pathelement location="c:/selenium/selenium-server-standalone-2.0b2.jar" /> <pathelement location="c:/program files/eclipse 3.5/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar" /> </path> <target...

iphone - Fill a circle with an outline -

i need draw filled circle, , needs have outline different colour. right i'm doing creating 2 circles, , filling 1 stroking other. cgcontextfillellipseinrect(context, cgrectmake(10, 10, 80, 80)); cgcontextstrokeellipseinrect(context, cgrectmake(10, 10, 80, 80)); the problem circle looks little offset , uneven. there function allows simultaneous drawing of circle outline in single line? try adding thickness outline stroking larger pen line width. may need inset rectangle of half width of pen.

Android: Transparent WebView over Camera Preview -

just general question , maybe has idea: possible have transparent webview on camera surfaceview , use html/css creating overlay? <!-- in xml --> <webview android:id="@+id/webkit" android:layout_width="200dip" android:layout_height="wrap_content" android:maxwidth="200dip" android:maxheight="200dip" android:layout_marginbottom="4dip" android:adjustviewbounds="true" android:visibility="gone" /> // oncreate barcodebrowser = (webview)findviewbyid(r.id.webkit); ... // somewhere in runtime barcodebrowser.setvisibility(view.visible); string downloadlink = "http://stackoverflow.com/questions/1260422/setting-webview-background-image-to-a-resource-graphic-in-android"; barcodebrowser.setbackgroundcolor(colo...

ssl - sslv3 alert illegal parameter using Net::HTTP in Ruby on Linux -

i attempting use remote system user authentication. chunk of code gets response when run on macosx, fails on machine: def create uri = uri.parse('https://ourclient.example.com/') http = net::http.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = openssl::ssl::verify_none request = net::http::post.new('/login.jsp') request.set_form_data({'login_name' => params[:login], 'password' => params[:password]}) response = http.request(request) puts "response body: #{response.body.inspect}" end turning verify off gets rid of warning on macs. on machine, http.request raises exception: openssl::ssl::sslerror (ssl_connect returned=1 errno=0 state=sslv2/v3 read server hello a: sslv3 alert illegal parameter): app/controllers/sessions_controller.rb:16:in `create' i same behavior using irb without rails. did clean install of fedora 14 yesterday, installed required development tools , libra...

python - Importing classes from different files in a subdirectory -

here's structure i'm working with: directory/ script.py subdir/ __init__.py myclass01.py myclass02.py what want import in script.py classes defined in myclass01.py , myclass02.py . if do: from subdir.myclass01 import * it works fine class defined in myclass01.py . solution if there many classes defined in different files in subdir , want import of them, i'd have type 1 line each file. there must shortcut this. tried: from subdir.* import * but didn't work out. edit : here contents of files: this __init__.py (using __all__ apalala suggested): __all__ = ['myclass01','myclass02'] this myclass01.py : class myclass01: def printsomething(): print 'hey' this myclass02.py : class myclass02: def printsomething(): print 'sup' this script.py : from subdir import * myclass01().printsomething() myclass02().printsomething...

playframework - Play Framework User Authentication/Membership -

i want support user authentication in play application. web app , think built-in "secure" module simple needs. in fact, user group discusses how secure module demonstration purproses. however, how can develop such system? essentially, application allow user login , have own settings , forth applied throughout application. there pages unauthenticated users can view if client authenticated, view of pages different. pretty simple setup documentation refers simple secure module. if special requirement pages publicly visible, i've got answer: play framework: how require login actions, not all . copied secure module , made few small additions.

ruby on rails - Rendering an image -

so should pretty easy, yet can't work. i have controller method finds image based on query, output gets cached. image remote (flickr, google images, etc) or local. regardless of source, need take image file contents, , pass through user. in essence, proxy. passing through remote images seems work fine, passing through local images gives me a: invalid byte sequence in utf-8 so here's got. i'm hoping can solve problem or guide me in better direction code. def image_proxy query = params[:query] image_url = get_image_url(query) # returns absolute local file path or url response.headers['cache-control'] = "public, max-age=#{12.hours.to_i}" response.headers['content-type'] = 'image/jpeg' response.headers['content-disposition'] = 'inline' render :text => open(image_url).read end remote files work fine, local files don't. bonus can solve other issue: i need set proper content type. remote image...

c++ - Increasing MAXIMUM_WAIT_OBJECTS for WaitforMultipleObjects -

what simplest way wait more objects maximum_wait_objects ? msdn lists this: create thread wait on maximum_wait_objects handles, wait on thread plus other handles. use technique break handles groups of maximum_wait_objects . call registerwaitforsingleobject wait on each handle. wait thread thread pool waits on maximum_wait_objects registered objects , assigns worker thread after object signaled or time-out interval expires. but neither them clear. situation waiting array of on thousand handles threads. if find waiting on tons of objects might want io completion ports instead. large numbers of parallel operations iocp more efficient. and name iocp misleading, can use iocp own synchronization structures well.

iphone - Predictive dictionary text input API/framework for with iOS apps -

i have been looking while 'predictive dictionary' used iphone , other other phones increase text input accuracy suggesting words. does know if such dictionary available objective c/ios? or way/tools create 1 scratch? many redirects/links/replies, christian did consider using uitextchecker ?

php - How to configure a vhost for zendframework? -

i configure vhost zf, have no idea how it, please if great. thanks the process of creating virtual host, depends on version of apache , overall remains same. apache (scroll down apache2 ) if using regular apache, such apache on mamp stack or centos, following. edit httpd.conf file, in apache conf directory, add end of file. (if using mamp, in applications/mamp/conf/apache otherwise should in /etc/apache/conf) namevirtualhost *:80 <virtualhost *:80> servername quickstart.local documentroot /applications/mamp/htdocs/quickstart/public setenv application_env "development" <directory /applications/mamp/htdocs/quickstart/public> directoryindex index.php allowoverride order allow,deny allow </directory> </virtualhost> after this, restart apache, sudo /etc/init.d/apache restart or restart via xamp stack client if exists. you need let browser aware of domain name ...

AJAX & Python: Response text from python script is an object -

edited out silly mistake i using ajax access python script, text python script & display on webpage. my problem: response text "undefined" when should "bbbb" i confused going wrong? python script incorrect (not handling ajax (?requests?) correctly), javascript or wsgi server made? html & javascript: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> <!-- function post( dest, params ) { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie...

c++ - How to hook AllocMem(), FreeMem() etc... calls ? It can be by any kind of technique dll, executable, etc -

i'm trying hook events related memory allocation create external debugger have no need of implementation on source code. need hook theses calls, 1 know how ? like, http://www.itworld.com/uir000929interposers runs on windows too. c/c++ implementations or ideas welcomed too. tks tks answers, i'll make tests find best alternative. i checkout answers no available solutions now. i'm searching , researching self too. if discovery thing new i'll post here. you might want check microsoft's detours . jeffrey richter's books on windows programming contain similar library.

algorithm - Efficient way to make two pairs in python -

i make 2 pairs pairs. pair consists of 2 elements, , two-pair consists of 2 pairs. here list of constraints: in pair, order of elements important: (element1, element2) != (element2, element1) in two-pair, order of pairs not important: (pair1, pair2) == (pair2, pair1) i wrote pseudo code satisfies above constraints follows: class pair: def __init__(self, element1, element2): assert isinstance(element1, element) assert isinstance(element2, element) self.element1 = element1 self.element2 = element2 def __eq__(self, other): if not isinstance(other, pair): return false if self.element1 != other.element1: return false if self.element2 != other.element2: return false return true def __ne__(self, other): return not (self.__eq__(other)) def __hash__(self): return hash(self.element1) ^ hash(self.element2) def getfirst(self): return self....

Import SQL file into mysql -

i have database `nitm`. haven't created tables there. have sql file contains necessary data database. file `nitm.sql` in `c:\ drive`. file has size of 103m. using wamp server. i have used following syntax in mysql console import file. mysql>c:/nitm.sql; but didn't work. from mysql console: mysql> use database_name; mysql> source path/to/file.sql; make sure there no slash before path if referring relative path... took me while realize that! lol

c++ - Environment variables are different for dll than exe -

i'm debugging 64-bit application c# exe using native c++ dll, on windows 7. seems environment variables different these two, though both executing in same process. how possible calling system.environment.setenvironmentvariable has no effect on values returned getenv()? the environment variables blob of data gets passed windows process when starts. runtime functions using (the bcl system.environment , crt getenv) making copies of environment during startup, means not operating on same "environment" variables. conceptually must because otherwise there need way synchronize them accessing environment.

Setting Oracle Timestamp with Coldfusion -

this pretty simple question, , searched previous questions couldn't find answer. how insert or create timestamp in oracle using coldfusion? you can insert this: <cfquery name="qtest"> insert mytable(mytimestampcol) values (<cfqueryparam cfsqltype="cf_sql_timestamp" value="#now()#" />) </cfquery> hope helps.

c# - How do I check if the useragent is an ipad or iphone? -

i'm using c# asp.net website. how can check if user using ipad or iphone? how can check platform? for example, if user enter website ipad i'd display"hello ipad user" for ipad user agent like: mozilla/5.0(ipad; u; cpu iphone os 3_2 mac os x; en-us) applewebkit/531.21.10 (khtml, gecko) version/4.0.4 mobile/7b314 safari/531.21.10 and iphone somthing like: mozilla/5.0 (iphone; u; cpu mac os x; en) applewebkit/420+ (khtml, gecko) version/3.0 mobile/1a543a safari/419.3 any many more depending on version , wheather iphone 3 or 4 so better substring search iphone , ipad as suggested answer

Transform MySQL 'update' statements to 'insert' statements -

i have 11mb dump containing update statements, formatted this: update `table` set `id` = 1,`field`='etc' `table`.`id` = 1; however, need insert these values new database, using statements this: insert `table` (`id`, `field`) values ('etc', 1); has written tool or service convert update statements insert statements? (at first glance, seems beyond reach of regex) lazy approach. if have ids, insert no matter id's , after run updates.

c++ - How to use the same QAction in two QMenus with different text? -

so have action want expose in multiple menus (one of main menus, , context menus). i'd menu item text differ menu menu (to make mnemonic unique, , more or less verbose necessary in each context). in mfc (which have pleasure of migrating away @ moment) easy, each menu's items defined separately, , map same id, linked handler. in qt though, qaction encapsulates behaviour text/icon/etc. don't suppose there's straightforward support return different text dependent on it's being used. my thought how handle is, each location, create "proxy" qaction , has text specific context , has triggered() signal connected original qaction 's one. thought should check first whether there's easier way approach this. i don't know mfc, in qt - qaction interface. 1 qaction object can have 1 text display. real action qaction does, implement in qt calls slot. can have interfaces(or qactions objects) pointing same slot - connect qaction objects, want ...

Is there a way I can change where a PHP page selects from a MYSQL database by using a form? -

i have website , want make easier change information being shown without them having edit html/php , using ftp. at moment have information in php file included in mysql query. it lot easier if done using form, text field person can type table name , updates on main page , starts displaying table instead. sorry if haven't explained well. :( i have news you. every php/mysql-driven site in world made exact way - edit site contents using html form. even first php version name php/fi, stands form interpreter. even better, site user doesn't have deal mysql - it's being done in php. no need type table names form field - table names written in php code. usual php application being connected 1 mysql database - so, no need choose. tables, it's being done way: user selects human-readable matter, "latest news" , being redirected php script called, say, news.php . script runs query news table in database , outputs html formatted news highligh...

dialog - android timepicker on cancel -

i use standart android's timepicker: ... showdialog(timepicker); ... private timepickerdialog.ontimesetlistener mtimesetlistener = new timepickerdialog.ontimesetlistener() { public void ontimeset(timepicker view, int hourofday, int minute) { //code; } }; @override protected dialog oncreatedialog(int id) { switch (id) { case timepicker: return new timepickerdialog(this,mtimesetlistener, 0, 0, true); } return null; } everything fine, how can catch cancel button perform code ? setoncancellistener or try setondismisslistener.

c# - Problem with declaring List<myClass> property in VS2010 -

hi created 2 usercontrol (the line & station) , use station in line usercontrol , use "line" usercontrol in forms. there no problem @ design time, whem want add "line" usercontrol form. in case, visual studio stop working , closed. i comment changes in code , find problem property number of stations in line. whem comment every thing go ok need property. code [serializable] public class actionpoint { public string carinfo; public string rightstationname; public string rightstationinfo; public string leftstationname; public string leftstationinfo; public actionpoint() { } } and use class in property. use property define stations in line. public class line : usercontrol { public list<actionpoint> stations { { return stations; } set { stations = value; } } } i think problem property, not list, try this. list<actionpoint> _stations; public list<actionpoint> stations { { r...

google cloud datastore - GAE problem at getting results from a simple query in deployment -

hy! i have dataviewer open @ kind named survey; there row has year=2010; then when open app , run query survey of 2010 got no results. q = survey.all() q.filter('year', data['year']) surveys = q.fetch(1) #json = survey[0].to_json() #key = survey[0].key() return surveys data['year'] exists; , in development server works; i think might has problems namespace kind? or dont know how fix it? thanks

app store - iPhone multilingual App in a single Country. (belgium case) -

question regarding app store deploiement, in belgium (and in many other country), 3 languages spoken (french, dutch, german). therefor developed localizable app these 3 languages , made 3 description page. those 3 description pages displayed in itunes depends on os language. (great!) but on internet, had deploy application in 3 different country (france, germany, netherlands) , access correct country appstore see description in language. thus, belgium people have go on appstore of language country (which not belgium appstore) able understand description. is there way provide 3 languages in 1 , unique belgium appstore ? (checking system language exemple, or proposing 3 descriptions on app page) hope made clear enough english ! more : when go mac store url shows /be-fr/ french, /be-nl/ dutch, language of macbook description changes. when watch appstore url, can see /be/ more : depends came in app store, got "screenshots" written or "captures d'écra...

sql - MySQL query to search a field with JSON string -

this might simple enough basic sql or might need regexp i've hit brick wall. my data stored in json string these 2 examples (each in 1 field): [{"id":"2","value":["1","3"]},{"id":"3","value":["1","2"]}] and: [{"id":"3","value":["2"]},{"id":"3","value":["1","2","5"]}] i want search values in between last brackets might consist of many numbers ["1","2","5"] or single on ["2"] . beginning numbers correspond 2 categories - single "id":"2" , "id":"3" . using %"2"% simple of course matches everything. can query "id":"$var" return each category use php filter through after have results, data can quite large , i'm sure it's easy sql guru. i don't have...

java - Changing hashCode of object stored in hash-based collection -

i have hash-based collection of objects, such hashset or hashmap . issues can run when implementation of hashcode() such can change time because it's computed mutable fields? how affect hibernate? there reason why having hashcode() return object's id default bad? not-yet-persisted objects have id=0, if matters. what reasonable implementation of hashcode hibernate-mapped entities? once set id immutable, it's not true moment of saving entity database. i'm not worried performance of hashset dozen entities key=0. care whether it's safe application , hibernate use id hash code, because id changes generated on persist. if hash code of same object changes on time, results unpredictable. hash collections use hash code assign objects buckets -- if hash code changes, collection doesn't know, can fail find existing object because hashes different bucket now. returning object's id isn't bad, if many of them have id=0 mentioned, reduce perfo...

mysql - Database Design: how to model generic price factors of a product/service? -

i'm trying create generic data model allow particular product (indicated fk product_id in sample table below) specify 0 or more price "factors" (i define "factor" unit of price added or subtracted in order total). so there table: =============================== price =============================== price_id (pk) product_id (fk) label operation (enum: add, subtract) type (enum: amount, percentage) value a book's price might represented way: ==================================================================== price_id | product_id | label | operation | type | value ==================================================================== 1 | 10 | price | add | amount | 20 2 | 10 | discount | subtract | percentage | .25 3 | 10 | sales tax | add | percentage | .1 this means: price: $20.00 discount: - $5.00 (25%) -------------------- sub total: $15.00 sales ...

ruby on rails - Architecture for RoR SaaS application -

i have done decent amount of base ror work, haven't faced concerning scaling , running multiple applications. i in process of building application client hope market other users in similar industries, struggling high level architecture. seems unnecessary run separate instance of application each client, don't know how load different configurations/layouts/features various users. don't expect each individual application have extremely high traffic seems waste each have unique instance/database. yet, each instance require own css potentially different configuration of available functionality. is can done using subdomains? can load different configurations based on this? have insight how 37 signals applications manage different configurations based on account? when making same decision our application, considered several things... first , foremost, considered complexity. when start adding multiple customers same database, need consider how going segmen...

Mercurial workflow with subrepositories and offline clones? -

i'm offline lot. so normally, use 1 local clone "hub" features, bugs, etc. hg clone local-hub bug-123 works offline. cool. can use similar workflow if project contains remote subrepositories? because, if .hgsub says sub/shared = http://server/hg/shared hg clone says abort: error: getaddrinfo failed note once clone created (while connected), push , pull use path in subrepo's hgrc (instead of location in .hgsub ). can point local clone , cool. but clone looks @ .hgsub (as it's supposed to). if "blessed" subrepo on server, can't create new clones offline, though files need right there. this problem, right? ideally whomever set project uses relative urls in .hgsub file this: sub/shared = ../shared and then, of course, makes shared sibling of main repo. long have cloned down main repo , subs (as siblings) work out. if they've used absolute urls in .hgsub file can work around using subpaths section in ....

java - Wrong output using replaceall -

why "aaaaaaaaa" instead of "1a234a567" following code: string myst = "1.234.567"; string test = myst.replaceall(".", "a"); system.out.println(test); any idea? replaceall function take regular expression parameter. , regular expression "." means "any character". have escape specify character want : replaceall("\\.", "a")

jquery - PHP & JSON - Trouble to print a value on client side -

i have php function : if(($_post['id']=="pm_read") && (isset($_post['pm_id'])) && (ctype_digit($_post['pm_id'])) && (isset($_session['nickname']))) { $update=mysql_query("update pm set readed='1' id='".$_post['pm_id']."' , receiver='".$_session['nickname']."'",$mydb); $query=mysql_query("select count(id) pm receiver='".$_session['nickname']."' , readed='0' , receiver_delete='0' order date desc",$mydb); $arraypm[0]=mysql_result($query,0,'count(id)'); $query=mysql_query("select message pm id='".$_post['pm_id']."' , receiver='".$_session['nickname']."'",$mydb); $arraypm[1]=mysql_result($query,0,'message'); echo json_encode($arraypm); } on client side, array trought jquery function : $...

android - Upgrading to Mac OS Lion -

i develop android apps on macbook pro snow leopard on using eclipse , looking upgrade laptop lion released yesterday wondering if there problems running java/eclipse on this? has else upgraded , did have issues? i've upgraded. haven't encountered problems / bugs yet. fell free upgrade imho. edit: 1 thing i've noticed - scrollbars changed in eclipse too, , new style markings (that mark lines in opened document problems or warnings appear) seems have disappeared.

wpf - how to make active while in background c# xaml -

i made virtual keyboard in xaml c# using wpf. totally working , great. add few quality of life things if possible. there method of having take keyboard input while in background , primary application notepad. virtual keyboard highlights keys pressed why important. barring there way make text in textblock selectable copy paste (i can track typed , post in one, text should not directly alterable!!!!, website) i'd know if there way have curser default textbox rather having click it. you should use low level hooks in app show pressed keys. see code sample here .

ruby on rails - How do I make sure an association's attribute is correct to validate the association? -

i've got simple user: **edited bit clarity, , on sam's suggestion class user < activerecord::base # <snip other attribs> has_many :handles has_one :active_handle, :class_name => "handle" validates_each :active_handle, :allow_nil => true |record, attr, value| record.errors.add attr, "is not owned correct user" unless record.handles.include?(value) end end and handle model: class handle < activerecord::base belongs_to :user attr_accessible :user_id validates :user_id, :presence => true, :numericality => true attr_accessible :name validates :name, #etc... end now i'd check, when setting user.active_handle association, handle owned correct handle.user_id. i've tried in custom validation, , in validate method on user model. both ways, exact opposite of want, sets user_id of handle user doing checking. i'm @ end of rope, don't understand something, , google ...

MP3 Duration Java -

having awful time trying accurate time set of mp3s. have these following properties generated using mp3spi 1.9.5 library . // mp3.crc=true // mp3.copyright=true // mp3.padding=false // mp3.channels=1 // mp3.version.mpeg=2.5 // mp3.length.bytes=6425480 // mp3.framerate.fps=27.777779 // mp3.framesize.bytes=140 // duration=1606356000 // mp3.version.layer=3 // mp3.length.frames=44621 // mp3.frequency.hz=8000 // mp3.header.pos=0 // mp3.bitrate.nominal.bps=16000 // mp3.vbr.scale=0 // mp3.version.encoding=mpeg2dot5l3 // mp3.mode=3 // mp3.vbr=false // mp3.original=false now file reading has duration of 47:35 reported itunes, , 48:50 using mac preview. when duration in java using library 26:46: audiofileformat fileformat = audiosystem.getaudiofileformat(f); map<?, ?> properties = ((taudiofileformat) fileformat).properties(); string key = "duration"; ...

php - cURL gets less cookies than FireFox! How to fix it? -

how can make curl cookies? i thought maybe firefox gets different cookies page loads or has built-in javascript sets cookies after page loaded, or maybe redirects other pages , other pages set other cookies, don't know how make curl same thing. set curl follow redirects still no success. curl sets cookies not of them. following code use in php: $url = 'https://www.example.com'; $handle = curl_init($url); curl_setopt($handle, curlopt_cookiesession, true); curl_setopt($handle, curlopt_returntransfer, true); curl_setopt($handle, curlopt_followlocation, true); curl_setopt($handle, curlopt_cookiejar, "cookies.txt"); curl_setopt($handle, curlopt_cookiefile, "cookies.txt"); curl_setopt($handle, curlopt_autoreferer, true); curl_setopt($handle, curlopt_useragent, 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; .net clr 1.0.3705; .net clr 1.1.4322)'); $htmlcontent = curl_exec($handle); following live http header in firefox https:/...

iphone - Extract embedded profile from ipa in PHP -

i want create web server testflight. want upload ipa file , fetch provision profile. user don't need add provision profile. there solution this? also, how testflight working install application in device? actually embedded profile in ad-hoc distribution install on user's device automatically while downloaded ota. check apples docs on distributing enterprise apps ios 4 devices , section installing apps wirelessly . full sample read [deleted] edit: link above broken, , seems have moved to: http://aaronparecki.com/articles/2011/01/21/1/how-to-distribute-your-ios-apps-over-the-air also since ios 7.0.3, plist (not ipa) must hosted on ssl secured site (https).

iphone - Grouped Table View Obj-C -

i followed tutorial here , wondering how make table appear grouped. ex: group1 contains subview 1 , subview two group2 contains subview three i switched type in interface builder shows 1 group. thanks, adam sidenote* new @ objective c, hence tutorial. edit i thought might helpful put piece of code #import "rootviewcontroller.h" #import "subviewonecontroller.h" #import "subviewtwocontroller.h" @implementation rootviewcontroller #pragma mark - #pragma mark view lifecycle -(void)awakefromnib { views = [[nsmutablearray alloc] init]; subviewonecontroller *subviewonecontroller = [[subviewonecontroller alloc] init]; subviewtwocontroller *subviewtwocontroller = [[subviewtwocontroller alloc] init]; //subview 1 subviewonecontroller.title = @"subview one"; [views addobject:[nsdictionary dictionarywithobjectsandkeys: @"subview one", @"title", ...

How to change with jQuery a data attribute of a set of elements? -

say have set of elements $elements. have data attr named "amount". first 1 has data-amount = 1, second 2 , on. whats simplest way increment in x value of them. y solution is $elements.each(function(){ $(this).data('amount',$(this).data('amount')+=x); }); is there better solution, without using each statement? thanks! jquery, of v1.6.2 @ least, doesn't offer overload .data() accepts function. still using each , within can do: $(this).data().amount += x;

asp.net - Part of custom control should be rendered only once -

i working on custom control. part of render div not displayed right away. based on particular client event, div shown. works fine when there once instance of custom control on page. in case of multiple instances, many above mentioned divs rendered, though not displayed. make container page lighter, want render div once, irrespective of number of occurrences of custom control. great. thanks, surya perhaps can store flag telling that div has been rendered. can store flag in httpcontext.items. here code if ((bool)httpcontext.current.items["divrendered"] == false) { //render div httpcontext.current.items["divrendered"] = true; }

javascript - Google Maps API v3 infowindow close event/callback? -

i keep track of , infowindows open on google maps interface (i store names in array), can't figure out how remove them array when closed via "x" in upper right hand corner of each one. is there sort of callback can listen for? or maybe can addlistener("close", infowindow1, etc ? there's event infowindows call closeclick can you var currentmark; var infowindow = new google.maps.infowindow({ content: 'im info windows' }); google.maps.event.addlistener(marker, 'click', function () { infowindow.open(map, this); currentmark = this; }); google.maps.event.addlistener(infowindow,'closeclick',function(){ currentmark.setmap(null); //removes marker // then, remove infowindows name array });

.net - Merging Memory Streams to create a http PDF response in c# -

i trying merge 2 crystal reports single pdf file , i'm using itextsharp v5.1.1. says document cannot opened. might corrupted. there no build errors. pdf malformed , cant opened. here order chose accomplish this. export crystal report memorystream1 in pdf format export second report memorystream2. merge memory streams send streams http output response pdf. here code each step in order. /// dataset stored procedure cssource report dscs = csdata.getussourcexml(ds_input); /// create report of type cssource rptcs = reportfactory.getreport(typeof(cssource)); rptcs .setdatasource(dscs); /// set parameters cs report rptcs .parameterfields["parameterid"].currentvalues.clear(); rptcs .setparametervalue("parameterid", pid); //// serialize object pdf mscs=(memorystream)rptcs .exporttostream(exportformattype.portabledocformat); for step 2 /// dataset stored procedure aden report dsad = csdata.getadde...

Excel VBA concatenate Column 1 for range of values in Column 2 -

i have set of rows & column below column1 column2 123 value1 456 value1 789 value2 101 value2 234 value2 567 value3 890 value4 concatenate column1 based on column2 range like: column3 123 123,456 789 789,101 789,101,234 567 890 i tried using formula , did it, there better way (like in macro) this? =if(b2=b1,c1&","&c2,c2) and pick last row each value well, macro it. wouldn't better, though! sub macro1() dim source range dim control range dim output range set source = range("a1") set control = range("b1") set output = range("c1") dim storehere string dim row integer dim additon boolean row = 1 storehere = "" while (not (isempty(source.cells(row, 1)))) if (row > 1) if (control.cells(row, 1) = control.cells(row - 1, 1)) additon = true else ...

django - How do I exclude current object in ManyToMany query? -

i have 2 basic models, story , category: class category(models.model): title = models.charfield(max_length=50) slug = models.slugfield() ... class story(models.model): headline = models.charfield(max_length=50) slug = models.slugfield() categories = models.manytomanyfield(category) ... and view story detail: from django.views.generic import date_based, list_detail solo.apps.news.models import story def story_detail(request, slug, year, month, day): """ displays story detail. if user superuser, view display unpublished story detail previewing purposes. """ stories = none if request.user.is_superuser: stories = story.objects.all() else: stories = story.objects.live() return date_based.object_detail( request, year=year, month=month, day=day, date_field='pub_date', slug=slug, queryset=stories, template_object_name = 'story', ) on view given story object -- i'...

iis 7.5 - IIS 7.5 Virtual Directory getting Unauthorized: Access is denied due to invalid credentials -

i have web application trying access images shared folder on different server. in web app, created new virtual directory. alias qcphotos , path \alta\qcphotos. alta different server web server, brighton. i getting error: 401 - unauthorized: access denied due invalid credentials. not have permission view directory or page using credentials supplied. in trying debug, on alta server, have given user full access folder. gave {domain}\brighton$ full access folder. i turned on directory browsing, , seems work fine. can list contents of folder, click on jpg image, error comes up. well, i'm still not sure why wasn't letting me access, created domain user acct named qcphotos. gave user read permissions on folder, , set virtual directory use user in iis. fixed problem.

widget - Android: onAppWidgetChanged doesn't appear to exist -

this description of appwidgethost.startlistening() : start receiving onappwidgetchanged calls appwidgets i can't find reference mysterious onappwidgetchanged thing anywhere. google hits quotes same piece of documentation. what referring to? 1 need call, override, or implement widget updates? its unlikely need implement widget host yourself. home page existing widget host. looking implement widgetprovider means extending android.appwidget.appwidgetprovider , overriding 2 methods: onupdate() , onreceive() time onenabled too. never need implement widget host, if goal please clarify. widget provider broadcast receiver designed run inside widget host (usually home). widget provider might live milliseconds, process broadcasted events , processing 1 of them mandatory , must specified in manifest. communicate out information widget provider broadcast receiver extends context , can issue startactivity(intent) or startservice(intent) think need unless i...

c# - How do I update a single item in an ObservableCollection class? -

how update single item in observablecollection class? i know how add. , know how search observablecollection 1 item @ time in "for" loop (using count representation of amout of items) how chage existing item. if "foreach" , find item needs updating, how put observablecollection> you don't need remove item, change, add. can use linq firstordefault method find necessary item using appropriate predicate , change properties, e.g.: var item = list.firstordefault(i => i.name == "john"); if (item != null) { item.lastname = "smith"; } removing or adding item observablecollection generate collectionchanged event.

c# - Colors in SDL acting very weird -

i'm making program in sdl.net, need draw filled polygon. figured might reuse polygon surface instead of remaking every time need draw, make surface this, , save dictionary afterwards: polysur = video.screen.createcompatiblesurface(70, 70, true); polysur.transparentcolor = color.magenta; polysur.fill(color.magenta); polysur.transparent = true; poly.draw(polysur, color.lightgreen, false, true); poly polygon object i've created beforehand. you might think draw light green polygon when surface blitted screen; doesn't. resulting polygon cyan! discovered through experimentation if make color color.fromargb , r channel becomes red, g channel becomes cyan, , b channel becomes black. however, if set second boolean in draw call false (disabling filling), light green outline. obviously, fill operation causing colors mess up. any ideas? it's bug: http://sourceforge.net/tracker/index.php?func=detail&aid=3127181&group_id=52340&atid=466516 lin...

ruby on rails - replacing certain column values with "-" in a will_paginate result set without affecting sorting -

i have model table 3 fields: "id", "amount" , "type". im calling paginate method display data need replace amount "-" if type = "specific_type". i can replacing values in view "-" if type condition met. screws sort order "-" values evaluated 0 replacing values in view still leaves me incorrect sort order. i thought using find_by_sql , trying create virtual field using case statement select *, case type when 'specific' amount else '-' end amounts; this way, can use virtual column. the problem need take in param hash of options have manually render sql clause. sounds tedious unless there's better way of doing it. in controller: def index @resources = [] your_resources = resource.find(:all) your_resources.each |resource| resource.amount = '-' if resource.amount = "specific_type" @resources << reso...

iphone - Objective-C: How to check if 2 properties are the same or not? -

let's have 2 instances of person class. 1 named john , 1 mary. person class has 2 properties age , gender . there way make iteration thorough instances' properties , check if current property equal given property? this: for (iterate thorough properties of instance mary) { //first iteration @selector(mary.age)==@selector(john.age) //this yes; //second iteration @selector(mary.gender)==@selector(john.age) //this no; } you can property name nsstrings , use isequaltostring : method compare them. for (iterate thorough properties of instance mary) { //first iteration nsstring *marryproperty = [nsstring stringwithcstring:property_getname(mary.age) encoding:nsutf8stringencoding]; nsstring *johnproperty = [nsstring stringwithcstring:property_getname(john.age) encoding:nsutf8stringencoding]; if([marryproperty isequaltostring:johnproperty]) nslog(@"yes"); else n...

javascript - swf not transparent + div opacity chrome & opera on osx -

ok got weird stuff here no clue anymore. first swf file not going transparent, when ensure wmode transparent. non off browsers working... swf embedded not transparent. tried removing params, still same... what's wrong? <div id="flashcontent"> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/swfobject.js"></script> <script type="text/javascript"> var flashvars = {}; flashvars.domain = "*"; var params = {}; params.movie = "myflash.swf"; params.quality = "best"; params.play = "true"; params.loop = "false"; params.menu = "false"; params.wmode = "transparent"; params.bgcolor = "#626262"; params.scale = ...

c# - which specific conditions could cause a db4o's native query transformation bug? -

this fails: var results = container.query<someclass>(s => s.field == value && s.anenumfield != someenum.anenumvalue ); assert.areequal(1, results.count); but doesn't: predicate<someclass> matches = s => s.field == value && s.anenumfield != someenum.anenumvalue; var results = container.query<someclass>(s => matches(s)); assert.areequal(1, results.count); the different in tests demonstrates issue happens when db4o expression transformation, calling method prevents that. value checked in test, exact value (no case differences), test inserts first. any special conditions db4o transformations has bugs queries? maybe .net enums? i have narrowed down, , example above didn't include troublesome bit. doesn't have enum field, "value" in above expression. specifically issue happens when query includes someinstance.field value, like: var results = container.query<someclass>(s => s.field == s...

linux - Are Unix reads and writes to a single file atomically serialized? -

i'd know if writes upon single file done atomically such write("bla bla") , subsequent write("herp derp") same file never results in interleaving, e.g. "bla herp bla derp". assuming these writes happen in different processes or threads, governs gets done first? also, read() return data reflecting file in state of previous writes completed (whether data has been written disk or not)? example, after write("herp derp"), subsequent reads reflect full data written file, or subsequent read reflect "herp" not "derp" (or reflect none of data @ all)? if reads , writes occur in different processes/threads? i'm not interested in concurrent file access strategies. want know read , write exactly. separate write() calls processed separately, not single atomic write transaction, , interleaving entirely possible when multiple processes/threads writing same file. order of actual writes determined schedulers (both ker...

php - effective way of doing preview images -

i'm doing preview images online store sells pdfs. the functionality aiming is: when customers browse store, catalogue of pdf templates visible tiny scaled images. additionally, customers can click on template , image pop of customized pdf (ie fields filled in customer appropriate content). the pdf software i've found php fpdf, fpdi generation of customized pdf , imagemagick generation of previews. the thing i'm finding though in order imagemagick generation of images customized pdf. pdf needs exist image created on server directories. what design looking though server side wise, want have templates , image creation not leave files on server. is there software package or have manual memory management? ie create custom pdf, create imagemagick preview image, delete custom pdf (which needs generated again if customer buys it), upload preview image, send link user (and @ point delete preview image later... maybe on logout?)

c# - mscoree.dll's GetRequestedRuntimeInfo() causing improper TargetFrameworkDirectories - how to debug? -

i'm having problem .net build system looking in wrong folders framework references. machine has .net 4.0 , visual studio 2010 installed, , problem happens on projects .net version less 4.0 (my example in .net 3.5). problem looked build issues, digging deeper it, found microsoft.build.tasks.v4.0.dll (called during build process) calling mscoree.dll , getting wrong information back: (decompiled source) frameworklocationhelper. constructdotnetframeworkpathfromruntimeinfo(string requestedversion): int num1 = 264; int num2 = 25; stringbuilder pdirectory; stringbuilder pversion; uint requestedruntimeinfo; { pdirectory = new stringbuilder(num1); pversion = new stringbuilder(num2); uint dwdirectorylength; uint dwlength; --------> requestedruntimeinfo = nativemethodsshared.getrequestedruntimeinfo(string.empty, requestedversion, string.empty, 16u, 64u, pdirectory, num1, out ...

mysql - add the same thing to a table column by sql command -

there table named test . in it. there columns this: 001.jpg ... 999.jpg now want use sql command add url before them. http://www.example.com/xxx/001.jpg .....is there way this? thank you. supposing field called url , simple update query do: update test set url = concat("http://", url);

How can I identify the request queue for a linux block device -

i working on driver connects hard disk on network. there bug if enable 2 or more hard disks on computer, first 1 gets partitions looked on , identified. result is, if have 1 partition on hda , 1 partitions on hdb, connect hda there partition can mounted. hda1 gets blkid xyz123 mounts. when go ahead , mount hdb1 comes same blkid , in fact, driver reading hda, not hdb. so think found place driver messing up. below debug output including dump_stack put @ first spot seems accessing wrong device. here code section: /*basically, request_queue processor. in log output follows, second device, (hdb) has been connected, right after hda connected , hda1 mounted system. */ void nblk_request_proc(struct request_queue *q) { struct request *req; ndas_error_t err = ndas_ok; dump_stack(); while((req = nblk_next_request(q)) != null) { dbgl_blk(8,"processing queue request slot %d",slot_r(req)); if (test_bit(ndas_flag_queue_suspended, &(ndas_get_slot_dev(slot_r(req)...