Posts

Showing posts from June, 2012

android - How to pass Intent Extras? -

public class menus extends activity { //set constants mediastore query, , show videos private final static uri media_external_content_uri = mediastore.video.media.external_content_uri; private final static string _id = mediastore.video.media._id; private final static string media_data = mediastore.video.media.data; //flag 1 used images selection private gridview _gallery; private cursor _cursor; private int _columnindex; private int[] _videosid; private uri _contenturi; protected context _context; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); _context = getapplicationcontext(); _gallery = (gridview) findviewbyid(r.id.videogrdvw); //set default external/sdcard uri _contenturi = media_external_content_uri; //initialize videos uri //showtoast(_contenturi.getpath()); initvideosid(); //set gallery adapter setgal

php - ExtJS String to Combobox -

i have php file returns string this ["item1","item2","item3","item4"] i need create combobox extjs. options must items 4 options. how if php link items.php . make things clear need combobox displayfield , valuefield have same values, item1 displayfield , valuefield . in advance! p.s. string not json formatted, guess it's array store. firstly, think have modify php script returns string @ least [["item1"],["item2"],["item3"],["item4"]] . otherwise have create own extjs reader or override ext.data.reader.array.read method. secondly, store should this: var store = ext.create('ext.data.store', { fields: ['item'], proxy: { type: 'ajax', url: '/items.php', reader: { type: 'array' } } } thirdly, combo config should this: ext.create('ext.form.combobox', { store: store, displayfield: 'item', v

javascript - Imagemap layer on top of united states map... jquery rollovers -

i trying make clickable united states map in html. think best way create imagemap image , use jquery there rollovers , such. know best way make imagemaps irregular shapes (states in case). looking in photoshop seems used have don't. dreamweaver might best choice: http://help.adobe.com/en_us/dreamweaver/10.0_using/wscbb6b82af5544594822510a94ae8d65-7c13a.html

c# - Active directory cross domain - group members using PrincipalContext -

i trying fetch members of given active directory group using directoryservices.accounemanagement namespaces classes in c#. if have principal context object constructor specified specific domain, whenever access member the group other domains running below error: "a referral returned server". scenario : have different sub domains under root domain eg: emea.mycorp.com, asia.mycorp.com, asiapacific.mycorp.com, xyz.mycorp.com if running below code domain xyz.mycorp.com, group in asiapacific if specify servername in principal context object access group. private principalcontext context = new principalcontext(contexttype.domain, "asiapacific domain server name"); if group has users other domains emea\abcd, below code fails @ userprincipal: groupprincipal searchgroup = groupprincipal.findbyidentity(context, "dev team"); groupname = new list<string>(); foreach (userprincipal p in searchgroup.getmembers()) {

java - Stop/disable specific webservice under Apache -

i have jboss running on linux runs java soap webservice. deal none of on day-to-day basis, can't give many specifics. webservice heartbeat part of system. given design of system (which going changing soon, hopefully), cannot take server "out of rotation" patch it. i'm wondering there specific way disable webservice running heartbeat while allowing other web stuff continue? if lives in own .war , remove .war $tomcat_home/webapps - service come down (and rest stay up).

C# Service Word "There is insufficient memory. Save the document now" -

i writing c# window service run on server (installed office) need convert ms word doc rtf file , load richtextbox, , rtf string , plaintext string db (get plaintext string full text indexing allowing user search) i used following code perform conversion in service, however, error occurred on line newapp.documents.open "there insufficient memory. save document now" i've check on server task manager , found winword.exe loading lot of memory (says 60~70 mb) , don't quit (well, exception..... >_<) i've try same code run in same machine windows form, , got no error. , service set run administrator already. private void doc2rtf(object source, object target) { //creating instance of word application word.application newapp = new word.application(); newapp.automationsecurity = microsoft.office.core.msoautomationsecurity.msoautomationsecurityforcedisable; newapp.displayalerts = word.wdalertlevel.wdalertsnone;

ruby on rails - How can I stop a form repeating using fields_for? -

Image
i have table of venues each can have many offers. i have form adds offers venues venues edit page. once submit form newly created offer shown partial instead of form clearing allow offer entered, form created. so if enter 5 offers have 6 add new offer forms, 5 of them details entered saved ones. my code looks this: venue model class venue < activerecord::base has_many :offers accepts_nested_attributes_for :offers, :reject_if => lambda { |a| a[:title].blank? } end edit - venue controller class venuescontroller < applicationcontroller protect_from_forgery :only => [:update, :delete, :create] load_and_authorize_resource def index if @venues = venue.with_type(params[:venuetypes]).with_area(params[:areas]).order("average_rating desc").all else @venues = venue.all end @venues = @venues.paginate :per_page => 15, :page => params[:page] end def new @venue = venue.new end def create @venue =

apache - htaccess folder rewrite -

i've been reading multiple posts on here htaccess folder rewriting none seem fit question (properly). my question is: i have 2 sub folders on server, website1 , website2. when user goes www.foo.com wish visual url remain same want server uri go /website1/ load index.php website1 i want same thing when user goes www.bar.com again url not change time links /website2/ load index.php 2nd website. would appreciate i'm still learning rewrites. examples explanations highly appreciated. advice of best practice (if any) appreciated. kingcrunch right -- proper way setup such environment use <vistualhost> directive in apache config file. if, whatever reason needs dona via rewrite , .htaccess .. need mod_rewrite enabled , .htaccess files allowed contain rewrite rule ( allowoverride directive). here rules: options +followsymlinks -multiviews rewriteengine on rewritebase / # rule #1 rewritecond %{http_host} =www.foo.com rewritecond %{request_uri} !^

php - Codeigniter routing -

in codeigniter possible make routing ignore pattern route else, example tests/index treated normal other /index routed through tests/test possible? not positive how work, try should match index, , route tests/whatever matched. $routes["test\/((?!index).*)"] = 'tests/$1';

php - MySQL Database Connection Problems -

i set a database, , made code allowed people register members page on website i'm building. code used has worked before, many times, reason keep getting error message when try submit data test: failed connect server: lost connection mysql server @ 'reading initial communication packet', system error: 111 i've tried know, nothing works. think i'm missing something, here's php code sends data (however, nothing in code seems wrong or out of place): <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(db_host, db_user, db_password); if(!$link) { die('failed connect server: ' . mysql_error()); } $db = mysql_select_db(db_database); if(!$db) { die("unable select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $fname =

objective c - Analyze error when autorelease called on object returned by class_createInstance -

i'm adding code provided partner ios project calls class_createinstance , calls autorelease before returning, this: class functionclass = objc_getclass(functionname); nsobject* functionobject = class_createinstance(functionclass, 0); [[functionobject performselector:@selector(initwithdictionary:) withobject:msg] autorelease]; when running analyze in xcode 4.0.2, following warning on last line: object sent -autorelease many times question 1: how object getting sent autorelease many times? understanding of class_createinstance need release value returns. question 2: if code correct, how can avoid warning analyze? have pretty strict policy not check in analyze warnings. this decidedly odd pattern and, thus, analyzer isn't aware of it. use of class_createinstance() extremely rare. two possible solutions off top of head: use preprocessor markup tell analyzer that, yes, in fact, functionobject retained reference (i don't have markup handy --

backbone.js - How to use Ruby code inside JST files? -

i using jammit package assets. 1 of things package files .jst extension , make them available in window.jst namespace in browser. however, i've been looking way make templates dynamic, , i'm not sure how or if it's possible. what alternatives have if cannot make jst files dynamic? as far can tell rails 3.0 isn't possible. jammit assumes jst files javascript files. maybe in later versions may add ability. wouldn't count on happening time soon. if able upgrade rails 3.1 can replace jammit asset pipeline allows run through erb or ever language want before ends jst file. kliment mamykin made walkthrough upgrade rails 3.0 rails 3.1.rc4 asset pipeline enabled. http://mamykin.com/2011/07/03/upgrading-to-rails31-rc4.html

java - Doubt about strictfp and StrictMath -

i have little technical question, same call: public static strictfp double mymethod(double phi){ return math.exp(phi); } or: public static double mymethod(double phi){ return strictmath.exp(phi); } or strictfp keyword applies basic arithmetic operations + - * / used inside method? or strictfp keyword applies basic arithmetic operations + - * / used inside method? the strictfp keyword applies operations in method or class modifies. doesn't reroute calls math functions strictmath , need explicitly use strictmath instead of math . from http://www.esus.com/javaindex/j2se/jdk1.2/javamath/strictfp.html if floating point expression within strictfp "scope" , results predictable described in ieee 754 ...

visual studio 2010 - Cannot initialize unordered_map from int -

i've got strange problem. msvc doesn't have initializer lists, i've used lambda approximate them. static const std::unordered_map<std::wstring, lexedfile::token> reserved_words = []() -> std::unordered_map<std::wstring, lexedfile::token> { std::unordered_map<std::wstring, lexedfile::token> retval; // stuff retval return retval; }(); msvc throws compiler error. error c2440: 'initializing' : cannot convert 'int' 'std::tr1::unordered_map<_kty,_ty>' unless i'm quite blind, there's no "int" anywhere near this. don't see what's wrong. suggestions? edit: there's nothing funky // stuff retval , it's bunch of insertions, , function-scope static variable in lambda in member function. auto next = [&] { static const std::unordered_map<std::wstring, lexedfile::token> reserved_words = []() -> std::unordered_map<std::wstring, lexedfile::token>

.net - Using as operator to cast, even after using is operator to verify class type in C#? -

i understand using as operator cast object, on explicit cast, more desirable due fact if cast fails, reference variable goes null instead of throwing exception. however, lets check see type of class object is, that's inside of list, prior using as operator, so, drawablegamecomponent drawcomponent; foreach (component in components) { if (component drawablegamecomponent) { drawcomponent = component drawablegamecomponent; // drawcomponent } } does using as operator lose benefits checking is operator first? doing following cast good, because first check class type using is before attempting cast? if (component drawablegamecomponent) { ((drawablegamecomponent)componet).visible = true; } i'm wondering if there underlying piece i'm missing, or if comes down matter of taste pattern use. latter pattern create garbage through explicit cast? thanks in advance! better (saves 1 "cast" - compare generated il)

android - How to use R to select a ListView when using it with ListActivity -

i have code: public class myactivity extends listactivity implements onclicklistener { private arraylist<string> listitems = new arraylist<string>(); arrayadapter<string> adapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.setadapter(); this.bindbuttons(); } private void setadapter() { setcontentview(r.layout.siteactivity); adapter=new arrayadapter<string>(this, r.layout.siteitem, listitems); setlistadapter(adapter); } private void bindbuttons() { findviewbyid(r.id.buttonprevious).setonclicklistener(this); findviewbyid(r.id.buttonnext).setonclicklistener(this); } // ... } with layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

java - How can I modify what controls show up for my VideoView? -

i have videoview controlled simple mediacontroller i'd modify controls for. currently, shows seek bar, fast-forward , rewind buttons, , play/pause. i'd narrow down having play , pause buttons, stream i'm playing more or less live. how can modify controls present? current code in oncreate : this.setcontentview(r.layout.videoplayer); this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); this.videoview = (videoview)this.findviewbyid(r.id.videoview); this.mediacontroller = new mediacontroller(this); this.mediacontroller.setanchorview(this.videoview); uri uri = uri.parse(this.getintent().getstringextra("uri")); this.videoview.setmediacontroller(this.mediacontroller); this.videoview.setvideouri(uri); this.videoview.setonpreparedlistener(new onpreparedlistener() { @override public void onprepared(mediaplayer mp) { findviewbyid(r.id.video_loading_spinner).setvisibility(view.gone);

Property as a decorator in Python 2.4? -

i'm developing application tied down python 2.4. according python builtins page's description of property "the getter , setter , , deleter attributes added" in python 2.6. there still way use property decorator, or imperative use x = property(...) syntax? you can use decorator, can only specify getter if so. can delete getter, setter, , deleter methods once have called property() though.

.net - finding the sum of a column -

i have 3 columns in table first 1 start time, second 1 end time , third 1 duration. now want find out sum of duration column, ideas how can it? however using .net programming language select sum(duration) tablename

git submodules - 'Git could not checkout' error is causing problem while deploying an app on engineyard -

i'm trying deploy app on engine yard. i'm using rails 2.3.5 , ruby 1.8.7 when try deploy it, ~> deploying revision 481f05e emergency commit :: running git checkout -q '481f05e42f3e13b5eda7e598a1b797b031c9ca5e' :: running git submodule sync synchronizing submodule url '' :: running git submodule update --init no submodule mapping found in .gitmodules path 'school' no submodule mapping found in .gitmodules path 'school' *** [error] git not checkout (481f05e42f3e13b5eda7e598a1b797b031c9ca5e) *** is git submodule sync causing problem? i not have submodules in repository. i not have submodules in repository. that means shouldn't see .gitmodules file in repo. if there is, means have somehow submodule declared (in case you might want remove it ). if there isn't .gitmodules file, within school path makes deployment script believe submodules, , tries access (non-existent) .gitmodules file of parent repo. may sc

apache - How to run python scripts? -

i php developer , want use python project. common , simplest way run python script on server apache or lighttpd? having trouble understanding how server languages not php or asp run on servers. in python have called wsgi . believe right now. grab python web framework, django . comes web server , documentation on how deploy later . play , things start clear up. the longer version python general purpose language - it's not designed web php is. need bit of work web stuff , have frameworks (django easiest start with, why i'm recommending you). in general should understand how web works. uses http protocol communication, build on top of tcp stack, web application server, uses sockets ( php has them well python ) , understands http. python comes 1 build in - simplehttpserver , not production uses (it's great development, though). why there things mod_wsgi (python specific), fastcgi (general purpouse). things ways real, production grade, web server (apache,

mysql - SQL 3 column query on condition -

i'm still pretty new sql , have table following street | family | car -------------------------------- mayfair | jones | bmw mayfair | jones | ford mayfair | jones | mazda mayfair | smith | bmw mayfair | fox | bmw park lane | taylor | ford park lane | taylor | mazda park lane | cole | bmw i wondering if there single query can done check particular street, see if there car family's have? so instance in above table query return bmw mayfair family's on mayfair own bmw. i'm using xampp @ moment mysql don't have fancy server or setup etc... thanks select street, car tablex t1 group street, car having count(distinct family) = ( select count(distinct t2.family) tablex t2 t2.street = t1.street ) or: select distinct street, car --- show streets , cars tablex not exists --- there no ( select family

java - Problem with Method.invoke -

i have method return list of objects , want call invoke method of class method. problem invoke method returns object , not list<object> . the code here: class<? extends anobject> anobject = myobject.getclass(); method mymethod = myobject.getmethod("getlistobject"); object objject = method.invoke(myobject); // want return list how can solve it? class<? extends anobject> anobject = myobject.getclass(); method mymethod = myobject.getmethod("getlistobject"); list object = (list)mymethod.invoke(anobject);

ruby on rails - Mailer result as String? -

in our custom sales app our users able send emails based on text partials choose. need record sent mails in activity model. how mailer result string in order save it? instead of calling deliver method send mail, can capture email message calling to_s. example, if have mailer: class mymailer < actionmailer::base default :from => "sender@me.com" def my_email mail(:to => "destination@you.com", :subject => "mail subject") end end you mail_content = mymailer.my_email.to_s

automated tests - how to validate data retrieved from db using jmeter? -

i want retrieve data db using jmeter , take results, compare values sent in request. can suggest me few ideas on how accomplish using jmeter only? i'm able store message in db , retrieve same data( saved in form of file). not able compare further. thanks, bharath to validate response, you'll want use assertion samplers , of there several may find useful you're doing.

iPhone: MultiTouching -

i have lot of buttons on view. , when hold finger @ 1 of them, still can tup on others buttons , actions. how block ? thanks... did u try setting exclusivetouch property yes ? exclusivetouch a boolean value indicates whether receiver handles touch events exclusively. @property(nonatomic, getter=isexclusivetouch) bool exclusivetouch discussion setting property yes causes receiver block delivery of touch events other views in same window. default value of property no. availability available in ios 2.0 , later.

database - NOSQL Design, without denormalization? -

i've started designing 'schema' of distributed store database. i keep having mental debates on how denormalize. understand how it, , why increase performance if denormalization matches queries minimize gathering data multiple places... ...but, it's said pre-mature optimization bad. advantages of design relational, references instead of duplicate data embedded clear: elegant, flexible, no worries keeping duplicate data consistent, etc. so wondering whether it's reasonable strategy design schema in relational way, using application layer gather data necessary, , change later if needed. if traffic becomes issue, on technology can scale horizontally design changes (isolation, denormalization). seems best choice among: start rdbms, move distributed store if needed start distributed store, full denormalized design (scale-ready) start distributed store relational design, denormalize + isolate if needed thoughts? thanks i'd go option 2,

scala - Methods in trait become volatile methods when mixed in concrete classes in 2.9.0-1 but not 2.8.1 -

i noticed breaking (for me using ognl) change in 2.9.0-1: i find that, in 2.9, methods declared in trait become volatile when mixed in class: example in 2.9.0-1 import java.lang.reflect.modifier trait supertrait { def getknoll = "kanutten" } class klasswithknoll extends supertrait { def getknall = "mars" } val qsc = classof[klasswithknoll] val knollgetter = qsc.getdeclaredmethod("getknoll") println("isvolatile: " + modifier.isvolatile(knollgetter.getmodifiers())) this prints out isvolatile: true but in 2.8.1: it prints out isvolatile: false this breaking change me ognl refuses execute volatile (why don't know) in expressions. so - question is; why change made? there's no such thing volatile method. seeing 0x0040 flag set, acc_volatile fields, acc_bridge methods. since modifier.isvolatile method takes int, can't tell you're asking not meaningful.

plsql - PLS-00323 error in oracle -

i creating procedure in package. have updated specification of package , when updating body of package shows me following error. [error] pls-00323 (314: 13): pls-00323: subprogram or cursor 'insert_customer_address' declared in package specification , must defined in package body n.b.: insert_customer_address procedure name. as experiences many times, related definition of function/procedure(i mean variable names , corresponding types), if there variable in body , not in spec, cause error. common error don' worry!

drupal - Theme a custom menu with theme_menu_tree() -

i'm trying override custom menu output in block instead of <ul class="menu">...</ul> i can <select name="menu title">...</select> in drupal 6, use function theme_menu_tree($tree,$menu_name="") {...} doesn't work in drupal 7 function theme_menu_tree($variables) {...} . i've tried theme_menu_tree__mymenu($variables) {...} no success. how specify unique menu in drupal 7? thanks. i had same problem overriding , correct naming of theme_menu_tree function specific menu name. found suppose correct name of function should be: your_themename_menu_tree__your_menuname the name of menu taken administration » structure » menus pages. seems me drupal adds word "menu" before of new user menus. in case created menu called "testing menu" in theme "mytheme" , name of overriding function was: mytheme_menu_tree__menu_testing_menu

c# - Remote Installation/Deployment of MSI/EXE files: -

remote installation/deployment of msi/exe files: i wanted develop/explore c# code remote installation/deployment of msi/exe files. remote installation of applications should done taking data xml file has remote computers ip addresses, port numbers, etc. there many tools available presently remote installation/deployment, develop code or else explore available code remote installation/deployment. can me in issue. thanks in advance. writing custom code network deployment not feasible. type of deployment complex need create entire framework around it. so have 2 options: use built-in microsoft tools: group policy or sccm use commercial network deployment tool each approach has it's own advantages , disadvantages, should research both of them before deciding.

objective c - How to return to my iphone application after call ends? -

i able call iphone application using below code: nsstring *phonenumber = @"tel://1234567890"; [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:phonenumber]]; now, want know how return application when call ends ? as far i'm aware, such interaction impossible since application has been demoted background, , ui interaction has been delegated phone app, , user.

android - ExpandableListView ignores setSelectedChild() -

i try select item in expandablelistview using setselectedchild(int groupposition, int childposition, boolean shouldexpandgroup), nothing happens. here's primitive activity tested with: import android.app.activity; import android.graphics.color; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.view.viewgroup; import android.widget.baseexpandablelistadapter; import android.widget.button; import android.widget.expandablelistview; import android.widget.textview; public class startupactivity extends activity { private static final string[] _items = new string[] {"oops", "wham", "bam"}; private expandablelistview _explist; private textview _txt_hello; private button _btn_sel; private myexplistadapter _explist_adapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main);

Symfony 2 receiving anonymous token after basic authentication -

i have symfony 2 app using basic in_memory authentication (as described in security documentation ). login works fine in our development environment(s). on staging server, basic authentication doesn't seem provide proper token -as seen in hereby provided logfile-; keep on getting login popup again , again. our security configuration: security: firewalls: secured_area: pattern: ^/ anonymous: ~ http_basic: realm: "secured demo area" access_control: - { path: ^/admin, roles: [role_admin]} providers: in_memory: users: admin: { password: admin, roles: 'role_admin' } encoders: symfony\component\security\core\user\user: plaintext this log output (successful) development environment login: [2011-07-21 13:49:48] security.debug: read securitycontext session [] [] [2011-07-21 13:49:48] security.debug: reloading user user provider.

visual studio - Scrabble Word Placement C# -

i'm writing scrabble-like game in c#. can computer find highest point value word can made using current rack, have no idea how check if word "placeable" on 15*15 gameboard(2d array: string[,]). in it's default state(with no letters on board) elements set 0. is allowed --------------- -------h------- -------e------- -----fill------ -------l------- -------o------- --------------- how can check if word not example: is not allowed --------------- -h------------- -e------------- fill------------ <-- f out of bounds -l------------- -o------------- --------------- is not allowed --------------- -h------------- -e-w----------- -l-o----------- -l-r----------- foll----------- <-- fill overlapping o ---d----------- the paper, " the worlds fastest scrabble engine " (pdf), 1988 , describes efficient scrabble engine. it's short , surprisingly readable!

sending html form data to php -

i using drupal site.here code have written in client side <form method="get"> email :<input type ="text" name ="email" size ="20"><br /> <button style="width:65;height:25" onclick='email_direction_data()'><b>send</b></button> </form> when click button page refresh.text field used enter email address.i have written below code inside drupal module file in function send email. drupal_mail('direction', 'invitation', $_get['email'] , language_default(), $params); but text field content not going array when click button.what reason that?is there wrong in code? you need have html <input type="submit" /> button, not <button> tag.

string - Forcing a pass-by-reference in Python -

boy not understanding python pass-by-reference issues... have created extremely useful "unpacker" class pass around various objects need unpack it, yet given how extraordinarily slow is, can tell it's making copy of binarystr each time pass bu object. know because if break bu smaller chunks, runs, literally, 100x faster (i using hold 16mb file i/o buffer) so question is, why member not getting passed reference, , there way force to? pretty sure bu object passed reference (since code works), speed suggests .binarystr object copied. there more subtle i'm missing? class binaryunpacker(object): def __init__(self, binarystr): self.binarystr = binarystr self.pos = 0 def get(self, vartype, sz=0): pos = self.pos if vartype == uint32: value = unpack('<i', self.binarystr[pos:pos+4])[0] self.pos += 4 return value elif vartype == uint64: value = unpack('<

python - Get file size during os.walk -

i using os.walk compare 2 folders, , see if contain exact same files. however, checks file names. want ensure file sizes same, , if they're different report back. can file size os.walk ? the same way file size without using os.walk , os.stat . need remember join root: for root, dirs, files in os.walk(some_directory): fn in files: path = os.path.join(root, fn) size = os.stat(path).st_size # in bytes # ...

exception - Grails error handler always receives null pointer -

we have custom error controller gets called after of our errors. however, of our errors thrown end coming controller null pointers, though original error not null pointer. ideas? code below. bootstrap , urlmappings available if needed. thanks error handler method def handleerrors = { def exception = request.exception.cause.class if (exception) { exception ex = request.exception //this exception npe ... block of code throwing exception. did not have try catch in here, wanted add sure exception being thrown not npe. file not found exception. try{ def writer = new filewriter( new file(filesavelocation)); } catch ( ex) { throw(ex) } edit: adding exception pushed exception handler exception:org.codehaus.groovy.grails.web.errors.grailswrappedruntimeexception cause:org.springframework.web.util.nestedservletexception: request processing failed; nested exception java.lang.nullpointerexception

block - Lock files in PHP without using flock -

when user upload file(users can upload multiple files) exec('nohup php /main/apache2/work/upload/run.php &'); i using nohup needs executed in end. in original design run.php scans directory using scandir everytime it's executed. exclusive lock lock_ex on file using flock , use lock_nb skip file if has lock , go next one. if file has lock //do logic . problem server missing fcntl() library , since flock uses library execute locking mechanism, flock won't work @ moment. it's going take month or 2 installed(i have no control on that). so work around have temporary file lock.txt acts lock. if filename exists in lock.txt skip file , go next one. $dir = "/main/apache2/work/upload/files/"; $files = scandir($dir); $filename = "lock.txt"; for($i=0; $i<count($files); $i++) { if(substr(strrchr($files[$i],'.csv'),-4) == '.csv') { if($file_handle = fopen("$filename", "

Could not connect: Access denied for user shout1@localhost (using password:YES) 'Error PHP / MySQL -

i have script set on site static shoutbox page people leave comments etc. everthing /was/ working fine. have set constants in shoutbox.php file such; define("host", "localhost"); define("user", "shout1"); define("password", "xxxxxxxx"); define("db", "shout1"); my database called shout1 , user name assigned same. have created table on database called shoutbox has 4 entries of id (int), date, user (varchar) & message (varchar) believe fine. when go domain in question http://p4blo.it/shoutbox error mentioned in title advising access denied @localhost shout1 any ideas? have double , triple checked, deleted db , tables, recreated etc. edit: forgot mention, user shout1 has been assigned access full privileges database shout1 looks host runs cpanel. in cpanel have carefull user , database names, since prefixed cpanel-username. eg. if cpanel-username "p4blo" database ca

ruby - Sinatra/Rack params[] in before block -

i'm making site using sinatra, going well, or until needed access params[] hash in before block. basically, i'm trying this: before if params[:forum_id] @forum = forum.find(params[:forum_id]) build_breadcrumbs(@forum.parents) # ... more code, snipped keep short end end but thing is, can't call params[] hash in before block, have ideas? the reason i'm putting code in before block because i'd rather not have go , put in every 1 of get , post blocks every page. from docs: before filters evaluated before each request within same context routes , can modify request , response. since happens before actual request, can't access request parameters. can put repetitive code method , call in route blocks.

sql - Need help optimizing this tSQL Query -

i'm not dba , unfortunately don't have dba consult within @ our company. wondering if give me recommendation on how improve query, either changing query or adding indexes database. looking @ execution plan of query seems outer joins killing query. query returns 350k results, takes 30 seconds complete. don't know db's, don't think good? perhaps i'm wrong? any suggestions appreciated. in advance. as side note being create orm , not me directly. using linq-to-sql. select [t12].[value] [discoveryenabled], [t12].[value2] [isconnected], [t12].[interface], [t12].[description] [interfacedescription], [t12].[value3] [duplex], [t12].[value4] [isenabled], [t12].[value5] [host], [t12].[value6] [hostip], [t12].[value7] [mac], [t12].[value8] [macadded], [t12].[value9] [portfast], [t12].[value10] [portsecurity], [t12].[value11] [shorthost], [t12].[value12] [snmplink], [t12].[value13] [spe

ajax - State Change After Update (by Another User) But Before Poll -

suppose have following scenario: 2 users both signal ready play, rails app receives , starts game one of 2 users issue "forfeit" via ajax (im assuming it's not possible prevent that, amirite?) by time other user polls figure out whether game has started, game has ended , scores updated that user confused i'm not quite sure here. can give me ideas? alright, figured out did wrong. (cant self answer yet because rep low) when user polls figure out whether his/her game has started, , receive moves , etc, check "game in progress" , "user = user polling" attributes figure out respond. that's wrong, because ends, logic fails find relevant game retrieve data , give user. what i'm think of right is, add "end game has been polled" attribute game object (well, playing objects through relationships) if game ended has not been polled, user receive once respond confirm. game not polled again. the flag indicating gam

layout - Multiple rows with CSS floating divs -

i implement such design using floating css divs: --------------- |header | --------------- |col1| row1 | | |--------| | | row2 | --------------- | footer | --------------- i searched around found no easy way it. how achieve this? thanks. edit: want clarify problem. want have 2 rows of images next menu bar on left. trying use float:left image layout. edit2: solved problem myslef using display:inline-block image elements instead of float:left. i start container has width of page. example, we'll width:950px. of weird widths caused because of borders, if removed them, the widths more regular numbers 400, 950, 350 etc. here live example: http://jsfiddle.net/edgbp/embedded/result/ <html> <head> <style type="text/css"> #maincontent { width:950px; height:100%; margin:0 auto; } #header { width:946px; height:150px; border:#000 solid; border-width:2px 2px 1px 2px; } #leftcolumn { widt

compilation - Python: getting segmentation fault when using compile/eval -

code: import ast globalsdict = {} fast = ast.functiondef( name="foo", args=ast.arguments(args=[], vararg=none, kwarg=none, defaults=[]), body=[], decorator_list=[]) exprast = ast.interactive(body=[fast]) ast.fix_missing_locations(exprast) compiled = compile(exprast, "<foo>", "single") eval(compiled, globalsdict, globalsdict) print globalsdict["foo"] with both cpython , pypy, getting segmentation fault. why? cpython bug report pypy bug report abstract syntax trees documentation i guess function definition must not have empty body. tested code adding no-op statement function body: fast = ast.functiondef( # ... body=[ast.pass()], # ... and segmentation fault gone; output is: <function foo @ 0x022db3f0> if correct, bug in ast module, since should check empty body.

silverlight - What setting in IIS that could cause XAP to download everytime when access the page from fresh IE? -

i have sample program nothing hello world. open ie , go development environement , access silverlight, loads xap first time , if close ie , open again, xap not downloaded. since there no changes expect not download. after deploying in qa environement, open ie first time, load xap expected. now close ie , open again, expect not download xap does download xap again. if refresh on page not download xap. happens on fresh ie open in our qa environment. all above tests done on same box same ie setting. there no client side ie cache issue. did check date , time on servers see if there difference specified in silverlight xap gets downloaded everytime link , our servers in same date , time. does 1 know how prevent iis not download everytime? the default settings in ie mean fresh instance of ie always attempt fetch each unique url when first encountered. ie if cache headers sent resource last time fetched indicate resource still fresh. however ie send if-modified-since

ssrs 2008 - cant access reportsmanager with "browser" user -

i have set reportsmanager page 2 accounts have access using "folder settings" security role assignment page. added 2 accounts, lets call them "user" , "reportuser". "user" content manager role. "reportuser" browser role. likewise under "site settings" set "user" system administrator , "reportsuser" system user. when launch reportsmanager page locally while logged in "user" can access site correctly expect. when try access reportsmanager while logged in "reportsuser" tells me rsaccessdenied. "user" member of administrators. "reportsuser" normal user. even though "reportsuser" set site browser , site settings config of system user had still launch ie administrator (or disable uac) reportsuser able view page without error. if turned off uac wasn't issue have leave uac on. if hit reports manager page xp acts normal. stupid uac.

.net - Set a string when a CheckBox has been checked (C#) -

i have check box in winforms, when checked set string e.g.: string checkbox = true edit: or better example: bool checkbox = true; so when method run lookup string , dependent on it's value perform a submethod... so question how set string on checkbox when clicked, have checked actions list , closest "checkchanged", won't work. why checkchanged not work? bool checkbox = false; private void checkbox1_checkedchanged(object sender, eventargs e) { if (checkbox1.checked) { checkbox = true; } } or use checkbox1.checked in subroutine.

javascript - jQuery - Compare new value with old value on form submit, across all fields (inputs, selects)? -

i reading answer question , solve problem single field, how watch fields (input, select, radio, etc...) on form? this have (i'm using delegate, form injects page dynamically): $('#preferencesbody').delegate('input[type="radio"], select', 'change', function() { var key = $(this).attr('data-key'); var value = $(this).val(); // how old value, , compare current value, if different, call saveuserpreferences? preferences.saveuserpreferences(key, value); }); thanks. $('#formid :input') will select input fields (including textarea's , buttons) on form id=formid so function this.. $('#preferencesbody').delegate(':input', 'change', function() { var key = $(this).attr('data-key'); var value = $(this).val(); preferences.saveuserpreferences(key, value); });

shell - How can I stop a background-process started from bash after the next command finished? -

how manage, morbo-server called here background-process shutdown/killed automatically if close firefox-window or if stop script in way? #!/bin/bash morbo mojolicious_lite.pl & firefox -new-window http://localhost:3000/ ok, let's solve one. #!/bin/bash morbo mojolicious_lite.pl & p=$! trap "kill $p" int # maybe want exit here too? firefox -new-window http://localhost:3000/ wait this 1 should work... when firefox exits shell wait remaining jobs (morbo) can interrupted ctrl-c - in case trap kills them. you can test visually (i.e. seeing gets executed) with bash -x run.sh assuming script called run.sh ;)

rails using has_many and belongs_to -

alright, i'm going try explain best possible: i have 2 models employer.rb class employer < activerecord::base has_many :listings end listing.rb class listing < activerecord::base belongs_to :employer end employers login through employers_controller , listings created through listings_controller i'm having trouble getting id employer table being inserted employer_id column in each individual created listing. hope makes sense. if has advice, appreciated. have feeling because i'm doing outside of employer_controller, not sure. thanks! 1) if not dealing nested resource then when render new action of listing controller, know employer (@employer) want create listing. so render hidden field employer_id using hidden_field or hidden_field_tag hidden_field_tag 'employer_id', @employer.id() 2) if dealing nested resource , route looks /employers/:employer_id/listings/new / (get) && /employers/:employer_id/listings

ios - uitableview contentInset issue -

i have strange issue contentinsent . implementing "pull & release" refresh on uitableview , works fine, in cases display "loading" status without user interaction. thought use contentinset in following way: scrollview.contentinset = uiedgeinsetsmake(60.0f, 0.0f, 0.0f, 0.0f); everything works fine 1 or 2 cells displayed - out of 3 possible on view. once number of cells grows banner @ top not displayed, @ same time manually scrolling works fine. have move scroll besides moving content? ok, found answer playing bit different values. turnes out in case described above besides setting contentinset have setup contentoffset . in case following code worked: scrollview.contentinset = uiedgeinsetsmake(60.0f, 0.0f, 0.0f, 0.0f); scrollview.contentoffset = cgpointmake(0.0f, -60.0f);

ms access - open from from newly entered record before save -

in access 2007. enter new record on form. click button has macro action open form. can make form open linked new record? understand need primary key on new form etc. if record saved can make second form open data. question when it's still new record/form need navigate directly onto linked form... please share direction on this.. if understanding question need following: add new record on form1 click button on form1 open form2 when form2 opens, contains info form1 i have process similar in database , things way. the users have form enter new records they use button click post new data table. during process, return primary key new record. final process of button click, tell open new form, , populate primary key grabbed. new form opens using pk record. my code button click in vba: private sub ok_click() dim rst dao.recordset dim rst1 dao.recordset dim sqlstr string dim rptid variant set rst = currentdb.openrecordset("tble_investigation

ios - rebuild ipa file using appcelerator -

i'm using titanium appcelerator build ipad app. have ipad provisioned , everything, when try run app on "ios device" appcelerator menu opens itunes , tries install / sync app on ipad. problem computer i"m using develop not main computer ipad, don't want sync. i'm using iphone configuration utility, , going through titanium workspace until find .app or .ipa. using testflight beta test, , import ipa , sends off few devices. problem is, updated app in appcelerator, .ipa (or .app) file never updated. there way fresh build regenerate .ipa file? there way run app computer (while it's plugged in) can still use log , info terminal using titanium? thanks! in version 1.7.x of titanium, .ipa of app in build/iphone/build/debug-iphoneos directory of titanium project - can (and are) uploading testflight. force rebuild, delete in build/iphone directory (including subdirectories) , 'run on device' build again. give fresh build , fresh ipa. if u

osx - how to set up the environment variables on mac os x -

i trying download myrna tool on mac os x. 1 of procedures on installation, "set myrna_home environment variable point extracted directory (containing myrna_emr)" so tried way echo "export myrna_home=/.../....directory/.." >> ~/.bashrc but seems not work.(when type echo myrna_home in command line, there nothing or when type printenv myrna_home not come out.) anyone knows how set env vars?? thank you, there several ways that. 1 adding variable ~/.bash_profile file. example: myrna_home=/whatever/you/want/ export myrna_home then can try if works logging in again , trying on terminal: $ echo $myrna_home it should print whatever set mryna_home on ~/.bash_profile . if want environment variable available users, can change /etc/bashrc file. prefer changing 1 users' environment.

stdclass - PHP strict standards: is this bad? -

when create standard class do: $test = null; $test->id = 1; $test->name = 'name'; however in strict-mode error. so correct way of doing is: $test = new stdclass(); $test->id = 1; $test->name = 'name'; so wondering: is big no-no do: $test = null; want? what gain conforming strict standards? make sure code keep on working in future versions? better backwards compatible? matter of best practice? else? edit typo is big no-no do: $test = null; want? yes. it's allowed because php loose, turning on strict mode gives god's-honest truth. what gain conforming strict standards? make sure code keep on working in future versions? better backwards compatible? matter of best practice? yes. something else? it's right .

php - need help with using stristr -

i need return after "i can read." understand search string , find whats in array $check how make check , return whats found after "i can read"? $string = "i can read. can count. can spell."; $check = array("i can count.", "i can't count."); $find = stristr($string, $check, true); echo $find; $find = 'i can read.'; $string = '[...]'; echo substr($string,stripos($string,$find)+strlen($find));

vb.net - Primary X axis in MS chart control wont display max value? (Resolved) -

Image
i using ms chart control .net 4 framework in visual studio 2010 using windows forms. having issue scale of primary x axis on user input text box on button click. using both primary , secondary y axes work on user input. i have checked settings each axis , have same settings. don't see why both y axes work on user input , x not. please help. the following code using: private sub button1_click(sender system.object, e system.eventargs) handles button1.click chart1.chartareas("area1").axisx.minimum = val(xprimemin.text) chart1.chartareas("area1").axisx.maximum = val(xprimemax.text) chart1.chartareas("area1").axisx.interval = val(xprimeinterval.text) chart1.chartareas("area1").axisx.labelstyle.interval = val(xprimeinterval.text) chart1.chartareas("area1").axisy.minimum = val(yprimemin.text) chart1.chartareas("area1").axisy.maximum = val(yprimemax.text) chart1.chartareas("area1")

php - How do I create and store md5 passwords in mysql -

probably newbie question but, ive been reading around , have found difficulty in understanding creation , storage of passwords. i've read md5/hash passwords best ways store them in database. however, how go creating passwords in first place? so have login page user bob, , password bob123 - how 1. bobs password database begin (hashed) 2. how retrive , confirm hashed password? thanks first off md5 isn't greatest hashing method use try sha256 or sha512 that said lets use hash('sha256') instead of md5() represent hashing part of process. when first create username , password hash raw password salt (some random characters added each password make them longer/stronger). might coming in create user form: $escapedname = mysql_real_escape_string($_post['name']); # use whatever escaping function db requires important. $escapedpw = mysql_real_escape_string($_post['password']); # generate random salt use account $salt = bin2hex(mcrypt_c