Posts

Showing posts from July, 2010

amazon s3 - EBS Volume from Ubuntu to RedHat -

i use ebs volume data on i've been working in ubuntu ami in redhat 6 ami. issue i'm having redhat says volume not have valid partition table. fdisk output unmounted volume. disk /dev/xvdk: 901.9 gb, 901875499008 bytes 255 heads, 63 sectors/track, 109646 cylinders units = cylinders of 16065 * 512 = 8225280 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disk identifier: 0x00000000 disk /dev/xvdk doesn't contain valid partition table interestingly, volume isn't 901.9 gb 300 gb.. don't know if means anything. concerned possibly erasing data in volume accident. can give me pointers formatting volume redhat without deleting contents? i checked volume works in ubuntu instance , does. i'm not able advise on partition issue such, other stating neither need nor want format it, because formatting indeed (potentially) destructive operation. best guess redhat isn't able identify file

c# - Accessing objects from within the scope of a using block through the object being used -

i'd know if possible following: using (myclass o = new myclass()) { theclassiwantmyclasstosee x = new theclassiwantmyclasstosee(); x.dostuff(); } i'd create class (myclass) , use in using block. inside block, want work objects of type (theclassiwantmyclasstosee). when using block falls out of scope, want perform actions on these (theclassiwantmyclasstosee) objects. is possible make class aware of other objects declared in scope transparently? i realise add object instances myclass object, i'd make easier developers working api i'm building. any ideas welcome. thanks. the way make myclass aware of theclassiwantmyclasstosee creating reference 1 other. there no way navigate , explore classes in scope. statement true regardless of whether scope relates using block, method block, foreach loop or other. why not have simple myclass.addrelationship(theclassiwantmyclasstosee child) method makes class a

.net - Adding TimeStamps with EF 4.3 Migrations -

i'm using code first migrations , i'm altering model add timestamp fields tables. i'm trying add timetamp fields in second migration. here sample of code looks like public class user { public int userid { get; set; } public string username { get; set; } public byte[] timestamp { get; set; } } public class usermodelconfiguration: entitytypeconfiguration<user> { public usermodelconfiguration() { property(p => p.username).isrequired().hasmaxlength(250); property(p => p.timestamp).isrowversion(); } } the generated migration looks public override void up() { addcolumn("users", "timestamp", c => c.binary(nullable: false, fixedlength: true, timestamp: true, storetype: "rowversion")); } when execute update-database command, error message says "defaults cannot created on columns of data type timestamp.

c++ - ERROR_PATH_NOT_FOUND vs ERROR_FILE_NOT_FOUND, what is the difference? -

possible duplicate: what's difference between path_not_found , name_not_found i error_file_not_found when try open file that's not there, fopen fails error_path_not_found . so difference between error_file_not_found , error_path_not_found ? in winerror.h , error_file_not_found has descriptive text "the system cannot find file specified." , error_path_not_found has descriptive text "the system cannot find path specified." this doesn't particularly clarify matters. usually, however, "file not found" refers case file cannot found , "path not found" refers case component of path (one of directory names specified) cannot found.

Perform actions after WPF DataGrid data is completely bound -

i have old windows forms application @ work converting wpf. part of this, there button which, when clicked, creates brand new datagridview , adds page, binding data sql query. data bever written database, new column added end of data checkbox on it, , when checkbox changed id row passed method along state of checkbox. in wpf, have dynamic grid creation working, , data binding. having found couldn't directly add column datagrid itself, i've added source dataset table before binding. works , whos data along checkbox each row. however, can't event fire when individual checkbox clicked. i have managed find code @ http://forums.silverlight.net/t/11547.aspx , causes row commit whenever checkbox changed, code pass id , bool value resides in editending event. updatesourcetrigger added each checkbox looping on each row in checkbox column during "loaded" event of datagrid, failing, , after internet searching seems because "loaded" doesn't guarantee dat

Google Maps API v3: SVG graphics clip / disappear when zooming -

test link: http://kwestievan.nl/reizen what i'm doing here: implemented own overlayview draw curved lines marker marker arrowheads @ end of each line svg. add div element map of width , height contain line , arrowhead. put inline svg code in div let browser draw line , arrow. if viewed in safari or chrome annoying , unexpected behavior occurs. in safari whole svg graphic disappears beyond zoom level, , in chrome arrowheads @ end of line disappear , re-appear @ random zoom levels seems. in firefox , opera behavior not happening , arrowheads visible @ zoom level. don't mind red boxes and/or displacement of arrows. that's work in progress. what going on here? svg not compatible google maps or doing wrong? the marker infowindow shadow? marker shadow set same values infowindow . duplicate variable maybe? change name of marker shadow 'path'. may have inadvertently used same identifier marker path name infowindow shadow path. i agree star. started

java - How to refresh ImageVIew on every button click with new image from the web? -

i new android , trying create first app. should have imageview along 2 buttons (back , next). when user clicks on next button, image in imageview should replaced next image (hosted on server). names of files 1.jpg, 2.jpg, 3.jpg... using following code, not working. when activity starts first image loaded properly, when click next button nothing happens (nothing in logcat also). public class slidesactivity extends activity { private imageview imageview; private int imagenumber = 1; private string plakatiurl = "http://plakati.bg/" + integer.tostring(imagenumber) + ".jpg"; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.slides); final drawable image = loadimagefromweb(plakatiurl); imageview = new imageview(getbasecontext()); imageview = (imageview) findviewbyid(r.id.imageview1); imageview.setimagedrawable(image); button nextbutton = (but

performance - Java application getting slow with passage of time -

i have pro*c application calling java module using jni. application performance decreasing when run continuously 1 or 2 day. memory usage remain in acceptable range. can please guide me how investigate performance issue? i use profiler, or add timings key phases in application , log them. need narrow down getting slower on time. it data structure o(n) growing use it.

python - Recommended error handling (try/catch or exceptions) using Pyside/Qt -

i'm developing pyside/qt application, coming scientific background. best practices try/catch errors in pyside? example, having several qcheckbox, best approach handling error if none of boxes checked? thanks edit: comments. i'm looking suggestions on best approach in code when user input being considered. example: if self.main_frame.lradiobutton.ischecked(): if self.main_frame.radiobutton2.ischecked(): print 'clicked' else: print 'no button selected!' elif self.main_frame.tradiobutton.ischecked(): if self.main_frame.radiobutton3.ischecked(): print 'clicked' else: print 'no button selected!' else: print 'no button selected, top level' so there possibilities user try further action without having selected @ least 1 of possibilities given program. should done handle "no butto

Manually populate Rails databases -

is there rails way manually populate databases? can use postgresql sql inserts wondering if there rails way well add create statemants db/seeds.rb , run rake db:seed product.create( [ { :price => 120.00, :item => "table" }, { :price => 49.99, :item => "chair" } ] )

sql - Calculating Number of Columns that have no Null value -

i want make table following | id | sibling1 | sibling2 | sibling 3 | total_siblings | ______________________________________________________________ | 1 | tom | lisa | null | 2 | ______________________________________________________________ | 2 | bart | jason | nelson | 3 | ______________________________________________________________ | 3 | george | null | null | 1 | ______________________________________________________________ | 4 | null | null | null | 0 | for sibling1, sibling2, sibling3: nvarchar(50) (can't change requirement). my concern how can calculate value total_siblings display number of siblings above, using sql? attempted use (sibling1 + sibling 2) not display result want. cheers a query trick. select id,sibling1,sibling2,sibling3 ,count(sibling1)+count(sibling2)+count(sibling3) total mytable group id a little exp

jquery - Play youtube video when clicking on a preview image, php and javascript -

i using javascript make preview image play youtube video on click event: $(document).ready(function(){ $("#feature_content").click(function(){ var iframe = "<iframe />"; var url = "http://www.youtube.com/embed/serial_number?autoplay=1&autohide=1&modestbranding=1&rel=0&hd=1"; var width = 600; var height = 335; var frameborder = 0; $(iframe, { name: 'videoframe', id: 'videoframe', src: url, width: '600', height: '335', frameborder: 0, class: 'youtube-player', type: 'text/html', allowfullscreen: true }).css({'position': 'absolute', 'top': '11px', 'left': '11px'}).appendto(this); $(this).find('img').fadeout(function() { $(this).remove();}); });

Facebook says valid URL is not a valid URL -

trying add app domain new app. thing domain http://the.me facebook doesn't consider valid url. any workaround? are including http:// in there? shouldn't have that. use the.me domain. tried , worked me. see example: http://imgur.com/g8sje

multithreading - locking global variables under the Threading module of python -

let suppose have 2 threads , single global variable in python code threading module. in code, thread-1 modifies global variable's value, whereas, thread-2 reads value of global variable , perform task depending on value. in situation, need protect access global variable lock()? in c, mutex must used under such condition. however, python gil? still case? lock() still required? assigning object value global variable atomic operation in python. other threads cannot read variable incorrectly reading while it's being assigned. gil guarantees in c implementation of python, other implementations can , make same guarantee in different ways. if global variable mutable object, list, , modifying object, depends on method use. methods on builtin objects lists atomic. i can't sure don't need lock, though, without knowing more details purpose of variable , how using it. why thread-2 need change behavior based on value, , ok if thread-1 changes value after thread-2

c++ - pointer to member function -

i trying generalize functions filterx() , filtery() in following class table function filter() . the functions filterx() , filtery() differ in function call inside procedure. while filterx() calls getx() , filtery() calls gety() . #include <iostream> #include <string> #include <vector> using namespace std; class row { public: void add(string x, string y, int val); string getx() const { return d_x; } string gety() const { return d_y; } int getval() const { return d_val; } private: string d_x; string d_y; int d_val; }; class table { public: void add(string x, string y, int val); vector<int> filterx(string s); vector<int> filtery(string s); private: vector<row> d_table; }; //--------------------class row---------------------------- void row::add(string x, string y, int val) { d_x = x; d_y = y; d_val =

printf - C: strncpy more characters than allocated then printing... unexpected output? -

in sample code given professor: #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char alpha[] = "abcdefghijklmnopqrstuvwxyz"; printf( "%s\n", alpha ); printf( "%c\n", alpha[8] ); alpha[8] = 'z'; /* segmentation fault if alpha declared statically! */ printf( "%d\n", sizeof( alpha ) ); printf( "%d\n", strlen( alpha ) ); char x[10]; strncpy( x, alpha, 26 ); /* strncpy() not copy or append '\0' */ printf( "%s\n", x ); return exit_success; } when first compiling , running, program segfaults due to, see in few minutes of googling, gcc protection mechanism against buffer overflows (triggered printf( "%s\n", x ); in x had been filled 26 bytes alpha). believe understand. however, when disabling protection mechanism gcc -fno-stack-protector, output see is: abcdefghijklmnopqrstuvwxyz 27 26 abcdefghzjklmnopqrstuvwxyzklmnopqrstuvwxy

Flash memory management and Actionscript -

there many discussions problem, want pay attention on situations imho seems not clear: yes general rules are: remove chachedasbitmap stop movieclip if playing remove events delete references etc. but let's look: first example: have nested sprite (ex: mainsprite), contains other sprites dynamic textfields in (and chached bitmaps), textfileds , movieclips event listeners on (with weak reference). when need remove sprite need first remove it's nested content via loops or just removechild(mainsprite); mainsprite=null; is enough? second example: have sprite in i'm loading bitmap , manipulating bitmapdata, later i'm replacing content of sprite bitmap, allocated memory older bitmap automatically erases , overwritten or still exists? third example: have "graphics template" movieclip (in library export actionscript property set on it) i'm adding on stage , filling dynamic data (and adding event listeners), let's it's 1 scene of app, on sc

sql - How to sum the total of same group and same month? -

i have view in following format: channel | themonth | thecount | ------------------------------- chaa | 3 | 5 | ------------------------------- chaa | 2 | 2 | ------------------------------- chaa | 1 | 4 | ------------------------------- chab | 2 | 1 | ------------------------------- i sum thecount having same month current month (assuming current month march) previous month , chaa (channel) of 3 (themonth) have thecount value of 7 (5+2). expected output shown this: channel | themonth | thecount | ------------------------------- chaa | 3 | 7 | --> note: row has been updated. ------------------------------- chaa | 2 | 2 | --> retain value ------------------------------- chaa | 1 | 4 | --> retain value ------------------------------- chab | 2 | 1 | --> retain value ------------------------------- i have been using sql case fix

regex - JavaScript Regular Expression Match Return the Input as the First 2 Indexies -

i getting started regex in javascript (and in general) , have come across oddity can't seem find explanation using google. without getting detail, using following expression: /(^sw:\s?(-?\d{1,3}.\d{1,6})\sne:\s?(-?\d{1,3}.\d{1,6})$)/i which matching user input like: sw: -27.990344 ne: 150.234562 with following console.log output: ["sw: -27.345455 ne: 180.234567", "sw: -27.345455 ne: 180.234567", "-27.345455", "180.234567"] 0 "sw: -27.345455 ne: 180.234567" 1 "sw: -27.345455 ne: 180.234567" 2 "-27.345455" 3 "180.234567" index 0 input "sw: -27.345455 ne: 180.234567" my question is: why index 0 , 1 returning user supplied input , actual data return index 2 , 3? i assume relative expression, don't know enough sure not normal behaviour. any appreciated. index 0 complete match, capturing groups starting @ index 1 . the capturing groups numbered opening

jquery - Rails 3.0.12 remote form failing with AJAX update -

using ruby 1.8.7-p358, rails 3.0.12, gem responder, gem simple-form; jquery_ujs.js i have form :remote=>true , uploading file = simple_form_for :resume, :url => {:controller => :resumes, action => :upload_resume, :id => @job_seeker.id}, :html => { :multipart => true }, :remote => true |f| etc the resume controller method looks this: respond_to :html, :xml, :json, :js def upload_resume r = @job_seeker.resumes.new r.name = params[:resume][:name] r.source_path = params[:resume][:content].original_filename r.doc_type = params[:resume][:content].content_type r.content = params[:resume][:content].tempfile.read r.size = r.content.size r.source_ip = request.remote_ip r.save ,end which does, not respond upload_resume.js.erb, looks this: $('#resume_list').html("<%= escape_javascript(render(:partial => 'resumes/resumes' ))%>"); is there data-remote & file uploads ca

jquery - Return to iFrame instead of parent on closing Fancybox -

i have iframe that's rendered inside fancybox. within iframe have link calls fancybox on parent page suggested here . working desired. on closing fancybox called within iframe using fancybox on parent page, return parent page. however, behavior modified return iframe instead of parent page. the fancybox have in iframe: jquery('.container').on('click', 'a.fancybox-large', function(e){ e.preventdefault(); parent.jquery.fancybox({ href : this.href, padding : 0, closebtn : true, fittoview : true, helpers : { overlay: {opacity: 1, css: {'background-color': '#000000'}} } }); }); any suggestion? regards, john you can select element inside of iframe want focus on using .focus() method. so having input field inside iframe instance <input type="text" class="field" /> edited: add full script. add script a

jsp - List<Foo> as form backing object using spring 3 mvc, correct syntax? -

i want this, foo class 1 string field name, , getter/setter : <form:form id="frmfoo" modelattribute="foos"> <c:foreach items="${foos}" var="foo"> <form:input path="${foo.name}" type="text"/> and submit complete list of foos updated names ? controller sig looks : @requestmapping(value = "/foo", method = requestmethod.post) public string getsendemail(list<foo> foos, model model) {} maybe answersyour question: controller : @controller("/") public class foocontroller{ //returns modelattribute foolistwrapper view fooform @requestmapping(value = "/foo", method = requestmethod.get) public string getfooform(model model) { foolistwrapper foolistwrapper = new foolistwrapper(); foolistwrapper.add(new foo()); foolistwrapper.add(new foo()); //add many foo need model.addattribute("foolistwrapper&qu

php - trying insert a checkbox in a form of terms and condition -

i trying input check-box terms , conditions in form, when registered form without ticking box registration went through , (which not suppose be). please have look. <?php echo "<h2>register</h2>"; $submit = $_post['register']; //form data $fullname = mysql_real_escape_string(htmlentities(strip_tags($_post['fullname']))); $username = strtolower(mysql_real_escape_string(htmlentities(strip_tags($_post['username'])))); $password = mysql_real_escape_string(htmlentities(strip_tags($_post['password']))); $repeatpassword = mysql_real_escape_string(htmlentities(strip_tags($_post['repeatpassword']))); $email = mysql_real_escape_string(htmlentities(strip_tags($_post['email']))); $houseno = mysql_real_escape_string(htmlentities(strip_tags($_post['houseno']))); $addressa = mysql_real_escape_string(htmlentities(strip_tags($_post['addressa']))); $addressb = mysql_real_escape_string(htmlentities(strip_tags($

c++ - Should I worry about Big Endianness or is it only a trivial aspect? -

are there many computers use big endian? tested on 5 different computers, each purchased in different years, , different models. each use little endian. big endian still used days or older processors such motorola 6800? edit: thank treya, intel.com/design/intarch/papers/endian.pdf nice , handy article. covers every answers bellow, , expands upon them. there's many processors in use today big endian, or allows option switch endian mode between big , little endian, (e.g. sparc, powerpc, arm, itanium..). it depends on mean "care endian". don't need care endianess if program data need. endian matters when need communicate outside world, such read/write file, or send data on network , reading/writing integers larger 1 byte directly to/from memory. when need deal external data, need know format. part of format e.g. know how integer encoded in data. if format specifies first byte of 4 byte integer significant byte of said integer, read byte , place @ si

php - echo a string, replacing nl with br and horizontal tabs with some html char -

for debugging want echo or print mysql html replacements nl , horizontal tabs. $sql=" select * `mytable`;"; i can echo nl2br($sql); in order replace \n <br /> . gives me screen output: select * `mytable`; now want swap horizontal tabs &nbsp; in order indent them on screen. what use instead of &nbsp; , i've never liked it? thanks you use html <pre> tag. echo '<pre>' . $sql . '</pre>';

hadoop - how to run a mapreduce job on amazon's elastic mapreduce (emr) cluster from windows? -

i'm trying learn how run java map/reduce (m/r) job on amazon's emr. documentation following here http://aws.amazon.com/articles/3938 . on windows 7 computer. when try run command, shown information. ./elasticmapreduce-client.rb runjobflow streaming_jobflow.json of course, since on windows machine, type in command. not sure why, particular command, there not windows version (all commands shown in pairs, 1 *nix , 1 windows). ruby elastic-mapreduce runjobflow my_job.json my question how submit/run job windows amazon's emr using command line interface (on windows)? i've tried searching online, taken wild places. appreciated. thanks. hmmm. i'm not sure how old example runjobflow is... i'd ignore it. are able run? localhost$ elastic-mapreduce --describe once can should play directly on cluster shake out exact steps need do... it's worth doing don't have start/stop cluster bazillion times. localhost$ elastic-mapreduce --create

turboc++ - How to include and use turbo vision library in Turbo C++ 3 -

Image
i ask question people have experience in coding using turbo c++ 3.0. i'm trying make text user interface console application , see turbo c++ 3 has option link turbo vision in program. using this: options -> linker -> libraries -> check turbo vision. know question how start using in program? tried include no avail, or not include header also. note: if know of other way develop c++/c console apps text user interface, please feel free answer to. thanks! edit: please not comment not use turbo c++ because it's old. i'm trying create console app text user interface our project. :) turbo vision out dated , no more maintained. however, if have stronger reasons use 'the doom' game era tui tool kit, go ahead else suggest using ncurses portable tui toolkit, as note, turbo vision library has potentially unsafe pointers. not safe library use in era , , dos 'only' thing, there ports posix based environment , still doubt saf

php - kohana orm top user -

i have 2 tables the users , comments the comments have many 1 relationship users trying think of way using orm top users based on amount of comments any suggestions? your query should this: select users.username, count(comments.id) total users inner join comments on users.id = comments.user_id group users.username order count(comments.id) desc translated orm: orm::factory('user') ->select('user.username', array('count("comments.id")', 'total')) ->join('comments', 'inner') ->on('user.id', '=', 'comments.user_id') ->group_by('user.username') ->order_by('total', 'desc') ->find_all();

php - check if a string is a URL -

this question has answer here: best way check if url valid 8 answers i've seen many questions wasn't able understand how works want more simple case. if have text, whatever is, i'd check if url or not. $text = "something.com"; //this url if (!isurl($text)){ echo "no not url"; exit; // die }else{ echo "yes url"; // else codes goes } function isurl($url){ // ??? } is there other way rather checking javascript in case js blocked? http://www.php.net/manual/en/function.preg-match.php#93824 <?php $regex = "((https?|ftp)\:\/\/)?"; // scheme $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // user , pass $regex .= "([a-z0-9-.]*)\.([a-z]{2,3})"; // host or ip $regex .= "(\:[0-9]{2,5})?"; // port $reg

model view controller - maven with spring mvc -

anybody have web project in maven spring? don't know why can't project working, therefore need see working project understand it. project simple login/logout in maven using spring mvc. tanks i http 404 when run project on server , don't know can wrong. maybe wrong som of xml-files: web.xml <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns /persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="bokingguard" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <!-- entities --> <properties> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.driver"/>

objective c - I can't understand UIScrollView behavior -

i've read lot of documentation still don't understand how uiscrollview works. i have example use uinavigationviewcontroller status bar (little top bar wifi, battery, etc., icons) , navigation bar (with "back" button). as first subview of uinavigatioviewcontroller's main view have uiscrollview. inside have created several subviews make it's contents size 500 points . in " viewdidload " method set scroll view's " contentsize " equals 500. doens't scroll down show last subview. i read should add points " contentinset " because of "bars". don't know why. isn't scroll view inside main view correctly framed? why need take "bars" account? anyway, read should 64 points (44 navigation bar + 20 status bar). doesn't work. the "magic" number (at least me) 84 points . must add quantity content size (584) or use as: self.scrollview.contentinset=uiedgeinsetsmake(0.0,0.0,

Receiving POST with Rack ruby server -

i have simple ruby server : app = proc.new |env| puts 'am receiving ? ' req = rack::request.new(env).params puts "if yes parameters ? : #{req.inspect}" end rack::handler::thin.run(app, :port => 4001, :threaded => true) how supposed receive post request parameters , i'm sending json object using post can see nothing i'm receiving nothing when send post localhost:4001 . that's because not returning response. response empty won't see anything. can test through curl: $ curl -f 'foo=bar' localhost:4001 curl: (52) empty reply server response within app: am receiving ? if yes parameters ? : {"foo"=>"bar"} try returning something: app = proc.new |env| puts 'am receiving ? ' req = rack::request.new(env).params puts "if yes parameters ? : #{req.inspect}" [200, { 'content-type' => 'text/plain' }, ['some body']] end

In hibernate when does Query fire and return ResultSet -

can u please tell in hibernate when query fire , return resultset. tell below example session session =sessionfactory.opensession(); criteria criteria = session.createcriteria(client.class); criteria.add(restrictions.like("clientname","%"+search+"%")); criteria.setmaxresults(10); list list = criteria.list(); the query fired when encounters criteria.list() in code when using criteria , returns list of objects of class specified in session.createcriteria('') . here client in case. you can find more options @ criteria documentation

algorithm - Swamp/dead-end pruning in non-grid maps -

are there existing algorithms finding , avoiding problematic areas ( swamps , dead-ends ) in pathfinding when using non-grid maps? there plenty available grids either avoid these areas or pseudo-avoid these areas way of jump point recursion , etc., have yet find useful quadtrees, navigational meshes, or other non-uniform maps. dead-end detection , swamps not grid specific. they're evaluated on grid maps.

AddType x-mapp-php5 .php to my .htaccess file -

hi have been told hosting provider add .htaccess file enable php5 addtype x-mapp-php5 .php my question is, put inside .htaccess file? @ moment looks this: ## # @version $id: htaccess.txt 14401 2010-01-26 14:10:00z louis $ # @package joomla # @copyright copyright (c) 2005 - 2010 open source matters. rights reserved. # @license http://www.gnu.org/copyleft/gpl.html gnu/gpl # joomla! free software ## ##################################################### # read if choose use file # # line below section: 'options +followsymlinks' may cause problems # server configurations. required use of mod_rewrite, may # set server administrator in way dissallows changing in # .htaccess file. if using causes server error out, comment out (add # # beginning of line), reload site in browser , test sef url's. if work, # has been set server administrator , not need set here. # ##################################################### ## can commented out if causes errors, see notes

delphi - sending a record type as parameter using dwscript -

please consider record: type tstudent = record name:string; age: integer; class:string; end; i have class tschool has following function: function addstudent(lstudent:tstudent):boolean; i want use class ( tschool ) in dwsunit, , function too, can't figure out how send record type parameter. how far i've reached: procedure tform1.dwsunitclassestschoolmethodsaddstudenteval(info: tprograminfo; extobject: tobject); begin info.resultasboolean:=(extobject tschool).addstudent(info.vars['lstudent'].value); end; but not working, keeps on giving me error incompatible types. i have defined in dwsunit record tschool, didn't work either. appreciated. i don't have delphi 2010 @ disposal now, have delphi xe(it should work in d2010 also), here's works me, can of course modify fit needs: program project1; {$apptype console} uses sysutils ,windows ,dwscomp ,dwscompiler ,dwsexprs ,dwscoreexprs ,dwsrttiexpose

MATLAB help for having the vertices corresponding to area -

i have program in matlab draws bounding box. displays area of every blob.i have arranged areas in descending order. want have verticesx , vertixesy corresponding area have arranged in descending order use further. can u please tell how have it? clear all; close all; clc i=imread('image.jpg'); ...... bw2=im2bw(j(:,:,2),l); subplot(2,3,4); imshow(bw2); % label each blob can make measurements of [labeledimage numberofblobs] = bwlabel(bw2, 8); % blob properties. blobmeasurements = regionprops(labeledimage, 'boundingbox','area'); allblobareas = [blobmeasurements.area]; % loop through blobs, putting bounding box. hold on; k = 1 : numberofblobs boundingbox = blobmeasurements(k).boundingbox; % box. x1 = boundingbox(1); y1 = boundingbox(2); x2 = x1 + boundingbox(3) - 1; y2 = y1 + boundingbox(4) - 1; verticesx = [x1 x2 x2 x1 x1]; verticesy = [y1 y1 y2 y2 y1]; % calculate width/height ratio. aspectratio(k) = boundingbox(3) / boundingbox(4); f

android - How control the "accept" or "cancel" buttons when installing an APK programmatically? -

i have function auto-updating app (it's non-market app) , want control "ok" or "cancel" button when decide accept update or decline update. here code (the code works doesn't control buttons) public void update(string apkurl,string versio){ try { url url = new url(apkurl); httpurlconnection c = (httpurlconnection) url.openconnection(); c.setrequestmethod("get"); c.setdooutput(true); c.connect(); string path = environment.getexternalstoragedirectory() + "/download/"; file file = new file(path); file.mkdirs(); file outputfile = new file(file, "app.apk"); outputfile.delete(); fileoutputstream fos = new fileoutputstream(outputfile); inputstream = c.getinputstream(); byte[] buffer = new byte[1024]; int len1 = 0; while ((len1 = is.read(buffer)) != -1) { fos.wr

Sharepoint 2010 - Object Model - Download DocumentSet Programmatically -

a code snippet of how can download documentset programmatically using sharepoint object model help. what trying - given sharepoint site, log in user default credentials - document library files hosted - pull files down on local machine what have done far, using microsoft.sharepoint.client; clientcontext cc = new clientcontext(configurationmanager.appsettings["site"]); cc.credentials = new networkcredential(username, pwd, domain); web site = cc.web; listcollection colllist = site.lists; var olist = colllist.getbytitle("document set test"); // document set cc.load(olist); cc.executequery(); // views var views = olist.views; cc.load(views); cc.executequery(); // documents camlquery camlquery = new camlquery(); camlquery.viewxml = @"<query> <

ruby on rails - You have a nil object when you didn't expect it! You might have expected an instance of Array -

i writing below def search cuisine=settings.allcuisines begin @orgs = getsearch(params[:lat], params[:lon],params[:zip], params[:dist], cuisine,params[:num_results]) respond_to |format| format.html {render action: "index"} format.json { render json: @orgs } end messg="success" code="0" results={:message=>messg,:code=>code} resul=results.new(results) resul.save rescue exception => exc messg=exc.message code="1" results={:message=>messg,:code=>code} resul=results.new(results) resul.save respond_to |format| format.html {render action: "index"} format.json { render json: @orgs } end end i getting error: you have nil object when didn't expect it! might have expected instance of array. error occurred while evaluating nil.each why happening? you calling @orgs.each in view , @orgs nil. can try nesting iterator in an: -

Android overriding onClick(View v) - is there a good solution to use for all buttons in an application -

as know can override few methods each type of view have created. not doing xml layout code because lot of stuff changes form @ runtime , there things created dynamically programmatic solution best route me here. so gist of issue lets have 50 buttons in android app. these buttons potentially on 1 activity more span out across multiple screens(activites). i have created button class called custombutton overrides onclick(view view) method. if of buttons supposed action(lets part of linearlayout) , part of relative layout , in each relative layout want information relative layout button resides in(perhaps information textviews in same relative layout, etc etc). one solution of course id of each button , switch(case) or , depending on id of button returned can something. problem is have 50 buttons. if had 200? should have 200 case checks in switch statement figure out action need take? so trying figure out information available me not aware of use when override onclick. @ov

Log parser solutions python/perl vs Java -

i know perl , python tested solution kind of log parsing , data mining - anybody have experience dealing syslog parsing java ? i have create java demon anyway load parsed output db .. thinking why not going way - python might useful when running on different environment. i started writing python scripts, wrote java gc log parser print timestamp when gc happened , counts etc, , found python real easy in writing it. kind of fields interested while parsing syslogs? think if know looking in logs(patterns etc) becomes easy write script you. ankit.

HTML5 Video with Video.js and AJAX -

i have <div> containing <video> element, , <ul> . clicking on element in <ul> causes ajax call update contents of <div> . on first attempt, first video load correctly, clicking on different link load poster, not controls. after googling, found solution that, leaves me following ajax call: $.ajax({ // each video has own unique id url: "/video?id=' + id, success: function (data) { $('#containing_div').html(data); // necessary re-load video player controls _v_('video_' + id, { "controls": true, "autoplay": false, "preload": "auto" }); } }); adding initialization call _v_ seemed matters somewhat: when switch videos, "play" control appears expected, , can play video. however, once do, when switch different video, controls gone again. furthermore, there weird random errors: if change videos few times, controls disappear no apparent

hibernate - Matching hasMany children with Grails dynamic finders -

in grails, i'm attempting find instance of domain class has exact entries in one-to-many relationship. consider example: class author { string name list<book> books static hasmany = [books:book] } class book { string title static belongsto = author } my database appears such: author book ------------------------- ------------------------ | id | name | | id | title | |----|------------------| ------------------------ | 1 | john steinbeck | | 1 | grapes of wrath | | 2 | michael crichton | | 2 | east of eden | ------------------------- | 3 | timeline | | 4 | jurassic park | ------------------------ author_book ---------------------------------------- | author_books_id | book_id | book_idx | ---------------------------------------- | 1 | 1 | 0 | // john steinbeck - grapes of wrath | 1

How to create a dynamic select list using Simple Form and Awesome Nested Set in Rails 3.1? -

could please explain how create dynamically generated pull-down select shows name labels web visitor , writes corresponding id database? concept seems basic must obvious else @ wit's end trying find way make work and/or code example learning how this. suggestions frustrated newbie? i have simple category model using awesome nested list track 200 categories. these table fields: t.string :name t.integer :parent_id t.integer :lft t.integer :rgt this category.rb model: class category < activerecord::base acts_as_nested_set attr_accessible :name, :parent_id end this simple form view/categories/_form.html.erb <%= simple_form_for(@category) |f| %> <%= f.error_notification %> <div class="form-inputs"> <%= f.input :name, :label => 'category name' %> <%= f.select :parent_id, :label => 'parent category', :value_method => { |r| [r.name, r.id, { :class => r.category.id }]}, :include_blank =&g

debugging - iOS Root Controller At Launch Error -

i'm recieving following error code when trying test run app. application windows expected have root view controller @ end of application launch the app running fine bare shell app (e.g. no functionality implemented) once added functions viewcontroller.m started generating error. viewcontroller.m contains. // // batttimeviewcontroller.m // batttime // // created james krawczyk on 09/03/2012. // copyright (c) 2012 james krawczyk. rights reserved. // #import "batttimeviewcontroller.h" @interface batttimeviewcontroller () @end @implementation batttimeviewcontroller @synthesize resdisplay; - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. } - (void)viewdidunload { [self setresdisplay:nil]; [super viewdidunload]; // release retained subviews of main view. } - (void)batterystatus { // current date time datetrack = [nsdate date]; // instantiate nsdateformatter nsdateforma

From io.Reader to string in Go -

i have io.readcloser object (from http.response object). what's efficient way convert entire stream string object? the short answer it not efficient because converting string requires doing complete copy of byte array. here proper (non-efficient) way want: buf := new(bytes.buffer) buf.readfrom(yourreader) s := buf.string() // complete copy of bytes in buffer. this copy done protection mechanism. strings immutable. if convert []byte string, change contents of string. however, go allows disable type safety mechanisms using unsafe package. use unsafe package @ own risk. name alone enough warning. here how using unsafe: buf := new(bytes.buffer) buf.readfrom(yourreader) b := buf.bytes() s := *(*string)(unsafe.pointer(&b)) there go, have efficiently converted byte array string. really, trick type system calling string. there couple caveats method: there no guarantees work in go compilers. while works plan-9 gc compiler, relies on "implementation deta

c++ - FindResource() fails to find data even though data is in exe -

i have been on one, , plumb stuck. have been building project , want embed text file resource executable. understand basics of how "should" work, reason not. so, let me start have far , maybe problem can pinned down. there 2 functions here, first, enumresnameproc attempt debug problem self, second, loadfileinresource function trying working. little messy because in middle of building when starting having problems. the exact issue is, findresourceexa returning null, , lost exact reason. know error, , return code 1813, "resource not found". i have other resources in project, have version node, mainifest node, (of which, not directly reading) have icon node (that applying window system menu icon) , bitmap (that loading texture.). these have defined types, example, type bitmap 12. now, attempting load text file, 'user defined' type of 10. know data inside executable, because if open in text editor... (yes, tried that) present, so, being includ