Posts

Showing posts from May, 2011

php - XSS in URI in page without any input -

is xss attack made user input? have recived attacks this: '"--></style></script><script>alert(0x002357)</script> when scanning php page without html content acunetix or netsparker. thanks in advance remember if had static collection of html files without server-side or or client-side scripting whatsoever, may still store logs in sql database or watch them html using log analyzer may vulnerable kind of uris. have seen uris in logs using escape sequences run malicious command in command line terminals – google escape sequence injection , may surprised how popular are. attacking web-based log analyzing tools more common – google log injection. not saying particular attack targeted @ logs i'm saying not displaying user input on web pages doesn't mean safe malicious payloads in uris.

mysql - PHP $_GET issue -

i hope can me issue, php example: ?id=5&language=en firstly ?id=5 simple page, language defined in directories, wanna make this ?id=5,en i don't put &language=en , comma , en how can ? list($id, $lang) = explode(',', $_get['id']); and use $id , $lang how want.

Automatically grab file path -

everyone looking way automatically upload file skip browse , choose file process. so set location of file somehow via form , client has click submit , automatcially upload file path have set. skipping browse file process. i intergrate following undesigns s3 class http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation <?php s3::setauth(awsaccesskey, awssecretkey); $bucket = "upload-bucket"; $path = "myfiles/"; // can empty "" $lifetime = 3600; // period parameters valid $maxfilesize = (1024 * 1024 * 50); // 50 mb $metaheaders = array("uid" => 123); $requestheaders = array( "content-type" => "application/octet-stream", "content-disposition" => 'attachment; filename=${filename}' ); $params = s3::gethttpuploadpostparams( $bucket, $path, s3::acl_public_read, $lifetime, $maxfilesiz

php - Best approach for a administration panel in Symfony -

i need develop administration panel web application written symfony. generating backend application seems first option, think introduces complications. the main purpose of basic administration panel managing users , configuring values multiple <select> <option>...</option> <option>...</option> ... </select> within application. restriction regular user cannot access area, model , crud actions should have same behaviour in frontend modules. is worth create whole backend application in case? or should enough block access checking user role? using same application easier simple administration tasks use same design , components frontend application. permissions can set using configuration , should fine either way . you create separate application , use admin generator... it how want separate 2 parts of website.

Why doesn't the Java compiler download imported packages? -

i'm trying run lucene java application on local machine. compilation error: package org.apache.commons.digester not exist because of import org.apache.commons.digester.digester; isn't compiler downloading package internet? if not, should do? no, compiler doesn't download packages internet. build management tools maven if configure them , add package project dependencies. without such tool should download jar manually , put on compiler classpath.

ruby on rails - capistrano behind http proxy -

is there way set http proxy capistrano ? i have deployment server behind proxy, capistrano hangs while fetching github repository https protocol. how can tell capistrano use proxy server ? you can use gateway option, when accessing remote server through proxy set :gateway, "proxy-user@100.200.300.400" ssh_options[:keys] = "~/.ssh/your-key" make sure have added remote servers ssh key github repo deploy keys. you can try forward_agent option make remote server use local machine ssh key access github. ssh_options[:forward_agent] = true hope helps.

java - How to avoid illegal state exception? -

every time "405 method not allowed" response server, want redirect user given url. however, keep getting illegalstateexceptions saying response has committed. there way can redirect user without getting exception? i have following servlet: public class methodnotallowedhandler extends httpservlet { @override protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { resp.sendredirect("http://www.google.com"); } } and following entry in web.xml: <servlet> <servlet-name>methodnotallowedhandler</servlet-name> <servlet-class>com.ex.methodnotallowedhandler</servlet-class> </servlet> <servlet-mapping> <servlet-name>methodnotallowedhandler</servlet-name> <url-pattern>/methodnotallowedhandler</url-pattern> </servlet-mapping> <error-page> <error-code>405</error-co

c# - Child Form Size Set to the MDI Form's MDI Container's Size -

i'd know how can have child form load it's size covering complete mdi parent's mdi container space (the dark-gray thing)? setting child form's windowstate maximized not option it'll maximize other form too. suggestions? i think code should it: form childform = new form(); f.left = 0; f.top = 0; f.size = parentform.clientrectangle.size;

visual studio 2010 - VB.NET won't compile because of underscore -

Image
i've been running same project on same computer months in vs2010. there have been no code changes class contains following code: private event valuechanged(byval sender object, byval e eventargs) _ implements sti.shared.ui.ieditfield.valuechanged recently, when compile, error class must implement event valuechanged. when remove underscore , bring implements piece same line, compiles. if undo checkout , revert code before, compiles. it's strange behavior , i'm wondering if out there has experienced this. i can reproduce error, slight technicallity: public interface itest 'note here have specified system.eventargs event valuechanged(byval sender object, byval e system.eventargs) end interface public class testfail implements itest 'and here have specified eventargs, fine... private event valuechanged(byval sender object, byval e eventargs) implements itest.valuechanged end class 'unless declare class calle

javascript - Memory efficiency in objects -

is either of these patterns more or less efficient other? pattern 1: var jso = new class({ initialize: function () { // code }, hilitefield: function () { // code } }); pattern 2: var jso = new class({ initialize: function () { this.hilitefield = hilitefield.bind(this); // code } }); var hilitefield = function () { // code } having multiple methods external class , scope chain, opposed behind class 'namespaced' methods can't better, imo. don't pattern #2 several reasons: manageability - having bind reference each external function class going hard do. readability - having indicate function being used class going task extendibility - because functions outside of jso class prototype, classes extend jso or use mixin won't able access external methods. that being said, memory standpoint - test say, pattern 1 have smaller overhead because it's defined once on prototype , not in every instance in

c - Write a function that return true if 2 passed strings to it are such that all characters of first string are uniquely present in second string -

efficient , o(n) code in c?? know solution of o(n*n) stringcompare(str1, str2){ int freq1[100] = {0}, i; int freq2[100] = {0}; for(i=0; i<=strlen(str1); i++){ freq1[str1[i]]+ = 1; } for(i=0; i<=strlen(str2); i++) { freq2[str2[i]]+ = 1; } for(i=0;i<26;i++){ if(freq1[i]!=freq2[i]) return 0; return 1; } } i modified mak 's pseudocode uses 1 frequency count array. positive value in final freq array means char in s1 not in s2 . negative value signals chars in s2 . function same(s1,s2): freq=array of zeros i=0 length of s1: freq[s1[i]]+=1 i=0 length of s2: freq[s2[i]]-=1 i=0 alphabet_size: if not freq[i]=0 return "no" return "yes"

sap - RFC callback server not available Exception while trying to execute cl_crm_ducuments=>create with file via RFC -

i'm trying upload file server directory sap-crm system (as attachment of opportunity). therefore using method create_with_file of cl_crm_documents class. to call method using rfc-function created myself. if test rfc-function within function builder, works fine. if execute rfc external system (in case ms-outlook) error occurs: "exception: rfc callback server not available". started debugger , program runs half way through (so connection works): create_with_file calls couple of functions until rfc_start_program function called. error occurs @ line. does know why error occurs if call function remote , solve problem. i don't have access crm system, what's happening: class use tries perform action on front-end pc using sap gui. this, performs rfc call or sap gui. works fine long using function builder because there's gui connection available. once use other means invoke function module, gui no longer there , program won't work. i'd sug

perl read multiple file -

in perl, how read multiple file @ once, am genrating report @ end of month, per day 1 log file create, i want read entire month files , my file somthing t.log.mmddyyy the glob function allow retrieve list of files names match pattern. if load list @argv , can process files--even in order single loop: use strict; use warnings; use getopt::long; sub usage ($) { $msg = shift; die <<"end_msg"; *** $msg usage: $0 --month=nn --year=nn path end_msg } getoptions( 'month=i' => \my $month, 'year=i' => \my $year ); usage "month not specified!" unless $month; usage "year not specified!" unless $year; usage "invalid month specified: $month" unless $month > 0 , $month < 13; usage "invalid year specified: $year" unless $year > 0; $directory_path = shift; die "'$directory_path' not exist!" unless -d $directory_path; @argv = sort glob( sprintf( "$d

Cannot set the Title-property of a page in asp.net -

i have weird problem in asp.net. i have page in can't set title -property under circumstances. if set title -property string-value in page_preload, value empty. happens in circumstances, don't understand when. if set breakpoint , debugger, after setting title="test"; , title property empty. pagetitle in browser shows "test". if use title-property in markup of page, empty. there special magic title-property, have know about? the page.title property wrapper around htmlhead control, exposed through page.header. before header gets initialized, stores title in property until gets initialized. whenever header gets established, copies property over... may issue is, or maybe else... hth.

flash - How would I create a panel on drag drop in flex 4? -

i trying drag component , on drop want create panel. here actionscript have doesn't seem working, ideas why? private function dragdrop(e:dragevent): void { var userpanel:panel = new panel(); userpanel.width = 100; userpanel.height = 100; userpanel.x = 10; userpanel.y = 10; userpanel.visible = true; addchild(userpanel); } the code you've included valid. drag initiator configured correctly? drop target configured accept drag-drop? here's code add panel canvas1 when canvas2 dragged canvas1: protected function canvas2_dragstarthandler(event:mouseevent):void { var draginitiator:canvas=canvas(event.currenttarget); var ds:dragsource = new dragsource(); dragmanager.dodrag(draginitiator, ds, event); } protected function canvas1_dragenterhandler(event:dragevent):void { dragmanager.acceptdragdrop(canvas(event.currenttarget)); } protected function canvas1_dragdrophandler(event:dragevent):void { var us

Visual Studio Item Template with Wizard -

i looking sample on how create item template wizard in visual studio 2010. requirement when user selects add item, want show dialog user enters input parameters. on pressing ok in form generate xml file want add project. thanks i'd recommend vsix featured in link http://blogs.msdn.com/b/visualstudio/archive/2010/03/04/creating-and-sharing-project-item-templates.aspx , rename zip file , open start with. xml in item templates aren't complicated. looking @ 1 generated tool classic asp file. <vstemplate version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" type="item"> <templatedata> <defaultname>classic asp</defaultname> <name>classic asp</name> <description>adds script tag import ref</description> <projecttype>web</projecttype> <projectsubtype>visualbasic</projectsubtype> <sortorder>10</sortorder&g

.net - How does System.Object store "objects" internally? -

i reading boxing, , book says "boxing can formally defined process of explicitly converting value type corresponding reference type storing variable in system.object ." (emphasis added) my question isn't boxing, got me thinking - how , system.object instance store values/variables/objects assigned it. i'm wondering not only object objshort = 5; but also object someotherobj = somereallycomplicatedobject; i've been looking around, including here (msdn system.object) , , don't see anywhere describes how system.object instance stores data. is object storing pointer object assigned it, or in case of boxing, pointer @ value type on stack? (jon, forgive me if in book too. have ordered , on way!) that description of boxing inaccurate. object created isn't instance of bare system.object ; each value type has own "hidden" corresponding reference type class deriving valuetype implementing same interfaces value type, , field of ty

ruby on rails - Paperclipped on Heroku? -

i curious if paperclipped working on heroku without using s3. i'm assuming heroku read-only system, there must way save images there. you can't write heroku's file system, no, there no way save images way want. options using service s3, or storing them in database. recommend using s3, because databases not optimized file storage. it's worth reading heroku's documentation on file uploads .

android - Placing touch areas on an image that is drag, pinch zoom capable -

i'm looking way place touchable hotspots on image. image (picture desk phone keypad, speaker button, hold, etc) in framelayout wrapped within relativelayout, , has few buttons along bottom. need image dragable, pinch/zoom-able, , have implemented following article: http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2/1747?tag=mantle_skin;content i've tried few ways embed hotspots including technique (from ip332): http://groups.google.com/group/android-developers/browse_thread/thread/ffabb722efac62b2 uses points determine hotspots. drag & zoom feature, doesn't work because points change whenever drag or zoom. try manually adjust of hotspot locations within ontouch method whenever motion detected, seems bit hairy me. in dream world, i'd somehow embed imagebuttons within image , have image , imagebuttons scale , move drag & zoom. imagebuttons allow ability give feedback (e.g. color change, etc) when hotspot pressed. any suggestions?

actionscript 3 - Multiple dynamic text score display. Modifying each text one after another and incrementing the score by a certain number -

i have result screen shows bonus points , such. want each text field increment 1 after , have increment amount each frame. result screen pops up. first player score check player score, more score want display if player score greater player display score 100 increase player display score 100 if player score greater player display score 10 increase player display score 10 else increase player display score 1 when finished move next score...and on. i have thought of using timers move 1 score next, not being in event.enter_frame 1 if moves next one. if statement incrementing score looks ridiculous , i'm thinking there has better way it. thinking of making separate function wouldn't know return, or how return looks increasing , not showing total number instantly. if have questions please leave comment. i'll try expand on little more. you make new scoretext class inherits textfield, , use each of score text fields. on class make settargetscore met

java - Jsch or SSHJ or Ganymed SSH-2? -

i need connect server(username,pasw,host)-- easy enter 3-10 commands -- command="dir;date;cd;dir" there easier way ?, without writing 20 lines: while(smtng) { lot of stuff+ mysterious print scr:d } download file-- easy write downloaded file same file (add not owerride) -- ideas how? so perform these increadible easy tasks, might seem impossible if dare use jsch(awsome documentation), there choise between jsch,sshj,ganymed suggestions? mystery: 2) multiple commands entering 4) adding existing txt file more txt :d (probably there build in command) or not? /* download/owerride : sftpchannel.get("downloadfile.txt", "savefile.txt");*/ i can't comment on others ganymed works indeed.

flash - autoplay youtube video -

i have site , in home page have embedded youtube video, div containing player hidden(display:none), so, when button(video) clicked, hide content of page , show youtube player, works ok, love when button(video) clicked, player shows , start reproduce video automatically, i've faild in each attempt, i'm using code find in other web , made changes swfobject.addloadevent( ytplayer_render_player ); function ytplayer_render_player( ) { swfobject.embedswf ( 'http://www.youtube.com/v/' + youtube_uhma.home + '&enablejsapi=1&rel=0&fs=1&playerapiid=ytplayer', 'ytplayer_div1', '425', '344', '8', null, null, { allowscriptaccess: 'always', allowfullscreen: 'true' }, { id: 'ytplayer_object' } ); } function onyoutubeplayerready( playerid ) { var o = document.getelementbyid( 'ytplayer_object' ); if ( o ) { o.addeventlistener( "onstate

iphone - Loading & Selecting audio files into Audio Units -

i'm trying build render callback function load variety of short sound files, , (according custom logic) put them in mixer unit's iodata audiobufferlist. how load aif or caf file program, , appropriately import samples iodata? see extended audio file services reference , particularly "extaudiofileopenurl" , "extaudiofileread". remember not time consuming in render callback (e.g. opening file may considered time consuming, allocating memory is).

Trying to parse JSON file with jQuery -

i trying parse json file exact stucture in following. { "students": { "student": [ { "id": 1, "name": "john doe", "image": "pic1.jpg", "homepage": "http: //www.google.com" }, { "id": 2, "name": "jane doe", "image": "pic1.jpg", "homepage": "http: //www.google.com" } ] } } i using following jquery function: function getstudents(filename) { $.getjson(filename, function(data){ $.each(data.student, function(i,s){ var id = s.id;; var name = s.name;; var img = s.image;; var homepage = s.homepage; $('.networktable').append('<tr><td><

linker - Windows Static Library with Default Functions -

i create static library (.lib) in windows can used in subsequent builds "backup" undefined functions. for instance let's have foobar.lib has definitions for: foo bar and have other program defines foo , built dll must export foo , bar . want able use foobar.lib automatically export default definition of bar in resulting dll (and ignore definition of foo in foobar.lib). i have tried sending foobar.lib linker multiple defined symbols error (/force supposed override strong warnings won't work expected). i've tried using /nodefaultlib:foobar.lib ignores library , says bar undefined. i 100% there way because use application (abaqus) allow users write plug-ins , not have define of required exports plug-in dll. , not use /force option. i figured out solution (not sure if or best solution). i trying define foo , bar in foobar.lib using 1 object file (foobar.obj). if split foo.obj , bar.obj , use create foobar.lib linker can ignore appropria

ruby on rails - activerecord/pg: support automatic timestamps in DDL -

updated (to show code) i'd mimic activerecord's automatic timestamps directly in database, without explicitly adding logic after every migration's create_table() call . here's now: class statusquo < my::migration::subclass def self.up create_table :tbl |t| ... columns ... t.timestamps end add_default_now(:tbl, :created_at) # alter column ... default now() add_default_now(:tbl, :updated_at) # alter column ... default now() add_updated_at_trigger(:tbl) # before update on ... trg_updated_at() end end by contrast, here's i'd do: class druthers < my::migration::subclass def self.up create_table :tbl |t| ... columns ... t.timestamps end end end is there easy or recommended way accomplish this? using activerecord 3, postgresql 8.4. here's best come far, full source here : in config/environment.rb check see if our connection adapter postgresql. if so, require

Zope Management Interface know-how for better Plone development -

as typical 'integrator' programmer customising plone, should know zmi me code more effectively? settings, tools, pitfalls, shortcuts , dark corners save me time , me write better code? edit: take read coding on filesystem, using genericsetup profiles make settings changes. know making changes in zmi bad idea , steer clear. zmi sure useful: inspecting workflow, or examining content item's permissions, or installing 1 part of profile via portal_setup. there nothing worth knowing zmi? or there other useful little tidbits in there? there few places in zmi find myself returning diagnostic information: /control_panel/database: select zodb mountpoint. cache parameters tab shows how of designated zodb cache size has been used. activity tab shows how many objects being loaded cache , written on time. /control_panel/debuginfo/manage: lots of info, including showing request each thread serving @ current moment. 'cache detail' , 'cache extreme detail'

html - How does the browser knows how to interpret the script tag? -

according this: http://www.w3.org/tr/1999/rec-html401-19991224/interact/scripts.html the type of script added in script tag. values are: "text/tcl", "text/javascript", "text/vbscript". recently i've seen in page: cofeescript in 1,2,3 following: <script src="coffee-script.js"></script> <script type="text/coffeescript"> alert "hello coffeescript!" </script> and works great! ( had download cofeescript library , use 1 in folder ) my question is. how browser knows given script should handled? have no idea. seeing can't finish answer, it's not yet entirely clear question ;) but answer question related: the type attribute of script , style elements in html? summary: type indeed required attribute in html 4 it defaults text/javascript in html 5 as far know, text/javascript de facto default in modern browsers if property missing in html 4.

How does MySQL handle storing ENUM value that doesn't exist? -

for example suppose enum "a", "b", "c" , try store "d" how mysql supposed behave? design perspective there correct way of handling case? (your program receives "d" fo above enum) if using strict mode error occur otherwise store empty string value of zero. the correct way handle case ensure invalid values never inserted or use data type.

c++ - GDI+ Bitmap LockBits returns rotated image? -

i loaded image file , want write avi file: gdiplus::bitmap frame(l"test.png", false); gdiplus::bitmapdata bmp_data = {}; gdiplus::rect rect(0, 0, frame.getwidth(), frame.getheight()); frame.lockbits(&rect, gdiplus::imagelockmoderead, frame.getpixelformat(), &bmp_data); avistreamwrite(avi_stream, i, 1, bmp_data.scan0, std::abs(bmp_data.stride) * bmp_data.height, aviif_keyframe, null, null); frame.unlockbits(&bmp_data); resulting avi-file rotated 180 degrees. what's wrong? also noticed original image bottom-up ( bitmap::lockbits() returned negative bitmapdata::stride ). saved disk bitmap::save() . after loading image top-down.

asp.net - Lucene.net multi field searches -

in attempt more contextually relevant search results i've decided have play lucene.net although i'm new , i've found not intuitive library i've come across. isn't helped lack of relevant examples out there me figure out. i'm using simple lucene build index , seems working perfectly: field f = null; document document = new document(); document.add(new field("id", dl.id.tostring(), field.store.yes, field.index.not_analyzed)); f = new field("category", dl.categoryname.tolowerinvariant(), field.store.yes, field.index.analyzed, field.termvector.with_positions_offsets); f.setboost(5); document.add(f); f = new field("company_name", dl.companyname.tolowerinvariant(), field.store.yes, field.index.analyzed, field.termvector.with_positions_offsets); f.setboost(2); document.add(f); document.add(new field("description", dl.description.tolowerinvariant(), field.store.yes, field.index.analyzed, field.termvector.with_position

mongodb - mass insert mongoid -

i have web app on heroku takes plain text of comma separated values (or other delimiter separated values) user copies-and-pastes web form, , app data each line , save mongo db. for instance 45nm, 180, 3 44nm, 180, 3.5 45nm, 90, 7 ... @project = project.first # project embeds_many :simulations @array_of_array_of_data_from_csv.each |line| @project.simulations.create(:thick => line[0], :ang => line[1], :pro => line[2]) #e.g. line[0] => 45nm, line[1] => 180, line[2] => 3 end for app's purposes, can't let user kind of import, have data them textarea. , each time, user can paste upto 30,000 lines. tried doing (30,000 data points) on heroku fake data in console, terminated saying long processes not supported in console, try rake tasks instead. so wondering if knows either way takes long insert 30,000 documents (of course, can that's the way is), or knows way speedily insert 30,000 documents? thanks help if inserting many documents shou

java - PreferenceManager Trouble -

i have got self problem. have preferencemanager keeps track of preferences have default values , can set user @ run time. other day testing , input value apparently not handled way have set up. want load default values set in xml file application run again. right now, gets part loading value below dr.sethrvmax(integer.parseint(prefs.getstring("hrvmaxkey", "100"))); and spits out error 02-23 20:35:31.454: error/androidruntime(276): fatal exception: main 02-23 20:35:31.454: error/androidruntime(276): java.lang.runtimeexception: unable start activity componentinfo{cpe495.smartapp/cpe495.smartapp.smartapp}: java.lang.numberformatexception: unable parse '7p-' integer 02-23 20:35:31.454: error/androidruntime(276): @ android.app.activitythread.performlaunchactivity(activitythread.java:2663) 02-23 20:35:31.454: error/androidruntime(276): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) 02-23 20:35:31.454: error/androidrun

java - Help understanding the hibernate behavior/error -

i have product class has 1-to-many association (composite pattern). below pojo, hbm, test code , log/error respectively. can explain error about. why getting error when setting parent's primary key? product pojo public class product { private long id; private set<product> children = collections.emptyset(); public void addchild(final product child) { if (children.isempty()) { children = sets.newhashset(); } child.setparent(this); children.add(child); } } hbm.xml <class name="product" table="product"> <set name="children" lazy="false" table="product"> <key> <column name="id" /> </key> <one-to-many class="product" /> </set> </class> test public void save() { // level 1 - mortgage lob prod

parameters - Parse a custom tag using request information in JSP -

i have simple problem haven't had luck finding solution google. i want expand custom jsp tags want able parse differently depending on request information. example tag: <my:tag type="..."/> should expanded differently if parameters in request differ: http://localhost:8080/context/servlet?arg=web should yield different result than: http://localhost:8080/context/servlet?arg=mobile does know how tag parsing class (usually expands tagsupport ) can access or passed parameters request? inside tag class, can access request object , parameter by this.pagecontext.getrequest().getparameter("arg");

how to harvest all files in one folder with wix -

i have following requirement: wish harvest files in 1 folder install packet, files in folder may increase or decrease, how can automatically? , if have 2 file sources, wish file in source 2 auto-overwrite file in source 1 same file name, how can this? thanks! you can't include several file wix directly, can use tool named "heat" you. careful not recommended use automatically on build. link doc . i don't understand second question.

Sorting results in Advanced System Reporter in Sitecore -

in sitecore's advanced system reporter (v1.3) shared source module, there out-of-the-box way of sorting results before results displayed email/screen or need implement myself? in standard asr install, can see media viewer viewer configuration item has sort parameter in attributes field it's using asr.reports.items.itemviewer class which, after checking in reflector, doesn't respect sort parameter. take mean class might have respected sort parameter doesn't now. as side thought, have thought scanner class more logical place put sorting logic @ viewer class level. ok, found answer. sort parameter found used when running report asr module. the sort parameter set in attributes , in following format: sort=columnname,asc|desc,[datetime] where column name display name of column, asc or desc sort direction , required , datetime set if column date time value. example: given column formatting of <columns> <column name="item name&quo

iphone - UIImageView doesn't update -

i have problem uiimageview doesn't update. so, it's this: have uiscrollview contains uiimageview (called imageview). now, imageview , should contain more uiimageviews. uiimageviews add code not appear. this code: for(i = 0 ; < nroftilesperheight ; i++) for(j = 0 ; j < nroftilesperwidth ; j++) { imagerect = cgrectmake(j*tile_width,i*tile_height,tile_width, tile_height); image = cgimagecreatewithimageinrect(aux.cgimage, imagerect); if(!data[i][j]) nslog(@"data[%d][%d] nil",i,j); context = cgbitmapcontextcreate (data[i][j], tile_width, tile_height, bitspercomponent, bitmapbytesperrow, colorspace, kcgimagealphapremultipliedlast | kcgbitmapbyteorder32big); if (context == null) { free (data); printf ("context not created!"); cgcolorspacerelease( colorspace ); }

What is the cause of 500/503 error in Apache/Mono? -

i have web services deployed in apache/mono server in production. working fine, sometime throws 500 error(internal server error) in apache log in random manner (i.e., throws error irrespective of web service) , consequent service calls after throws 503(service temp unavailable) error, makes apache/mono crashed. need restart apache/mono run service. so question what cause of 500 error (internal server error)? what cause of 503 error (server temp unavilable)? is errors caused due memory overflow in server? is problem due apache configuration problem or code problem?

SQL Query with Typo not working in MySQL (Order by on calculated field) -

i have query in 1 of column calculated one. every thing working except not ordering results when use calculated column in query. query large 1 have simplified below understanding. here calculated column "remaining" select t1.id, t1.name, t2.duration - datediff(now(), t1.posting_time) "remaining" table1 t1, table2 t2 td.id = t1.timefield order id, name, remaining desc even if remove "remaining" order clause or use asc or desc, nothing happens , order stays same. the time when 'remaining' alters sort order when id , name in 2 rows same. otherwise, has no effect on ordering. you need fix typo of ' td.id ' ' t2.id '. you should learn join notation too: select t1.id, t1.name, t2.duration - datediff(now(), t1.posting_time) "remaining" table1 t1 join table2 t2 on t2.id = t1.timefield order id, name, remaining desc

c# - How to find the difference between two dates -

how can find difference between 2 dates. example, difference between birthdate , current date. both dates in text boxes. i'll assume text box named birthdatetextbox exists , contains birth date: datetime birthdate = datetime.parse(birthdatetextbox.text); timespan timebetweendates = datetime.now.subtract(birthdate); there overloads of datetime.parse, datetime.tryparse, should read in documentation .

Print without newline under function doesn't work as it should in Python -

i'm doing progressbar uploading script , therefor want print row of multiple '#' can't work. when tell python not add newline remove doesn't work expected under functions. using "print ('#', end='')" in python 3 or "print '#'," in python 2 removes when executed under functions doesn't print out until whole function finished, should not wait normal print. import time = 0 def status(): print('#', end='') while < 60: status() time.sleep(1) += 1 this should print '#' every second doesn't. prints them after 60 seconds. using print('#') prints out every second expected. need fix this. please help! solution: "sys.stdout.flush()" after each print :) you need flush output buffer after each print invocation. see how flush output of python print?

What is SAL_CALL in c++? -

can 1 explain me briefly. what sal_call in c++? it's #define used in openoffice.org. it's defined in sal/inc/sal/types.h 1 of: #define sal_call #define sal_call __cdecl depending on platform being compiled for. looks it's set latter when _msc_ver (for microsoft) defined. it's used when specifying functions like: virtual void sal_call acquire() throw () { ++m_nrefcount; } which morphed into: virtual void acquire() throw () { ++m_nrefcount; } for regular compilers and: virtual void __cdecl acquire() throw () { ++m_nrefcount; } for microsoft. as __cdecl means microsoft compiler, see here , extracted below: microsoft specific this default calling convention c , c++ programs. because stack cleaned caller, can vararg functions. __cdecl calling convention creates larger executables __stdcall , because requires each function call include stack cleanup code. following list shows implementation of calling convention. +------------

django - how to use contains or startwith in join query -

i want use contains in join query gives error. following models.py : class profile(models.model): name = models.charfield(max_length=50, primary_key=true) assign = models.charfield(max_length=50) doj = models.datefield() dob = models.datefield() class meta: db_table = u'profile' def __str__(self): return '%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob) def __unicode__(self): return u'%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob) enter code here class working(models.model): w_name =models.foreignkey(profile, db_column='w_name') monday = models.integerfield(null=true, db_column='monday', blank=true) tuesday = models.integerfield(null=true, db_column='tuesday', blank=true) wednesday = models.integerfield(null=true, db_column='wednesday', blank=true) class meta: db_table = u'working' def __st

localization - Is there a way to set custom language strings for the ReCaptcha ASP.Net user control? -

i'm using recaptcha asp.net user control , wondering if aware of way of setting custom language strings control markup. i know how if i'm not using user control, e.g. setting recaptchaoptions javascript variable, user control writes own variable , uses solution won't work, or haven't when tried anyway. thanks in advance. if happy use supported languages built in, this question asking how set language using user control (added in 1.0.5) think exposes publish lang property. according customisations page recaptcha site , supported languages are: english, dutch, french, german, portuguese, russian, spanish, turkish otherwise, you're going have use javascript...if have created recaptcha control before using javascript, create own user control, or perhaps modify source (for yourself) of user control provided.

Can a regex return a match that's not a part of the original string? -

i'm using application requires me provide regex various files. uses matches regex uniquely identify each file , use data store retrieve metadata these files. there problem application, assumes data used identify each file numeric data. hence, stores results of matches in integers. i control data store not names of files. since application has bug in it, hoping use encoding scheme convert non-numeric data integer. i'd require regex return that's not part of original string match. possible? edit: since question unclear. i'm not using programming language. i'm editing configuration file. application written in c++. don't know specific regex implementation using. guess it's not possible then. the reason asked question sql example allows me return that's not part of table. hoping there might similar regex. no. regular expression return part(s) of input string match pattern expression. not perform transformations or encodings, nor add s

asp.net - Can a client be considered as a Thread? -

can consider 2 clients accessing same method of web service @ same time 2 threads (with problems involved...) ? same thing methods in asp.net web application ? it depends. see answer why these asynchronous ria service calls executed in serial on web server? . it's controlled 2 properties of servicebehaviourattribute , instancecontextmode , concurrencymode . in asp.net web application, requests multiple clients tend processed in parallel, unless (for bizarre reason) both clients sharing same session , both requests pages marked requiring session (which default believe), in case 2 requests serialized.

Database design: Multiple of the same type of item -

i wasn't sure entirely how word question, i'll explain i'm thinking. have previous experience designing databases haven't decided how want implement or run across before. i'll explain i'm thinking way of showing have thought out... i'm creating database store information of user things resume (this side project bunch of college kids). issue i'm coming across how deal storing large amount of things technical skills, perhaps of order of 20+ per user proficiency idea one: 1 huge table columns of techskill1 -> 20. along proficiency. use user id fk relate of these. pros: easiest implement, easiest on front end. cons: limited 20 skills, lots of potential nulls, excessive size idea two: table of large text input skills in 1 text object delimited character comma or |. column proficiencies delimited same way. again, userid fk. pros: easy implement, small table size, easy on front end information cons: possibility of wasting lot of empty space, need m

android - Started activity from home key screen -

i have background service starts activity, intent = new intent(this, myactivity.class); i.addflags(intent.flag_activity_new_task); startactivity(i); after destroying activity , restart on "long press home key menu", activity starts again. want start main activity instead. how realise this? could explain in more detail? if understand problem try setting flag_activity_no_history. alternatively manual solution check flag_activity_launched_from_history on intent in myactivity , launch main activity if see flag set. following code should that: if ((getintent().getflags() & flag_activity_launched_from_history) > 0) { activity.startactivity(new intent(context , mainactivity.class).addflags(intent.flag_activity_clear_top)); }

How do I write php code to check if checkbox is checked or not? -

how write php code check if checkbox checked or not ? if checkbox selected yes value stored in database, , if checkbox not selected, no valued stored in database. how that? know how connect database etc. <input type="checkbox" name="cb1" value="yes" /> $cb1 = ($_post['cb1'] == 'yes')?'yes':'no'; if checkbox not clicked value null i.e. variable $_post['cb1'] not set.

html - CSS position:absolute + dynamic height -

i have 4 <div> tags 1 after other, in position:absolute , align them using top , left . the 3rd div tag contains dynamic content , height of div changes according amount of text in it. however, set top , left of divs, 4th div affected height of 3rd dynamic div. how can solve this? http://jsfiddle.net/25xrh/ you may want try wrapping 4 divs in parent div , absolutely positioning that. can allow position of 1 of children divs affect another. http://jsfiddle.net/25xrh/5/ the solution had meant no matter tried affect top:60px , left:180px stopped moving anywhere other this, dynamic content div wasn't able reposition it.

.htaccess - Allow only specific MAC addresses in Htaccess -

is possible .htaccess files allow requests specific mac address instead of ip address? and if answer yes , how? short answer: no ethernet mac not transferred in ip packet, in ethernet header. when ip packet leaves lan (technically local broadcast domain) ethernet header stripped off , mac address "lost".

c# - Having multiple properties incrementing one variable. Simple check of its value? -

i have 10 properties when each set increments value of variable value . when value of value 10, app end. seems awkward write same condition each of them this: int value=0; int { set { a=value; value++; if(value>10) ... //check here } } int b { set { b=value; value++; if(value>10) //check here again } } how can simplify checking value? private int counter; private int b; private int a; public int { set { counter++; = value; checkcounter(); } } public int b { set { counter++; b = value; checkcounter(); } } public void checkcounter() { if (counter>10) { //do } } or make counter property.. private int counter { set { counter = value; checkcounter(); } { return counter; } } and use when incrementing.. counter++;

Could not open new database 'DB Name'. CREATE DATABASE is aborted (SQL Server, Error: 948) -

*hi, the case: i trying move database 1 server another, source server has sql server 2008 r2, destination server has sql server 2008. i copied .mdf file tried use query sp_attach_db , wizard attach error, follows: attach database failed server 'server_name'. (microsoft.sqlserver.smo) ----------------------- additional information: exception occurred while executing transact-sql statement or batch. (microsoft.sqlserver.connectioninfo) the database 'db_name' cannot opened because version 661. server supports version 655 , earlier. downgrade path not supported. not open new database 'db_name'. create database aborted. (microsoft sql server, error: 948) i dont think possible attach database higher version of sql server lower version. eg 2008 2003 not ok, going 2003 2008 ok. you try doing import export data have not worked out how attach far.

messagebox - Rails private message system -

hey, i'm trying implement message system used in social networks. problem i'm facing first database structure , second how implement in rails. first idea i'm using 3 tables: messages: id|subject|text|created_at receivers: id|message_id|read:boolean creators: id|message_id|read:boolean now i'm wondering how implement following features: 1.) user can delete message. both want read message, how make sure message deleted when both users have deleted it. 2.) how implement reply? or how find corresponding creator? 3.) how find out whether mail read receiver? another idea is: creator_messages: id|creator_id|receiver_id|subject|text|read|created_at receiver_messages: same creator_messages this distinguishes between users, can delete individually messages. how find out, whether mail read or not? my third approach basicly second 1 table messages , displaying user. 1. message deleted 1 of user deletes it. 2. how represent relationships has_many , belongs to?

android - Swipe/Fling tab-changing in conjunction with ScrollView? -

the best find on particular issue (although not use gallery): scrollview , gallery interfering - doesn't give specific answer though. , implementation not use gallery, obviously. jump down next bold part interesting part so got fling/swipe/flick/whatever want call work while ago on application. inspiration gathered couple of different places, of them being "basic gesture detection" here on stack overflow ( fling gesture detection on grid layout ), code shogun ( http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ ) , developing android ( http://developingandroid.blogspot.com/2009/09/implementing-swipe-gesture.html ), not use viewflipper in application. when fling occurs change tab (wrapping around @ ends). now, of tabs contain scrollviews. these scrollviews respond up/down scrolls in order let view data inside it, no surprise there. issue appear 'scroll' function of these scrollviews overwrite fling gesture. cannot flin

mySQL stored procedure error -

i trying use if statement in stored mysql procedure, when try create in mysql workbench error error 1064: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'database'.'table' date=datein; . here code: delimiter $$ create definer=`rates_d_db` procedure `bydate`(in datein varchar(255),in action varchar(255)) begin if action = "edit" edit `database`.`table` date=datein; else select * `database`.`table` date=datein; end if; end$$ i new stored procedures, it's noob mistake. thanx in advance! date reserved word in mysql. have wrap in backticks well.

android - Unable to get the proper result -

here function.. public cursor fetchallalarmgreaterbydate(long appdate, int apptime) { return mdb.query(alarm_table, null, alarm_date + ">" + appdate + " , " + alarm_time + ">" + apptime, null, null, null, alarm_date + " asc" + " , " + alarm_time + " asc"); } i unable result in asc on both column alarm_date , alarm_time (it gives syntax error). if use alarm_date + " asc" doesn't give error problem doesn't give result. how make work properly? try public cursor fetchallalarmgreaterbydate(long appdate, int apptime) {return mdb.query(alarm_table, null, alarm_date + ">" + appdate + " , " + alarm_time + ">" + apptime, null, null, null, alarm_date + " asc" + " , " + alarm_time + " asc"); } just replace the"and" in query "," asc

Basic Sproutcore: class method, class variables help -

this how defining simple class instance variables , instance methods. exampleclass = sc.object.extend({ foo:undefined, bar: function() { this.foo = "hello world"; console.log( this.foo ); } } // test var testinstance = exampleclass.create(); testinstance.bar(); // outputs 'hello world' could me out similar example of class variable (or similar behavoir), , class method? thanks a class method/property done like: exampleclass = sc.object.extend({ foo:undefined, bar: function() { this.foo = "hello world"; console.log( this.foo ); } } exampleclass.mixin({ classfoo: "foo", classbar: function() { return "bar"; } }) then can access like: exampleclass.classfoo but don't forget when accessing property (or computed property) on instance, need use .get() like: var example = exampleclass.create(); // example.get('foo'); example.set('foo', 'b

php - Storing and selecting multiple ids in database -

i have newsletter component , users can subscribe multiple newsletters. stored in table of subscribers this: 4,8,11 (these id's of newsletters subscriber subscribed to) to select subscribers of newsletter use: "select * #__newsl_subscribers newslids '%" . (int) $id."%'"; when want select users receive newsletter id 1, user receives newsletter 11 (or 12, 10 etc..) selected. , that's problem. is there select-statement this? otherwise have store id's brackets around them [1],[11], etc... you should avoid solutions several ids stored in 1 field. instead should use foreign keys and, in case n:m relationships, relationship tables. n:m-relationships these a can have multiple b , vice versa. i following: table "subscriber": no information newsletters table "newsletter": no information subscribers new table "newsletter_subscriber" : field: subscriber_id field: newsletter_id both fields foreig

floating point - Why does using float instead of double not improve Android performance? -

since smart phones (at least ones, can find specs on) have 32-bit processors, imagine using single precision floating-point values in extensive calculations perform better doubles. however, doesn't seem case. even if avoid type casts, , use floatmath package whenever possible, can hardly see improvements in performance except memory use, when comparing float-based methods double-based ones. i working on rather large, calculation intensive sound analysis tool, doing several million multiplications , additions per second. since double precision multiplication on 32-bit processor takes several clock cycles vs. 1 single precision, assuming type change noticeable... isn't :-( is there explanation this? due way dalvik vm works, or what? floating-point units on typical cpus perform of calculations in double-precision (or better) , round or convert whatever final precision is. in other words, 32-bit cpus have 64-bit fpus. many phones have cpus include fpus, have fp

scala - Choosing the last element of a list -

scala> last(list(1, 1, 2, 3, 5, 8)) res0: int = 8 for having result above, wrote code: val yum = args(0).toint val thrill: def last(a: list[int]): list[int] = { println(last(list(args(0).toint).last) } what problem code? you can use last , returns last element or throws nosuchelementexception , if list empty. scala> list(1, 2, 3).last res0: int = 3 if not know if list empty or not, may consider using lastoption , returns option . scala> list().lastoption res1: option[nothing] = none scala> list(1, 2, 3).lastoption res2: option[int] = some(3) your question list , using last on infinite collection (e.g. stream.from(0) ) can dangerous , may result in infinite loop.

HTML5 optimized for iPhone -

i have software have reports accessed via iphone. once not willing develop iphone app, i´d make these reports accessible via iphone safari browsers. gmail in ipad uses html 5, guess can same. my question can find resources learn best practices doing , how can test in pc computer. thanks here similar answer i've given: exclusive css iphone/android for testing can use chrome or safari, both webkit browsers (which iphone uses). safari can render iphone user agent. hope helps.

C#: Compare a Regex string with groups -

i have string: {test1}-{test2}/{x+y} i want check whether {test1}{test} matches string. it match if ignore chars between }...{ how write regex? update: i want check whether {test1}{test2}{x+y} matches string: {test1}-{test2}/{x+y} i assuming comment means want use following pattern {test1}{test2}{x+y} , want match first string, additional rule between braced groups can provide anything, minus , division there should not prevent match. to match input, can contain arbitrary characters between braced groups, use type of regular expression: \{test1\}.*\{test2\}.*\{x\+y\} this match: {test1}{test2}{x+y} {test1}-{test2}/{x+y} {test1}+{test3}*{test2}/{test4}-{x-y}+{x+y} --------- --------------- <-- parts match .*