Posts

Showing posts from April, 2011

sql - Calculate percentage -

hi code gives me employee salaries , manager salaries. select e.emp_fname manager, e.emp_salary, d.dept_no, a.emp_fname employee, a.emp_salary employee e, employee a, department d e.emp_nin = a.emp_manager , a.emp_manager = d.emp_manager; ![alt text][1] how can show employees have salary within 10% of manager salary? assuming want allow employees earning more managers (you know happen, in different, better world) include in clause: and a.salary between (e.salary * 0.9) , (e.salary * 1.1) edit this uses simple mathematics. 0.9 = 90% , 1.1 = 110%; line restricts resultset employee records salary +/- 10% of manager's salary. if employees can never earn more manager need simpler greater test... and a.salary >= (e.salary * 0.9)

can QuickGraph support these requirements? (includes database persistence support) -

would quickgraph able me out requirements below? (a) want model graph of nodes , directional relationships between nodes - example model web pages/files linked under url, or modeling infrastructure , dependencies between hardware/software. library include methods such as * node.getdirectparents() //i.e. there more 1 direct parent node * node.getrootparents() //i.e. traverse tree top root parent(s) given node * node.getdirectchildren() * node.getallchildren() (b) have persist data database - should support sql server , ideally sqlite well. if support these requirement i'd love hear: any pointers parts of quickgraph dig into? what best concept re it's usage in terms of how use database persistence - simpler design assume every search/method works directly on database, or quickgraph support smarts able work in memory , "save" database changes @ appropriate point in time (e.g. ado.net datatable etc) thanks in advance greg, a. yes, quickgr...

http - PHP page load seems to be requesting itself and misinterpreting the result -

i'm working on messy php page developer , analyzing resource view in webkit developer tools , noticed page (index.php) makes http requests , interprets results image despite being sent text/html header. because of throws warning: resource interpreted image transferred mime type text/html. looking @ time graph call comes after <head> because has requested images body. there 2 'bad' requests. can explain might happening and/or suggest how fix this? these related php includes? not sure how webkit making requests, time i've seen kind of behavior (a script calling image) when: image urls supposed generated , not - leaving image source '' or current url. a mod_rewrite 'greedy', , redirects image requests - including browser's favicon request - bootstrap (or similar) script. does webkit request favicon? later request in timeline.

class - Define "Indirect subclass" in Android -

looking @ various pages in android docs , of them list "known indirect subclasses". mean? for interface, it's list of classes implement interface. for class, it's list of classes derive class, indirectly (ie., class in list derived class derives class being documented directly or indirectly). so android.view.viewgroup derives directly android.view.view , indirectly java.lang.object : java.lang.object android.view.view android.view.viewgroup since interfaces can implemented, not directly derived from, class implements interface considered 'indirectly derived' interface.

java - What is an effective method of traversing a 2d Array vertically to programatically find an "empty" set? -

first off, isn't homework ;). i'm trying create wordsearch game scratch , have hit barrier need guidance on. i'm using 2d array of chars grid of wordsearch. i'm quite comfortable placing words in these arrays horizontally, i'm stuck ideas on how vertically. this have far, should able copy/paste , run it import java.util.arraylist; import java.util.list; public class wordgame { private static list<string> words = new arraylist<string>(); private static int longestwordlength = 0; private static int padsize = 4; private static char[][] grid = null; public static void main(string[] args) { initialisewords(); workoutlongestword(); setupgrid(); printit(); } private static void printit() { (int = 0; < grid.length; i++) { (int j = 0; j < grid.length; j++) { system.out.print(grid[i][j]); } system.ou...

javascript - timing/waiting in jQuery -

i writting banner rotator , want cycle among few pictures after few seconds. jquery has waiting , calling callback? can see .delay method, doesn't seem have callback function. or maybe should use browser-dependant function? or maybe javascript contains function need? new javascript :-| . you can use native javascript: settimeout(function(){ /* stuff */ }, 1000); you can have fun mixins: var timeoutcallback = function() { this.foo = 5; } var scheduletimeout = function(obj, delay) { settimeout(function(){ timeoutcallback.call(obj); }, delay); } var myobj = { foo: 1, bar: 2 } scheduletimeout(myobj, 1000); // myobj.foo becomes 5 after 1000ms delay

python - aapt: Do not skip (null) files when packaging -

i developing android application uses number of python scripts in res/raw deployed via sl4a , included in app's apk. scripts make use of python packages, directories contain number of 0byte sized __init__.py files necessary python recognize directories packages. problem aapt skips files during packaging, preventing scripts working on device/emulator, modules not found interpreter: [aapt] creating full resource package... [null] (skipping (null) file '/home/user/app/res/raw/pypackage/__init__.py') is there way tell aapt include files nevertheless, or have pad files manually make them >0kb sized? looked @ aapt command-line options didn't find anything. if problem can add comment ' # ' inside __init__.py files. if find more problems directory structure can use tar or zip , expand after apk installation.

Converting a rails 2 count calculation to rails 3 -

i attempting convert rails 2 count calculation rails 3 i'm having issues answers.count('user_agents.browser', :joins => :user_agent, :group => 'user_agents.browser', :order => 'count(user_agents.browser) desc') that rails 2 , gives me error of pgerror: error: column answers.user_agents.browser not exist line 1: select count("answers"."user_agents.browser") "count_... ^ : select count("answers"."user_agents.browser") "count_user_agents_browser", user_agents.browser user_agents_browser "answers" inner join "user_agents" on "user_agents"."id" = "answers"."user_agent_id" (answers.survey_id = 18) group user_agents.browser order count(user_agents.browser) desc i've tried converting myself, close have gotten answers.select('count(user_agents.browser)').joins(:user_agent)....

asp.net mvc - dotnetopenid attribute extensions just not working for me! -

so here's code on request:- iauthenticationrequest req = openid.createrequest(request.form["openid_identifier"]); //add extention requests here req.addextension(new claimsrequest { email = demandlevel.request, birthdate = demandlevel.request, country = demandlevel.request, fullname = demandlevel.request, gender = demandlevel.request, language = demandlevel.request, nickname = demandlevel.request, postalcode = demandlevel.request, timezone = demandlevel.request } ); //get request openid return req.redirectingresponse.asactionresult(); and here's on pickup:- //get attributes site ...

iis - DCOM problems building a VB6 app in CruiseControl.net -

i can build vb6 application relies upon several dcom settings on build machine, no problem. however. second time try run same build process, fails, dcom and/or iis have locks on output files i'm trynig rebuild. currently, if log onto build machine , reset iis (using iisreset or otherwise), releases locks on output files, allowing build complete successfully. obviously, don't want have log onto build machine , don't want have keep resetting iis - there way around this? thanks. i think i've found solution - not pretty, it's 1 way around it. basically, prior build, calling out small application kill running processes going built during build. once they're killed, component no longer running in memory , no longer holding lock files. as say, there's cleaner way of doing , keep looking, now, should suffice.

Styling progress dialog in android -

spent half day understand how change styles progress dialog , not able so. very simple thing wanted start with, change spinner color in progress dialog other color other white ! , got stuck here itself. in android sdk , using image , applying animation , have scratch change color of spinner ? any examples progress dialog has been modified helpful , have seen in documentation , google search results upto 4-6 pages :) , still not able it. any interesting way show progress dialog other default 1 ? i appreciate if can provide blog on applying themes , styles , explains in detail. some code using, dialog1 = new progressdialog(this); dialog1 = progressdialog.show(this, "", "loading. please wait...", true); trying lot dialog1, not getting desired result. thank you final progressdialog progressbar = progressdialog.show( searchscreen.this, "", progressbarsearching); progressbar.s...

How to create an Object in a specific Entity Group with JPA? (Google AppEngine Java) -

i want use transactions in gae-j jpa. without jpa should be: entity child= new entity("child", "parentkey"); but how jpa? @entity public class parent{ @id @generatedvalue(strategy = generationtype.identity) private key id; private string text; } @entity public class child{ @id @generatedvalue(strategy = generationtype.identity) private key id; private parent parent; private string text; } trying... parent parent = new parent(); em.persist(parent); em.refresh(parent); child child = new child(); child.setparent(parent); em.persist(child); this doesn't work: org.datanucleus.store.appengine.datastorerelationfieldmanager$childwithoutparentexception: detected attempt establish child(130007) parent of parent(132001) entity identified child(132001) has been persisted without parent. parent cannot established or changed once object has been persisted. that sounds bit front... blockhead? or there easy way? tha...

objective c - How to find absolute NSView frame position in window -

i have complicated hierarchy of nsviews, how can find frame of view in window or able check if point in window in views frame? i tried this nspoint windoworigin = [[window contentview] convertpoint:nsmakepoint(0,0) fromview:myview]; send convertrect:toview: second argument set nil: nsrect viewframeinwindowcoords = [myview convertrect: [myview bounds] toview: nil]; on second thought, if need perform hit testing, might want opposite: nsview *viewunderpoint = [[window contentview] hittest: locationinwindow];

iis 7 - IIS redirect url for virtual directory -

how can set redirect url virtual directory in iis 7.0? have installed latest url rewrite module 2.x. i can explain problem example: i have website on iis 7.0 server, www.mysite.com. decided create virtual directory "sales" under site pointing website root directory. need create redirect url vdir. vdir pointing same virtual root directory site root. the big idea can go www.mysite/sales , automatically redirect www.mysite.com?productid=200. i tried redirect rewrite url vdir(not website), error message: cannot add duplicate collection entry of type 'rule' unique key attribute 'name' set "test". this happens when pointing virtual vdir , try add rule. i can add rules website level, rules don't work. mean url "www.mysite/sales" gives me following error. know key unique. checked web.config. this kind of feature easy use in iis 6.0, point @ vdir mouse , set properties-->a redirect url. please 1 explain right way in ii...

code formatting - How to fix broken automatic indentation in vim -

i trying use vim 7.2 (on windows xp) automatically indent , format vhdl , matlab code. trying use "gg=g" command. not work properly. code not indented @ all. to give example, had following source code, indented: % function based on code_g_generator() function function [v_code] = get_code(n_code_number) % there no need clear persistent variables in function mlock %% initialize internal variables persistent n_fifo_top; if isempty(n_fifo_top) n_fifo_top = 1; end n_memory_size = 4; if n_code_number > 4 c_saved_code_fifo = {-1*ones(1, n_memory_size)}; end if use "gg=g" command get: % function based on code_g_generator() function function [v_code] = get_code(n_code_number) % there no need clear persistent variables in function mlock %% initialize internal variables persistent n_fifo_top; if isempty(n_fifo_top) n_fifo_top = 1; end n_memory_size = 4; if n_code_number > 4 c_saved_code_fifo = {-1*ones(1, n_memory_size)...

c# - How to iterate through two IEnumerables simultaneously? -

i have enumerables ienumerable<a> list1 , ienumerable<b> list2 , iterate through them simultaneously like: foreach((a, b) in (list1, list2)) { // use , b } if not contain same number of elements, exception should thrown. what best way this? here's implementation of operation, typically called zip: using system; using system.collections.generic; namespace so2721939 { public sealed class zipentry<t1, t2> { public zipentry(int index, t1 value1, t2 value2) { index = index; value1 = value1; value2 = value2; } public int index { get; private set; } public t1 value1 { get; private set; } public t2 value2 { get; private set; } } public static class enumerableextensions { public static ienumerable<zipentry<t1, t2>> zip<t1, t2>( ienumerable<t1> collection1, ienumerable<t2> collection2) {...

.net - How to determine Threading Model of given COM library? -

i have com library should use in asp.net mvc application. unsure thread apartment model. how can determine it? determine component's clsid registry using key: hkey_classes_root\{component's progid}\clsid then lookup threadingmodel using registry key hkey_classes_root\clsid\{component's clsid}\inprocserver32\threadingmodel

PHP AJAX and mySQL not returning data? -

i have following block of php: $word = mysql_real_escape_string(trim($_get['word'])); $firstletter = substr('$word', 0, 1); $query = "select * `dictionary` word '%$firstletter'"; $result = mysql_query($query) or die(mysql_error().": ".$query); $row = mysql_fetch_assoc($result); // send word ajax request $i = 0; $fullload = ''; while ($i < mysql_numrows($result)) { $fullload = $fullload . '|' . $row['word']; $i++; } echo $fullload; now, ajax call: $.ajax({ type: "get", url: "word-list.php", data: "word="+ theword, success: function(data){ //data retrieved console.log(data); } }); now, lets assume missing word variable apple - $word = 'apple'; but when console.log() outputs - zero, nothing, nada,...

python - How to efficiently parse fixed width files? -

i trying find efficient way of parsing files holds fixed width lines. example, first 20 characters represent column, 21:30 1 , on. assuming line holds 100 characters, efficient way parse line several components? i use string slicing per line, it's little bit ugly if line big. there other fast methods? using python standard library's struct module easy extremely fast since it's written in c. here's how used want. allows columns of characters skipped specifying negative values number of characters in field. import struct fieldwidths = (2, -10, 24) # negative widths represent ignored padding fields fmtstring = ' '.join('{}{}'.format(abs(fw), 'x' if fw < 0 else 's') fw in fieldwidths) fieldstruct = struct.struct(fmtstring) parse = fieldstruct.unpack_from print('fmtstring: {!r}, recsize: {} chars'.format(fmtstring, fieldstruct.size)) line = 'abcdefghijklmnopqrstuvwxyz0123456789\n...

linux - Percentage value with GNU Diff -

what method using diff show percentage difference between 2 files? such if file has 100 lines , copy has 15 lines have been changed diff-percent 15%. something perhaps? two files, a1 , a2. $ sdiff -b -b -s a1 a2 | wc give how many lines differed. wc gives total, divide. the -b , -b ignore blanks , blank lines, , -s says suppress common lines.

multithreading - Synchronization of threads slows down a multithreaded application -

i have multithreaded application written in c#. noticed implementing thread synchronization lock(this) method slows down application 20%. expected behavior or should implementation closer? locking add overhead, can't avoided. of threads waiting on resources released, rather grabbing them when feel like. if implemented thread synchronization correctly, thing. but in general, question can't answered without intimate knowledge application. 20 % slowdown might ok, might locking broadly, , program (in general) slower. also, please dont use lock(this). if instance passed around , else locks on reference, have deadlock. best practice lock on private object noone else can access.

http - autocomplete through ajax -

i want suggest results using auto-complete. need send ajax requests on each keystroke. want keep http connection open few seconds , if typed within period, want send ajax in same connection. if nothing typed in period, want close http connection. background: i use typewatch plugin. here http connections made each time send request. still want improve speed. read in thread http://www.philwhln.com/quoras-technology-examined#the-search-box that: quora uses persistent connections. http connection established server when start typing search query. how can cross browser support? keep-alive? you can't. each request-response round trip asynchronous, meaning when it's sent, waits particular request's response return, handles it. what think want prevent script hammering server. there variety of methods, common use keystroke timer. timer waits specified number of milliseconds after user finishes typing before sending request, containing textbox...

html - How to get an inner div to fill the entire wrapper div? -

i have following html code: <div class="outer ui-draggable" style="position: relative;"> <div class="inner">foo bar</div> </div> with css: .outer { background-color: #f7f085; margin: 5px; height: 100px; width: 150px; text-align:center; vertical-align:text-bottom; } .outer .inner { display:inline; vertical-align:middle; height: 100px; width: 150px; } i inner div fill outer div - text block should entire 100x150 box. the problem code doesn't produce desired effect. outer div indeed correct size, inner div seems fill small area @ top of outer div. i tried using height:inherit , width:inherit instead of specifying size. the problem display:inline style. if want behave normal div, keep display:block . if it's display:inline tall inherited line-height.

iis 7 - How do I cache WCF REST web service in IIS7? -

when turn on output caching service doesn't appear cache-worthy in iis. should since i'm returning same json content on , over. varybyquerystring option seems trick, since resources uri based, there isn't query string, path resource. has gotten iis output cache wcf rest service? after digging using freb logs in iis, service in fact cache-worthy. can listen cache events in iis , show , not caching. found more helpful using perfmon. used following link set up. output caching work , in fact serve content right out of memory after things warmed up.

c# - When i select from sqlite column of type 'int' I can cast to .net int but when I select from 'integer' column I cannot -

i'm using system.data.sqlite, selecting sqlite database table column has type 'integer', , when this: int x = (int)reader["mycolumn"]; it fails. problem not value null; column not nullable. if change data type of column 'int' works fine. values in column '2', '3', '4', etc.; nothing big. anyone know if expected behaviour? as other answerer mentioned, sqlite integer stored in 1, 2, 3, 4, 6, or 8 bytes. however, won't overflow or out of range exceptions. in context, (int) cast, not conversion. if reader[] didn't return object of type integer, if it's returning different numeric type, cast exception, regardless of value contains. based on range of valid values sqlite integer, i'd guess it's returning value 64-bit integer, long . verify, try this: object x = reader["mycolumn"]; debug.writeline(x.gettype().name);

c - When does printf("%s", char*) stop printing? -

in class writing our own copy of c's malloc() function. test code (which can allocate space fine) using: char* ptr = my_malloc(6*sizeof(char)); memcpy(ptr, "hello\n", 6*sizeof(char)); printf("%s", ptr); the output typically this: hello unprintable character some debugging figured code wasn't causing per se, ptr's memory follows: [24 bytes of meta info][number of requested bytes][padding] so figured printf reaching padding, garbage. ran test of: printf("%s", "test\nd"); , got: test d which makes me wonder, when printf("%s", char*) stop printing chars? it stops printing when reaches null character ( \0 ), because %s expects string null terminated (i.e., expects argument c string). the string literal "test\nd" null terminated (all string literals null terminated). character array ptr not, however, because copy 6 characters buffer ( hello\n ), , not copy seventh character--the null...

c# - How would I define "GetDataFromNumber" so that my class contains a definition? -

my code gets error saying: 'eagle_eye_class_finder.getschedule' not contain definition 'getdatafromnumber' , no extension method 'getdatafromnumber'. using system; using system.io; using system.data; using system.text; using system.drawing; using system.data.oledb; using system.collections; using system.windows.forms; using system.componentmodel; using system.drawing.printing; using system.collections.generic; namespace eagle_eye_class_finder { /// form entry form, first form user see when app run. /// public class form1 : system.windows.forms.form { private system.windows.forms.textbox textbox1; private system.windows.forms.progressbar progressbar1; private system.windows.forms.picturebox picturebox1; private system.windows.forms.button button2; private system.windows.forms.datetimepicker datetimepicker1; private icontainer components; private timer timer1; pri...

php - Only insert if the value doesn't exist -

+----+----------+-----------+ | id | gamertag | timestamp | +----+----------+-----------+ so have table above want insert gamertag if doesn't exist. how that? $gamertag = "l rah l"; mysql_query("insert `gamertags`(`gamertag`)values ('".$gamertag."')"); you should both things: create unique index on column gamertag and use insert ignore . the unique index prevents duplicate row being added. the insert ignore prevents mysql issuing warning when duplicate row not added.

input - easiest way to take file into an array? - c# -

i have file of integers. first number - number of subsequent numbers. easiest way take file array? c# example 1: 8 1 2 3 4 5 6 7 8 example 2: 4 1 2 3 0 example 3: 3 0 0 1 int[] numbers = file .readalltext("test.txt") .split(' ') .select(int.parse) .skip(1) .toarray(); or if have number per line: int[] numbers = file .readalllines("test.txt") .select(int.parse) .skip(1) .toarray();

RavenDB or SQL Server 2008 Filestream -

a project working on @ minute involves taking massive set of results stored in file , doing calculations based on results. have been looking @ using either ravendb or using sql2008 filestream storage results. not sure technology best suited problem. has views on of these approaches best massive storage , possible searching of results? i tried insert lot of data raven , disappointed in first place, because did form 1 thread. turned out inserting sql server faster (without doing configuration on both servers). then realized misused raven, - far understand - designed handle massive parallelism. played bit tpl opening lot of threads / processes doing inserts in parallel. raven handled - keep "eventual consistency" in mind - not results showed in database immediatly short delay. i think direct comparrison hard unless adjust architecture fit choosen storage technology.

Using Sqlite3, create a slug version of a full title -

i have sqlite3 database table. added column called title_slug. want take contents of title column, , update new title_slug column slug version. can straight sqlite3 or have code outside of program? first of, there no loops in sqlite. not generic solution be: update mytab set title_slug = replace(replace(title_slug, ' ', '-'), '!', '') but have add many chars replace ?!

codeigniter - Codeignitor Manual Database Connection -

i doing php in codeignitor framework.always codeignitor support default persistent connections.i dont want use connection.i need connect manually.is possible in codeignitor?if know please me go forward.i need little bit explanation please. if want not persistent connection, set config file. $config['hostname'] = "localhost"; $config['username'] = "myusername"; $config['password'] = "mypassword"; $config['database'] = "mydatabase"; $config['dbdriver'] = "mysql"; $config['dbprefix'] = ""; $config['pconnect'] = false; $config['db_debug'] = true; $config['cache_on'] = false; $config['cachedir'] = ""; $config['char_set'] = "utf8"; $config['dbcollat'] = "utf8_general_ci"; $this->load->database($config); can read more in http://codeigniter.com/user_guide/database/connecting.html ...

html - How to select items which is displayed in Grid result -

<div class=x-grid3-scroller id=ext-gen742> <div class=x-grid3-body id=ext-gen743> <div class=x-grid3-row x-grid3-row-first x-grid3-row-last > <table class=x-grid3-row-table> <tbody> <tr> <td> class=x-grid3-col x-grid3-cell x-grid3-td-0 x-grid3-cell-first <td> class=x-grid3-col x-grid3-cell x-grid3-td-1 <td> class=x-grid3-col x-grid3-cell x-grid3-td-2 <td> class=x-grid3-col x-grid3-cell x-grid3-td-3 once click on 1 of these td values via gui, should selected in search field in form. could 1 meregarding this. i'm not sure asking, based off title i'm going give example answer: table abc def foo bar jkl mno xpath //tr[td/text()='foo']/td[2] this select bar following breakdown. find row[that has column, text ‘foo’] column [that second]

xml - Is there an equivallent for NSXMLParserDelegate in the cocoa touch framework? -

like title says, want parse xml in iphone application, there no nsxmlparserdelegate protocol there in system foundation framework. can add reference /system/library/frameworks/foundation.framework in iphone application? the nsxmlparser documentation shows delegate methods available you

Linux kernel live debugging, how it's done and what tools are used? -

what common , why not uncommon methods , tools used live debugging on linux kernel? know linus eg. against kind of debugging linux kernel or least , nothing has been done in sense in years, lot of time has passed since 2000 , interested if mentality has changed regarding linux project , current methods used live debugging on linux kernel @ moment(either local or remote)? references walkthroughs , tutorials on mentioned techniques , tools welcome. another option use ice /jtag controler, , gdb. 'hardware' solution used embedded systems, but instance qemu offers similar features: start qemu gdb 'remote' stub listens on 'localhost:1234' : qemu -s ... , then gdb open kernel file vmlinux compiled debug informations (you can take this mailing list thread discuss unoptimization of kernel). connect gdb , qemu: target remote localhost:1234 see you're live kernel: (gdb) #0 cpu_v7_do_idle () @ arch/arm/mm/proc-v7.s:77 #1 0xc0029728 in arch...

eclipse - Java Build Path - Add External JARs' and Add Variable -

what difference between java build path - add external jars button , add variable button functionality, why required. please explain in detail. both can used achieve same thing: add jar build path. suppose have project p1 wants use jar installed supplier s1, happens located @ c:\s1\aproject\jars\useful.jar client add external jars, navigate, select, , we're done. but, consider these cases. 1). suppose have several projects want use same jar? end repeating projects p1-pn. gets dull. what's worse, suppose install new version of s1's stack, need update project's build paths reference c:\s1\aproject-**v2**\jars\useful.jar and what's worse, if miss 1 running 2 versions of jar may bad! 2). share project colleage happens have s1 product installed in different location. need amend project point to e:\myfavouritethings\s1\aproject\jars\useful.jar and if using scm may tread on each others toes. so: instead add variable allows define workspa...

c# - Persisting a collection backed by viewstate in a CompositeControl -

maybe it's been long day i'm having trouble persisting collection backed asp.net viewstate in compositecontrol. here's simplified version: public class mycontrol : compositecontrol { public collection<myobject> myobjectcollection { { return (collection<myobject>)viewstate["coll"] == null ? new collection<myobject>() : (collection<myobject>)viewstate["coll"]; } set { viewstate["coll"] = value; } } } public partial class testpage : system.web.ui.page { protected void btn_click(object sender, eventargs e) { mycontrol1.myobjectcollection.add(new myobject()); } } when button clicked, event hander btn_click executes fine, setter myobjectcollection never gets called, hence new myobject() never gets persisted. i think i'm having blonde moment. fancy helping out? calling add() on collection isn't same calling setter on myobjectcollection property...

Extracting text from PDF with Poppler (C++) -

i'm trying way through poppler , (lack of) documentation. what want simple thing: open pdf file , read text in it. i'm going process text, doesn't matter here. so... saw poppler_page_get_text function, , kind of works, have specify selection rectangle, not handy. isn't there simple function output pdf text in order (maybe line line?). you should able set selection rectangle pagesize/mediabox of page , text. i should because before start wondering why surprised output of poppler_page_get_text , should aware of how text gets laid out on page. graphics laid out on page using program expressed in post-fix notation. render page, program executed on blank page. operations in program can include, changing colors, position, current transformation matrix, drawing lines, bezier curves , on. text laid out series of text operators bracketed bt (begin text) , et (end text). how or text placed on page @ sole discretion of software generates pdf. example, p...

Is there a way in VS 2010 with TFS 2008 to check in your changes as a new branch? -

my question rather simple have made many changes in our project don't want merge main branch right away. did not take branch @ start of these changes while making them. tried find way take branch check in code there not seem solution. how can , best approach take. using visual studio 2010 connects tfs 2008. thanks lot. you create new branch , change paths on edited files new branch before checking them in. create new branch. shelve pending changes. use power tools move shelved changes current branch new branch using following command. tfpt unshelve [my_shelveset_name] /migrate /source:current_branch_path /target:new_branch_path take @ powertools further details.

asp.net/ sql how can i save the text in Server.GetLastError() to DB when it has single quotes inside the string? -

i have below code , find text value represented in server.getlasterror contains single quotes , breaks sql insert code. exception ex = server.getlasterror(); stringbuilder thebody = new stringbuilder(); thebody.append("error message: " + ex.tostring() + "\n"); server.clearerror(); try { string ssql = "insert pmisweberr values ('" + thebody.tostring() + "', getdate())"; using (system.data.sqlclient.sqlconnection con = star.global.getconnection()) { system.data.sqlclient.sqlcommand cmd = new system.data.sqlclient.sqlcommand(ssql, con); cmd.commandtype = system.data.commandtype.text; cmd.executescalar(); } } catch (exception exe) { response.redirect("~/default.aspx?err="+ exe.message.tostring() ); } string ssql = "insert pmisweberr values (@errval, getdate())"; using (system.data.sqlclient.sqlco...

delphi - how to add a property to a component that will reflect on the object inspector -

in delphi 7 , when adding propery object, how possible see property in object inspector? make property published . instance, private fmyproperty: integer; published property myproperty: integer read fmyproperty write fmyproperty; often, need repaint control (or other processing) when property changed. can do private fmyproperty: integer; procedure setmyproperty(myproperty: integer); published property myproperty: integer read fmyproperty write setmyproperty; ... procedure tmycontrol.setmyproperty(myproperty: integer); begin if fmyproperty <> myproperty begin fmyproperty := myproperty; invalidate; // example end; end;

javascript - Why is Firefox 3 breaking with console.log -

i have following: console.log (a.time_ago() + ' ' + b.time_ago()); this breaking in firefox 3, meaning when ff hits line in js, goes no further. strangely if have firebug open doesn't break , continues normal. how firebug prevents issue? i'm puzzled on one. thoughts why console.log break firefox 3, not if firebug open? thanks this not firefox. code stop working in every browser (except chrome , safari (in instances) because have console.log() built in along developer tools.) it because when don't have firebug open, object "console" not defined. should take care never leave console.log() functions in code, or break in every browser . i'd add have used function: function log () { if (typeof console == 'undefined') { return; } console.log.apply(console, arguments); } then can call: log(somevar, anothervar); and work same way console.log, not fail if firebug not loaded (and shorter type :p) c...

django - Generate an unique identifier for a Model -

i have model containing filefield. i'd filefield have unique path. at first, @ though using id of entry, django move file it's upload_to path before saving entry, id empty. moreover, can't use title or other elements of model (except creation date) since can changed user. , prefer not copy/delete file every time user change title of it's entry (if use title part of path). here start research, found these : generate unique key , compare database. while key exist, generate new 1 ( django, unique field generation ) : problem potentials hits while database before having unique key getting timestamp creation date. problem here, if 2 people add file @ exact same time, generate conflicts i'd have unique id small possible, max length of 7 great. perfect solution have been have id of entry. know workaround (calling save() before moving files upload_to folder?) or if not, implementation best, based on 1 of solutions or 1 think better? since filefi...

c# - WCF: How to stop myServiceHost.Close() from disposing of myServiceHost object? -

apparently close , dispose same. want able close , open servicehost instance without having reinstantiate everytime. ideas? thanks. servicehost.close identical dispose() . true, in general, types have close() method - dispose() implemented in terms of close() . fyi - servicehostbase implements dispose() explicitly via: void idisposable.dispose() { base.close(); } this, effectively, means when close servicehost, you'll dispose() of it. there no supported way "reopen" without recreating it.

.net - c# - embed activex control remote desktop -

scenario: user 1 presenting or desktop user 2. user 2 can view what's happening on user 1 on his(user2)'s screen, cannot control it. got hint somewhere embedding activex control rdp allow me not know start? is sort of collaboration? any appreciated ! in advance ! the rdp control won't here. rdp doesn't allow screen sharing. remote assistance , "windows desktop sharing" (only in vista , newer) give core functionality néed adapt solution on top of closed , poorly documented components. your best bet write on top of vnc. ultravnc's code mess, have better luck tightvnc. good luck!

iphone - navigationItem.backBarButtonItem not working? Why is the previous menu still showing as the button? -

trying customize button in drilldown navigation controller. on 1 view controller have add button code programatically generates new uiviewcontroller : - (void)add:(id)sender { myaddviewcontroller *addcontroller = [[myaddviewcontroller alloc] initwithnibname:@"myaddviewcontroller" bundle:nil]; [self.navigationcontroller pushviewcontroller:addcontroller animated:yes]; [addcontroller release]; } this works , when click add button drills down new view. inside viewdidload method of myaddviewcontroller.m have: self.navigationitem.backbarbuttonitem = [[[uibarbuttonitem alloc] initwithtitle:@"back" style:uibarbuttonitemstyleplain target:nil action:nil] autorelease]; but isn't working. button in navigation controller remains title of previous view's controller on stack. seems line nothing. did miss something? thanks this work on each child after viewcontroller has self.navigationitem.backbarbuttonitem .

csv - Python: Write list to individual columns in each row -

i'm writing data csv current output follows: (the top row headers) vc_s vc_i vt_s 1 (['not reported'],['reported'],['click']) 2 (['not reported'],['reported'],['click']) the desired output follows: vc_s vc_i vt_s 1 not reported reported click 2 not reported reported click the code i've got far is: ifile = csv.reader(open("input.csv",'rb')) shutil.copy("input.csv","temp") tempfile = csv.reader(open("temp","rb")) ofile = csv.writer(open("results.csv","ab")) row in ifile: #do table scraping stuff here vc_s = str(cells[1].find(text=true)) vc_i = str(cells[2].find(text=true)) vt_s = str(cells[4].find(text=true)) entry = ([vc_s], [vc_i], [vt_s]) rowadd = tempfile.next() ofile.writerow(rowadd + [entry]) what doing w...

tooltip - ExtJS Quicktip constrains problem -

Image
i've got column renderer defined creates html fragment contains ext.qtip attributes create quicktip. works fine, image renders in grid cell, when hover on image tooltip larger image shown ... nice quicktip on bottom row expands beyond constraints of panel, there way make stay inside panel boundaries? var thumbrenderer = function(value, meta, record){ var thumbpath = config.baseurl + 'images/thumb/' + record.get('filename'); var previewpath = config.baseurl + 'images/big/' + record.get('filename'); return string.format('<img src="{0}" ext:qwidth="312" ext:qtip="<img style=\'margin: 2px 0;width:300px;\' src=\'{1}\' />" width="60" class="pic" />', thumbpath, previewpath); } you may want @ showat method: tip.showat([x,y]); where x , y respective x , y co-ordinate positions. edit: can use showby() method on quicktip instance: http:...

c++ - Read hexa data from file -

i'm trying read hexa data(color value ex. 0xffffffff) txt file... but don't know how read it.... i declared color value 'uint color' , want change value though txt file. if use int data can use 'atoi' function, can use function uint? you can use strtoul strtoul returns long, can 1 of 2 things: just truncate data check if fits in unit example usage: char *endptr; unsigned long ul = strtoul(str, &endptr, 16); if (str == endptr) // error, no data converted // truncate unsigned int utrunc = (unsigned int)ul; // or can first check if fits if (ul < uint_max) unsigned int ufit = (unsigned int)ul;

PHP & MySQL - Deleting table rows problem -

okay script supposed delete specific users case stored in 2 mysql tables reason when user deletes specific case deletes users cases want delete case user selects. wondering how can fix problem? in advance helping. here php & mysql code. if(isset($_post['delete_case'])) { $cases_ids = array(); $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"select cases.*, users_cases.* cases inner join users_cases on users_cases.cases_id = cases.id users_cases.user_id='$user_id'"); if (!$dbc) { print mysqli_error($mysqli); } else { while($row = mysqli_fetch_array($dbc)){ $cases_ids[] = $row["cases_id"]; } } foreach($_post['delete_id'] $di) { if(in_array($di, $cases_ids)) { $mysqli = mysqli_connect("localhost", "root", "", "sitename"); $dbc = mysqli_query($mysqli,"delete users...

python - client connects to old server thread and retrieves outdated data? -

i have client thread ping server 1 of status attributes: def run ( self ): client = socket.socket(socket.af_inet, socket.sock_stream) client.connect(('localhost',2727)) print 'client #', self.name , 'polling' x = client.recv(1024) client.close() print x my server runs loop gets it's state, , spawns thread socket: while true: devicestate = self.getdevicestate() channel, details = self.server.accept() sthread.serverthread(channel, details, devicestate).start() the issue after update devicestate , client pings, first gets old state (probably existing serverthread) no matter how long wait. when client pings again, can pick new state. there way shutdown serverthread if devicestate updated , make sure client socket gets fresh server thread? sthread.serverthread() function, right? instead of getting device state , passing argument serverthread() , have implementation of serverthre...

php - Problems with embedded apex in a string? -

how can write more embedded " , ' in php ? example, dunno how write html complete element apex: as can see, use '' php string. inside, use "", need level of apix , dunno how write 1 in php document. (php thinks string complete in middle because sees ' before end. $output .= '<img style="outline:none;" src="sites/default/unselect.png" alt="unselect all" onclick='$(this).siblings('.form-item').each(function(index){ $('input:checkbox', this).attr('checked', ''); });'/>'; how can solve ? thanks there many ways solve that. listed best worst 1) use templating engine , keep php , html separate. also, use non-obtrusive javascript , avoid javascript code in html tags 2) when outputting complex html, escape php mode , print strings is. function foo() { ?> complex html <?php php continues here } // foo 3) use heredoc syntax avoid quotin...

annotations - Ruby notation conventions -

when writing ruby code use: dog represent dog class #bark represent instance method .new or ::new represent class method what's convention representing instance of class? dog blend right in surrounding regular text. that sounds right. in smalltalk, customary use anarray , astring or adog (even parameter names in method declarations), translate an_array , a_string or a_dog . however, that's not customary, , might strange experienced rubyist, expect see ary , str , dog . note in general, dot only used in code examples actual method calls . when talking about method, always use # , :: instance methods , singleton methods.

ruby on rails - autotest shows blank -

i installed autotest gem , intend use rspec. problem is, when run autotest under rails app, see : railsapp$ autospec loading autotest/rails_rspec and stuck there until ctrl-c out of it. nothing changes if change rspec test or code. here's ~/.autotest require "autotest/restart" require 'redgreen/autotest' require 'autotest/fsevent' require "autotest/growl" i had same problem. able working making sure on latest (beta, if necessary) versions of rspec, rspec-rails, autotest, , autotest-rails, , putting following in autotest/discovery.rb: autotest.add_discovery { "rails" } autotest.add_discovery { "rspec2" } here's the blog post got me started in right direction.

JQUERY error : null or not an object. Any Jquery Ninjas that can help? -

any jquery ninja's out there? getting error in ie ? 'tip' null or not object here small script: $(document).ready(function() { //tooltips var tip; $(".tip_trigger").hover(function(){ //caching tooltip , removing container; appending body tip = $(this).find('.tip').remove(); $('body').append(tip); tip.show(); //show tooltip }, function() { tip.hide().remove(); //hide , remove tooltip appended body $(this).append(tip); //return tooltip original position }).mousemove(function(e) { //console.log(e.pagex) var mousex = e.pagex + 20; //get x coodrinates var mousey = e.pagey + 20; //get y coordinates var tipwidth = tip.width(); //find width of tooltip var tipheight = tip.height(); //find height of tooltip //distance of element right edge of viewport ...

c++ - Vector clear vs. resize -

i read on internet if clearing std::vector repetitively (in tight loop), might better use resize(0) instead of clear() , may faster. not sure this. have definitive answer this? i assume mean resize(0) instead of setsize , , calling instead of clear() , , you're talking std::vector . iirc recent answer discussed (can't find link), , on modern stl implementations, clear() identical resize(0) . previously clearing vector might have freed memory (ie. capacity falls zero), causing reallocations when start adding elements again, in contrast resize(0) keeping capacity there fewer reallocations. however, think in modern stl libraries there no difference. if you're using old stl implementation, or you're paranoid, resize(0) might faster.

xcode - Opengl Triangle instead of square -

im trying create spinning square inside of xcode using opengl instead reason have spinning triangle? i'm doing inside of sio2 dont think problem. here triangle: http://img220.imageshack.us/img220/7051/snapzproxscreensnapz001.png here code: void templaterender( void ) { const glfloat squarevertices[] ={ 100.0f, -100.0f, 100.0f, -100.0f, -100.0f, 100.0f, 100.0f, 100.0f, }; const unsigned char squarecolors[] = { 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, }; glmatrixmode( gl_modelview ); glloadidentity(); glclear( gl_depth_buffer_bit | gl_color_buffer_bit ); // rendering code here... sio2windowenter2d( sio2->_sio2window, 0.0f, 1.0f ); { glvertexpointer( 2, gl_float, 0, squarevertices ); glenableclientstate(gl_vertex_array); //set color array glcolorpointer( 4, gl_unsigned_byte, 0, squarecolors ); gle...

vb.net - I'd like to preview a Word document on form -

update2: now, i'm considering saving temporary copy of document in html format display it, kills idea show user's real time affect on document. it's bad practice re-save @ every character input , reload browser. so, suppose may impractical now. i'll keep ear thread answers might arise. thank help. update1: webbrowser works pdf, not word documents reason. instead of displaying in browser control, opens document in word. apparently having file program association within operating system, i'm programming work on machines besides own. therefore, i'll either need work around, or way change setting programmatically. interestingly, when right click on doc file, click open with, , select internet explorer, opens word. original question: i'm writing vb program fills in values within word document. i'm utilizing microsoft word 12.0 object library reference. i'd provide scrollable preview pane user within form or using. ...

How to use Groovy Set for unique elements? -

as simple must still can't understand wrong: class { boolean equals(o) { true } } def s = [new a(), new a()] set assert s.size() == 1 // assertion failed: gives 2 which method should override in order uniqueness? hashcode , java class { boolean equals(o) { true } int hashcode() { 1 } } def s = [new a(), new a()] set assert s.size() == 1

javascript - How to validate form using JQuery when only one particular button is pressed? -

i have form 2 submit buttons on it. buttons must of submit type , can't change it. how can make jquery not validate submit form when first button pressed , validate , submit when second button pressed? thank event.originalevent.explicitoriginaltarget gecko-specific property (see this question , answer ). the following should work: var dovalidate; $('#validating-button').click(function () { dovalidate = true; }); $('#non-validating-button').click(function () { dovalidate = false; }); $('#form').validate({ rules: { myinputname: { required: function () { return dovalidate; } } } });

html - Display Adobe pdf inside a div -

i have pdf file user has see , click on "i agree" button. how display pdf inside div? yes can. see code following thread 2007: pdf within div <div> <object data="test.pdf" type="application/pdf" width="300" height="200"> alt : <a href="test.pdf">test.pdf</a> </object> </div> it uses <object> , can styled css, , can float them, give them borders, etc. (in end, edited pdf files remove large borders , converted them jpg images.)

Rails 3 ajax hyperlink bindings -

i'm using rails 3 default javascript library (prototype, believe) , want render link makes ajax call when pressed. here's sample haml code: = link_to "test link", {controller: :information, action: :faq}, remote: true, id: "abc" :javascript $("abc").bind('ajax:beforesend', function(){ alert('begin!'); }) right now, i'm testing code hand. idea should click on link , alert box should pop says "begin!" no alert dialog pops when click on hyperlink. i've tried switch binding ajax:beforesend ajax:before , doesn't work either. any ideas on i'm doing wrong? thanks! $("#abc").bind('ajax:beforesend', function(){ you missing # id