Posts

Showing posts from January, 2015

compile ffmpeg on stand redhat -

i'm working on redhat server isn't connected internet, can't download things directly onto server. can transfer them via scp server. is there step step guide compiling ffmpeg redhat? if can scp server connected internet , wish install using rpm's rather compiling, suggest following: install yum-downloadonly on server in question: yum -y install yum-downloadonly simulate install of ffmpeg using downloadonly save required packages locally: yum -y install ffmpeg --downloadonly --downloaddir=your_download_directory transfer downloaded rpm's server without internet access cd directory rpm's on server , run install of them: rpm -ivh --nodeps *.rpm that should it!

php - Two-way encryption: I need to store passwords that can be retrieved -

i creating application store passwords, user can retrieve , see. passwords hardware device, checking against hashes out of question. what need know is: how encrypt , decrypt password in php? what safest algorithm encrypt passwords with? where store private key? instead of storing private key, idea require users enter private key time need password decrypted? (users of application can trusted) in ways can password stolen , decrypted? need aware of? personally, use mcrypt others posted. there more note... how encrypt , decrypt password in php? see below strong class takes care of you: what safest algorithm encrypt passwords with? safest ? of them. safest method if you're going encrypt protect against information disclosure vulnerabilities (xss, remote inclusion, etc). if gets out, attacker can crack encryption (no encryption 100% un-reversible without key - @nulluserexception points out not entirely true. there encryption schemes impossible crack

Populating ComboBox inside ListView in WPF -

Image
i have populated combobox inside listview . screen shot given below as shown above it's displaying "m", "a", "c" instead of "mac". why separating word characters? in code behind file i've written itemcategorydal itemcategorydalobj = new itemcategorydal(); datatable datatable = itemcategorydalobj.getallitemcategory(); listview1.itemssource = datatable.defaultview; and in .xaml file i've written: <listview height="148" horizontalalignment="left" margin="23,12,0,0" name="listview1" verticalalignment="top" width="447" > <listview.view> <gridview> - - - - - - - - - - - - - - - - <gridviewcolumn header="category name" width="150"> <gridviewcolumn.celltemplate> <datatemplate> <combobox itemssource="{bin

ruby - How to use Rake to manage multiple directory project? -

i have project consists of multiple projects, like: my_project\ proj_a\ (code, tests, rakefile, etc) proj_b\ (code, tests, rakefile, etc) proj_c\ (code, tests, rakefile, etc) i'd create rakefile under "my_project" can execute rakefile's in other projects. example package entire app need run tasks defined in rakefile's in proj_a, proj_b , proj_c (in order). what's best way this? have rakefile defines tasks call out other rakefiles? create rake task depends on other projects. import 'projdir1/rakefile' import 'projdir2/rakefile' task :finalproject => [:project1, :project2] # nothing or maybe cleanup end the tasks :project1 , :project2 defined in external rakefiles being included. also @ page more complex examples. http://rake.rubyforge.org/files/doc/rakefile_rdoc.html

localization - Changing the default ModelState error messages in ASP.NET MVC 3 -

i have resource files in separate assembly myapp.resources.dll. can use resources without problem issue appears when want change (localize) default validation messages: "the {0} field required." , "the value '{0}' not valid {1}." the solution defaultmodelbinder.resourceclasskey = "myapp.resources.global"; not work because requires resourceclasskey under app_globalresources folder in web project. what should fix me ? regards i have found solution case (when resources in separate assembly). to working should create custom resourceproviderfactory , register default resourceproviderfactorytype in <globalization> web.config section. setup localization // modify web.config in run-time , setup custom resourceproviderfactory var globalization = webconfigurationmanager.getsection("system.web/globalization") globalizationsection; var readonlyfield = typeof(configurationelement).getfield("_breadonly", b

haskell-problem: io string -> [int] -

hello great programmers out there, i'm doing first steps in haskell , have function confuses me: import data.list.split getncheck_guesslist = line <- getline let tmp = splitoneof ",;" line map read tmp::[int] splitoneof in data.list.split (i installed cabal install split) splitoneof :: (eq a)=> [a]->[a]->[[a]] from error there type incorrectness - don't know how solve conflicts io still mystery me i want read input of integers separated commas or semicolons , list of integers so: how can check if user input of type int how can "translate" input of type "io string" [int] thank in advance thoughts , hints - yours ε/2 when you're writing function uses io monad, value want return function must in io monad. this means that, instead of returning value type [int] , have return type io [int] . this, use return function, "wraps up" value io (it works any monad). just change last l

c# - Make VDProj .MSI installer copy itself locally after successful install -

we have large c# application spanning many projects packaged .msi file running msbuild (or through visual studio 2010) on .vdproj file. installation works fine, , warns correctly if other required software not found on local machine. however, if installation successful, installer copy particular folder in program files. example 'c:\program files\app\version\install_1.2.3.4.msi'. does know of way of doing this? you can msi path originaldatabase property. copy msi can use custom action scheduled after installfinalize standard action. for example, can write simple exe receives [originaldatabase] parameter , performs copy operation. installfinalize not shown in visual studio. can add custom action under install , edit msi orca change sequence after installfinalize in installexecutesequence table. you can more control on custom actions using other setup authoring tools.

Memcached disable on test environment? -

for example have on dedicated server live site , in sub folder test site? is there way disable memcached on test site because don't want thing make on test site affect memory cache on live site. in environments/test.rb, add line config.cache_store = :null_store in order disable caching.

Django admin: hide read-only fields on new records? -

i'm using django admin site readonly fields on records: class bookadmin(admin.modeladmin): fieldsets = [ (none, {'fields': ['title', 'library_id', 'is_missing', \ 'transactions_all_time']}), ] readonly_fields = ['transactions_all_time',] list_display = ('library_id', 'author', 'title') this works great when editing records - transactions_all_time field read-only, want. however, when adding new records behaves bit oddly. read-only section @ bottom of page, can't edit , irrelevant @ point. it better if field not present @ when adding new records. is there django option not displaying read-only fields while adding new record? know can hack css on add_form.html hide it, there better way? thanks. i had similar problem. resolved this class mymodeladmin(admin.modeladmin): readonly_fields = ('field_one',) def get_readonly_fields

mysql - grouping but ignore if blank -

i'm trying group (or @ least make unique) column m_group_name unless group empty. see doesn't yet have group (and edited placed one) while being able see existing groups. for example; id | m_group_name --------------------- 1 | red 2 | blue 3 | 4 | red 5 | which, ideally, result in 1 red, 1 blue, , 2 blanks. i've tried making blanks null , giving uuid value (after adapting similar found here on stackoverflow), seems make every null same value. select *, ifnull(m_group_name,uuid()) m_group m group m_group ideally i'd rather not use null honest edit: realised 'm_group_name' incorrectly labelled 'group' in example - corrected. select * m length(group) in (0, null) * length(null) return null . length('') return 0 . am right want see rows don't yet have group ? edit : okay, read carefully. how this: select * m length(group) not in (0, null) group group union select * m length(group) in (0, nul

c# - how to get a value and not the formula -

i trying obtain minimum value worksheet when generate minimum , place in cell, , extract value getting entire formula , not double value in cell.... doing wrong? below generate graph method. another thing, delete graph after save have tried .delete() threw , error, how go doing that private void generategraph(worksheet worksheet, int lastrow, int lastcolumn, string filename) { string topleft = tocell(0, 0); string bottomright = tocell(lastrow - 1, lastcolumn - 1); worksheet.get_range(tocell(0, 0), missing).formula = "max(b2:" + bottomright + ")"; worksheet.get_range(tocell(0, 0), missing).formulahidden = true; worksheet.get_range(tocell(0, 0), missing).calculate(); range range = (range)worksheet.cells[1,1]; // //here problem is, small being given formula above // string small = (string)range.value2; double min = convert.todouble(small); works

sql - Selecting rows with references across tables in SQLite 3 -

i have sqlite photo/album database 3 tables: albums id name hide -------------------------- 1 holiday 2010 1 2 day trip 0 photos id file ----------------- 1 photo1.jpg 2 photo2.jpg 3 photo3.jpg 4 photo4.jpg relation (connects photos albums) album photo ----------------- 1 1 1 2 2 3 2 1 a photo can assigned zero, 1 or several albums. each album has column 'hide' indicates, whether photos of album should ignored. i'm trying find select query returns photos not assigned album + photos in albums not hidden (i.e. have 'hide' value set 0). i came query selects photos in visible albums, don't know how include photos not assigned album: select file photos, albums, relation photos.id = relation.photo , albums.id = relation.album , albums.hide = 0 this query returns: photo1.jpg photo3.jpg however, required result be: photo1.jpg photo3.jpg photo4.jpg t

objective c - Problems in TTTableview class using Three20 in iPhone? -

now using three20 in apps. have problem, when run application mainwindow.xib , tttableview class isn't called. without mainwindow.xib call tttableview class. don't know why it's happening. please me out. thanks. in appdelegate code delete mainwindow.xib - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { if (![navigator restoreviewcontrollers]) { [navigator openurlaction:[tturlaction actionwithurlpath:kapprooturlpath]]; } } in main.m #import <uikit/uikit.h> int main(int argc, char *argv[]) { nsautoreleasepool * pool = [[nsautoreleasepool alloc] init]; int retval = uiapplicationmain(argc, argv, nil, @"yourappdelegate"); [pool release]; return retval; }

c# - Updating local nuget package on post-build event -

i have local nuget library repository separately both personal , work releted class libraries. i have created of nuget packages libraries no longer in development. did them because not know how update them automatically project builds. i have figured work being done nuget command line visual studio command prompt. can work needed (of course know commands , not !) basically want following tasks execute on post-build event of project. on project build: copying project dll specific folder (lib folder of nuget package) updating nuspec file new file version (my project increasing file version on every build) creating new nupkg file new file version phil haack shows of feature still prototype far can tell. so requirement above. has else accomplished this? jeremy skinner has written a blog post on how performs automated builds of packages , uploads them nuget gallery. think matches requirements. basically uses msbuild apply version (with msbuild community ext

How can I take MySQL dumps with some tables excluded from the database -

we have database in 1 specific table gets large fast. when taking dump , restoring database on server, takes lot of time due large size. want exclude specific table when taking dump. ideas ? mysqldump has --ignore-table option, like: mysqldump -p -u username nameofdatabase --ignore-table=verybigtable

c# - Autofac composite pattern -

i noticed quite need implement composite pattern. example: interface iservice { ... } class service1 : iservice { ... } class service2 : iservice { ... } class compositeservice : iservice { public compositeservice(ienumerable<iservice> services) { ... } ... } i want register compositeservice iservice in container , have dependencies injected. (looks similar decorator decorating set of services instead of one) what's best way in autofac? how ideal solution (for c#)? update: my current registration is: builder.registertype<service1>().named<iservice>("impl"); builder.registertype<service2>().named<iservice>("impl"); builder.register(c => new compositeservice(c.resolve<ienumerable<iservice>>("impl"))) .as<iservice>(); it similar decorators hand in http://nblumhardt.com/2011/01/decorator-support-in-autofac-2-4 can improved? i haven't implemented or thought

javascript - erasing textfield after submit content -

i want erase content of textfield after adding option select list, here html code example: <select size="15" style="width:230px" style="text-align:right" id="theaterselectcontrol"> <option>111</option> <option>222</option> <option>333</option> </select> <p> </p> <form> <input type="text" name="theater_name" value="" id="theater_name" style="width:225px"> </form> </td> </tr> <tr> <td align="right"> <input type="button" onclick="createoption()" value="ad

locking the object inside a property, c# -

public arraylist inputbuffer { { lock (this.in_buffer) { return this.in_buffer; } } } is this.in_buffer locked during call inputbuffer.clear? or property lock in_buffer object while it's getting reference it; lock exits, , reference used clear? in addition others have said scope of lock, remember aren't locking object , locking based on object instance named. common practice have separate lock mutex jon skeet exemplifies. if must guarantee synchronized execution while collection being cleared, expose method clears collection, have clients call that, , don't expose underlying implementation details. (which practice anyway - encapsulation.)

MySQL Query Ranking -

i have mysql query list "vote ranking" "actions" , work fine, want "id_user" doesn't repeat, made "distinct" in field. select count(v.id) votos, v.id_action, a.id_user, a.id_user_to, a.action, a.descripcion votes v, actions v.id_action = a.id group v.id_action order votos desc the result: votes act id_user 3 3 745059251 2 20 1245069513 2 23 1245069513 2 26 100000882722297 2 29 1245069513 2 44 1040560484 2 49 1257441644 2 50 1040560484 the expected result votes act id_user 3 3 745059251 2 20 1245069513 2 26 100000882722297 2 44 1040560484 2 49 1257441644 2 50 1040560484 if don't want duplicate users, should group a.id_user only. have aggregate actions, may want sum(a.action) or count(a.action) in place of a.action. it's hard tell should use without knowing &#

c++ - Visual Studio linker cannot find libboost_system -

i'm using vs 2008 , want use boost::asio library. work in new project (i want include boost/bind.hpp , boost/asio.hpp), in existing project error: fatal error lnk1104: datei "libboost_system-vc90-mt-sgd-1_46.lib" cannot found. i can't find file in boost directory, one: libboost_system-vc90-mt-gd-1_46.lib (gd instead of sgd) mean? thank you! i assume you've used boost installer boostpro. if reinstall , make sure select multithread debug, static runtime .

c# - Cryptic exception copy/pasting from DataGridView into Excel 2002 -

good morning, running visual studio 2008 (c# 3.5). datagridview loaded manually (not data bound). copy/pasting notepad/wordpad works fine, when try copy/paste excel weird exception: invalid formatetc structure (exception hresult: 0x80040064 (dv_e_formatetc)) this working of last friday. i'm stumped. pretty sure has worked in past. i've tried rebooting, re-adding datagridview control. appreciated. regards, -alan. perhaps of data being interpreted excel formula (like 5/0). you try pat's suggestion first (it's easier!). also, try pasting text notepad first, copying notepad, , pasting excel. if still errors, try pasting first half of text in notepad. if succeeds, paste second half. key try narrow down string of text causing excel barf on you.

search - How to add a recent file with a .zip file extension, in a specified folder to a php variable? -

i script in php code search specific folder added file .zip file extension , add variable manipulated later. use scandir files in specific folder, isolate zip files using strpos() or regexp on retrieved filenames. if needed, test last modification time of zip files found. edit: using glob() faster match *.zip files. [edit] managed come code think coded dirty. way clean up? $show = 2; // change 0 listing found file types $dir = ''; // blank if folder/directory scanned current 1 (with script) if($dir) chdir($dir); $files = glob( '*.zip'); usort( $files, 'filemtime_compare' ); function filemtime_compare( $a, $b ) { return filemtime( $b ) - filemtime( $a ); } $i = 0; foreach ( $files $file ) { ++$i; if ( $i == $show ) break; $value = $file; } echo "this file name in variable: " . $value; ?>

jquery - jqGrid clientArray -

i trying use jqgrid clientarray submit multiple updates @ once. (i trying update multiple rows in 1 go). onselectrow: function(id){ if (id && id !== lastsel) { jquery('#fnlusetaxlistings').saverow(lastsel, true, 'clientarray'); jquery('#fnlusetaxlistings').editrow(id, true, null, null); lastsel = id; } }, this works fine, have no idea how retrieve clientarray , send server? if can post example of sending clientarray server, helpful. thanks, ashish there no "clientarray", there 'data' parameter object local data. see this or this answer examples.

java - Using <c:when> with an enumeration -

i have jsp portlet needs display different markup according value of bean's property of enumeration type public enum state { canceled, completed } i used following code switch <c:choose> <c:when test="#{item.state == 'completed'}"> <img src="ok.gif" /> </c:when> <c:when test="#{item.state == 'canceled'}"> <img src="ko.gif" /> </c:when> </c:choose> but doesn't work. interestingly enough, returns false in both cases. item object (inside icefaces data table) backing bean state getter+setter property. have been told compare enumeration string , use == operator, maybe that's not way. so, question is: how use &lt;c:when&gt; tag compare property enumeration value? ... the item object ( inside icefaces data table ) ... then jstl indeed doesn't work. runs during view build time, not during view render

iphone - Selecting a location with MapKit -

is there best practice or common pattern allowing users select precise location on map using mapkit? i've seen examples user can enter address in search box. case user doesn't know exact address , wants select location map? it's bit more complex task seems. here guide how detect single taps on web view. i've used same pattern detect single taps on map view allowing zooming , dragging @ same time. hope helps.

ruby on rails - Set timezone for incoming xml data -

i'm getting datetime field api not explicitly set timezone. when place database it's assuming datetime must in gmt, timezone in chicago time. (i chicago time, because i'm still unsure if api factors in dst.) best way me convert time gmt before adding database? here xml sample of 1 of nodes i'm referring to: <fromdatetime>2011-03-17 08:00:00</fromdatetime> in ruby, i'm using add record database. :starttime => datetime.parse(row.at_xpath("fromdatetime/text()").to_s), i think need add difference in hours between cst , gmt last ruby call, right? how that? thanks! could use time instead? datetime not daylight savings time aware. time automatically sets local gmt offset given date/time , set dst if needed. irb(main):014:0> require 'time' irb(main):015:0> time.parse('2011-03-17 08:00:00') => thu mar 17 08:00:00 -0400 2011 irb(main):022:0> time.parse('2011-03-17 08:00:00').dst? =>

How Do i compare Two model fields against each other in django? -

Image
i have model in models.py file.i want to compare "start_date" , "end_date" start_date value never greater end_date or vice-versa.how do validation? class completion(models.model): start_date = models.datefield() end_date = models.datefield() batch = models.foreignkey(batch) topic = models.foreignkey(topic) i'd start getting head model validation framework. http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.model.clean it's used modelforms , makes whole lot of sense start using it. basically, you'd define clean() method in model, put in validation logic, , raise validationerror if fails. class mymodel(models.model): def clean(self): django.core.exceptions import validationerror if self.start_data > self.end_date: raise validationerror('start date cannot precede end date') def save(self, *args, **kwargs): # can have regular model insta

Simple Linux word processor to create trivially styled PDF? -

i want create trivially styled pdf. what's simple linux word processor can use?: i want embolden text , put headers on each page w/ enlarged text. want decide page breaks are. is latex this? there latex2pdf program? openoffice seems "big" (plus doesn't work on machine). i consider using html , html2pdf i'm not sure paging (unless broke each file multiple html pages, shudder). would enriched text (or rtf?) this? there linux word processors can produce these formats , programs can convert them pdf? i sense i'm missing basic (this can't hard), can't figure out what. latex job. vast majority of latex users produce pdf primary format; command pdflatex . latex suited if need automatable process. in same lines have @ apache fop xsl-fo processor can output pdf. may suited if input data xml. if don't need automate process, may use simple word processor program such abiword or kword . both of them can work in rtf (which should s

c++ - Returning garbage data from a classes private array -

i have class assignment have write program take number user no more 50 digits long. have class called number has array called value[50] used holding value of number. number length, use of arrays, requirement of assignment. the declaration of number class follows: class number { private: int value[50]; int numbersize; public: number(); number(int&, int&); int getvalue(); number& operator=(const number&); }; and definition number :: number(int& numbervalue, int& newnumbersize) { numbersize = newnumbersize; (int count = newnumbersize; count > 0; count --) { value[newnumbersize] = numbervalue % 10; numbervalue = numbervalue / 10; cout << value[numbersize] << endl; } } int number :: getvalue() { (int count2 = 0; count2 < numbersize; count2 ++) { cout << value[count2] << endl; } return 0; } i've omitted superfluous information suc

javascript - ajax jquery and drupal not work, please see why -

drupal 6: here code: http://pastebin.com/ggvffags //getcity.js: $(document).ready(function() { $("#edit-field-house-geo-area-value").bind('change', function(){ selected_loc=$("#edit-field-house-geo-area-value option:selected").val(); var myurl="http://whatever.com/getajax/citys/"+selected_loc+"/"; $.ajax({ type: "get", url: myurl, datatype: "json", success: function(data){ console.log(data); } }); }); }); drupal module: function sf_menu() { cache_clear_all(); $items = array (); $items ['getajax/citys/%'] = array ('title' => 'this custom page', 'page callback' => 'sf_get_cities_ajax', 'access arguments' => array ('access content' ), 'access callback' => 'user_access', // true give access 'page arg

How to export data from C++ to MatLab -

i have written c++ program outputs list of random numbers. asked export these numbers matlab in order produce histogram , other graphics. how can this? (i'm beginner; please specify files , steps need add). thank you. here did matlab console ( input.txt contains 3 integers values): >> f=fopen('input.txt','rt') f = 3 >> fscanf(f,'%d') ans = 1234 23435 888 >> fclose(f) ans = 0 >> to sum up: f=fopen('input.txt','rt'); integerlist = fscanf(f,'%d'); fclose(f); for more details functions can use doc or help in matlab console: doc fscanf fscanf

object - what is the life cycle of a ColdFusion CFC instance creation? -

i know how cfc instantiated in coldfusion under hood !. know create instance of component , reference newly created instance , can use call public methods inside them. but happening when write th code <cfscript> person = createobject('component','human') // happen here!!!! person.speak(); </cfscript> made correction statement here!!!. reason why ask question because have instance stored in application scope , instance used below application.person.speak(); now under high load. found memory not release person obj , @ point reached 200mb.. strange! . made correction says in best practices request.person = duplicate(application.person); now there direct way request.person = createobject('component','human'); difference, first 1 creates object , keep in share scope, deep copy request everytime request made(here instance created once). second 1 instance creation every time request made. there performance difference between

Excel 2007 VBA find function. Trying to find data between two sheets and put it in a third sheet -

all, i trying write macro search cells column 2 sheet1 in sheet2 , copy found rows sheet 2. this have got far: sub copyunique() application.displayalerts = false set qa_14 = sheets("qa 14feb") set prod_14 = sheets("prod 14feb") set prod_o14 = sheets("sheet1") counter = 1 dim found range dim qarange range row = 1 prod_14.usedrange.rows.count set qarange = qa_14.cells(2, 1) set found = qarange.find(what:=prod_14.cells(row, 2).text, after:=qa_14.range("a1"), lookin:=xlvalues, lookat:=xlpart, searchorder:=xlbycolumns, searchdirection:=xlnext, matchcase:=false, searchformat:=false) if not found nothing prod_14.usedrange.range(cells(row, 1), cells(row, prod_14.usedrange.columns.count)).copy prod_o14.range("a" & ltrim(str(counter))) counter = counter + 1 end if next end sub the problem occurs on line find function. gives type mismatch error.

c++ - sharing opengl context on different displays using ubuntu -

we have application multiple windows on different screens using 3 graphic cards. each window uses opengl render fonts, images etc... works far, except sharing resources. tried implement (fenster custom class store information context, etc...): //a list of display names vector<string> displays; displays.push_back(":0.0"); displays.push_back(":0.1"); displays.push_back(":0.2"); displays.push_back(":0.3"); displays.push_back(":0.4"); //and loop them foreach(string dispname in displays): //dummy code static int dblbuf[] = {glx_rgba, glx_depth_size, 16, glx_doublebuffer, none}; display* disp; if(dispname != "default") disp = xopendisplay(dispname.c_str()); else disp = xopendisplay(null); if(disp == null) { cout << "error geting display " << dispname << endl; return null; } cout << "creating window on screen "<< dispname << endl; xvisual

Making own shell in C -

i'm trying make own shell in c, having trouble strtok. use correctly parse out command , arguments input, can't parse path (it segfaults). once path parsed correctly should able call execlp on each piece , fork processes accordingly. insight appreciated, code below. feel free comment on style choices if think there doing better. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> void parse(char *, char *); void process(char *, char *, int); int main(int argc, char *argv[]) { char *command; char *path; char buffer[1024]; command = (char *)malloc(sizeof(char)); path = (char *)malloc(sizeof(char)); int loop = 1; while(loop == 1){ path = getenv("mypath"); if(path == null) path = "/bin#."; printf("($mypath %s)\n", path); printf("myshell$ "); command = fgets(buffer, 1024, stdin); printf("buffer: %s", buffer); printf("c

indexing - iTunes store: App keyword search optimization. Strings intelligently indexed? -

does know how app keywords indexed against search terms in itunes store? keyword characters allowed in itunes connect limited, listing combinations of search terms becomes factorially large. app "foo bar" , "goo bar", people may commonly search "foobar" or "bar foo". sufficient enter: foo, bar, goo and hope itunes appropriate substring matching, or cover bases, should enter: foo bar, goo bar, foo, goo, bar, foobar, goobar, bar foo, bar goo, barfoo, bargoo can shed light on how intelligently search strings matched keywords? well, should include "foo", "bar", "goo" , "foobar" since "foo" , "bar" different "foobar". remember being told itunes uses old key word system. include single word in keywords , not "foo bar" , "goo bar" "foo", "bar", , "goo". makes sense? hope helped. :)

mysql - How can I add an implied year to a string which does not specify the year? -

i have download many text files website. have put mysql database, file has lines of form: 02/04 15:00 strings 03/03 15:00 other strings 01/12/2010 12:00 other strings 03/04 15:00 more strings ... when year not explicitly written, means current year. need parse file line line , convert every date of form dd/mm date of form dd/mm/yyyy (where yyyy current year of course) before put database. how can this? awk -v year=$(date +%y) 'match($1, "^[0-9][0-9]/[0-9][0-9]$") {$1 = $1"/"year} 1' or awk -v year=$(date +%y) 'split($1, a, "/") == 2 {$1 = $1"/"year} 1'

javascript - How do I fetch a single model in Backbone? -

i have clock model in backbone: var clock = backbone.model.extend({}); i'm trying instance of that has latest information /clocks/123 . things i've tried: a "class"-level method clock.fetch(123) // typeerror: object function (){ ... } has no method 'fetch' creating instance , calling fetch on it: c = new clock({id: 123}) c.fetch() // error: 'url' property or function must specified a collection i tried creating allclocks collection resource (even though have no use such thing on page): var allclocks = backbone.collection.extend({ model: clock, url: '/clocks/' }); var allclocks = new allclocks(); allclocks.fetch(123); // returns /clocks/ how one api-backed clock? your second approach approach have used. try adding following clock model: url : function() { var base = 'clocks'; if (this.isnew()) return base; return base + (base.charat(base.length - 1) == '/' ? '' : '/'

URL not working right in anchor tag -

i tried this: <a href="http://cgi.ebay.com/ws/ebayisapi.dll?viewitem&item=250778518281&sspagename=adme:b:ss:us:1123">test</a> but stops after first :s. know why? it show link for: s:us:1123">test i'm confused. :) working fine me, general rule, ensure query string parameters url encoded, e.g: http://cgi.ebay.com/ws/ebayisapi.dll?viewitem&item=250778518281&sspagename=adme%3ab%3ass%3aus%3a1123

PHP Curl Proxy, how to define $_FILES['foo']['name'] -

i'm using curl make php proxy forward multipart form. form have input type="file". the proxy receive following data: array 'foo' => array 'name' => string 'wt.jpg' (length=6) 'type' => string 'image/jpeg' (length=10) 'tmp_name' => string '/tmp/phpoivrak' (length=14) 'error' => int 0 'size' => int 7427 so i'm expecting page @ end receive same array (except tmp_name) right receive this: 'foo' => array 'name' => 'phpoivrak' 'type' => 'image/jpeg' 'tmp_name' => '/tmp/php5zhcwy' 'error' => 0 'size' => 7427 as can see, name tmp_name proxy receiving, original filename lost. here's php code: $arrfields = $_post; foreach($_files $k => $file) $arrfields[$k] = '@' . $file['tmp_name'] . ';t

iphone - Evaluate/compare NSString with wildcards? -

hi i'm trying evaluate nsstring see if fits criteria, contains wildcards in form of 1 or more asterix characters. example: nsstring *filepath = @"file://users/test/desktop/file.txt"; nsstring *matchcriteria = @"file://*/file.*"; i see if filepath matches (fits?) matchcriteria , in example does. know how can go doing this? many thanks! you can use nsregularexpression .

javascript - Inserting related data using SQLite with Blackberry Webworks -

i have blackberry webworks webapp running under bb5, storing data locally using sqlite database. database has 2 tables, event , flight, 1 event can have many flights associated it. i'm finding difficult work out how populate both tables array of data. trouble in getting foreign key insert flights table, due asynchronous way bb's sqlite implementation works. db.transaction(function(tx) { for(var = 0; < eventsarray.length; i++) { var insertid = 0; tx.executesql("insert event(id,eventname,venuename) values (?,?,?)", [null, eventsarray[i].eventname, eventsarray[i].venuename], function(tx,result) { //success callback insertid = result.insertid; //if try inserting flights here, eventsarray[i] returns //the last item in array, lo

swing - problem with loop- for: java -

i'm trying change code loop, have problems panel[1].setbackground(color.red); panel[2].setbackground(color.white); panel[3].setbackground(color.red); panel[4].setbackground(color.white); panel[5].setbackground(color.red); panel[6].setbackground(color.white); panel[7].setbackground(color.red); panel[8].setbackground(color.white); panel[9].setbackground(color.red); panel[10].setbackground(color.white); new code - for for (int = 0; < panel.length; i++) { panel[(i*2)+1].setbackground(color.red);//i think correct, or no? panel[(i*3)+1].setbackground(color.white); //problem here } thanks solution for (int = 1; < panel.length; i++) { if ( % 2 == 0 ) { panel[i].setbackground(color.white); } else { panel[i].setbackground(color.red); } } or more concise expression using ternary operator: for (int =

Python - Is there any way to get pip without setuptools? -

seems kinda weird they'd require package manager install package manager. i'm on windows btw. pip require setuptools. pip wrapper around setuptools provide better installer easy_install , nicer installation behaviors, plus uninstall, requirements files, etc. if somehow got pip installed without setuptools still won't run without it.

Test companies for development of apps on Facebook? -

i'd best practices facebook app development. while i've read can create test accounts visiting http://www.facebook.com/developers/become_test_account.php , there way create development companies? i'll doing app development work employer, prefer non-live test company test apps with. there other facets or recommendations aware of? thanks. turns out facebook app development pretty confusing one-sided process. can either own personal user account or business user account, not both. , both types of accounts not same thing. real user accounts can create real valid "pages" though users become fans of. test user accounts (via link provided in initial post) cannot create pages, however.

git - How to separate changes from master into another branch without overwriting history? -

recently have started implement new experimental feature project. unfortunately forgot branch before starting , pushed several commits onto shared repository server master branch. since other people may have checked commits out avoid overwriting history on server. due changes master unstable, not good. therefore revert changes made master, create separate branch contain these changes , still able reintroduce (merge) them master once stable enough. this answer uses command line tools , takes different approach managing branches. may less confusing using multiple resets of various flavors. the revert command in git 1.7.2 , later can revert multiple commits in 1 command: git revert last-stable.. this create revert commits each commit after last-stable to, , including, current head commit (in reverse order). if dealing many unwanted commits, may want revert them in single commit: git revert -n last-stable.. git commit # edit message explain reverting multiple commi

zoom - Android Gallary -

i trying implement image gallery zoom in , zoom out facilities on every images. for have extended imageview , added zoom in zoom out mechanism it, in adapter class return own imageview. unfortunately not working current gallery widget. my image view skeleton this public class myimageview extends imageview implements ontouchlistener{} my adapter class code simple use imageview instead of original one. zoom in zoom out in imageview works fine without gallery not gallery. any, advice?

Hibernate, Oracle, Sequence and One To Many Problem -

i having issue doing 1 line save on 1 many object. foreign key not populated in child objects. aren't suppose automatically hibernate? badgeid never gets inserted badgelevel.badgeid. badge.java @basic @id @generatedvalue(strategy=generationtype.sequence, generator="badge_sequence") @sequencegenerator(name="badge_sequence", sequencename = "badge_sequence") @column(name = "id", nullable=false, unique=true) public long getid() { return id; } @onetomany(mappedby="badge", fetch=fetchtype.eager, cascade=cascadetype.all) @fetch(value=fetchmode.select) public list<badgelevel> getbadgelevels() { return this.badgelevels; } badgelevel.java @basic @id @notnull @generatedvalue(strategy=generationtype.sequence, generator="badgelevel_sequence") @sequencegenerator(name="badgelevel_sequence", sequencename = "badgelevel_sequence") @column(name = "id", nullable=false, unique=true

python - Why is the "file" command get confused on .py files? -

i have several python modules i've written. randomly, used file on directory, , surprised saw. here's resulting count of thought files were: 1 ascii java program text, long lines 1 /bin/env python script text executable 1 python script text executable 2 ascii c++ program text 4 ascii english text 18 ascii java program text that's strange! idea what's going on or why seems think python modules java files? i'm using centos 5.2. edit question more geared towards curiosity on why non-java , non-c++ program file being classified such. don't expect file perfect, surprised on choices being made. have guessed give , text file rather making incorrect inferences. from file man page file tests each argument in attempt classify it. there 3 sets of tests, performed in order: filesystem tests, magic number tests, , language tests. first test succeeds causes file type printed. my guess of files happen match tests different langua

How to set an image based on iphone platform in objective-c -

i'm moving application 3.x 4.x prepare app store , found need have 2 copies of custom pngs - question how can determine img show , when. example - how know show find.png vs find@2x.png is "safe" or "correct" 4.x specific apis or iphone have way determine platform on @ runtime? thank in advance when use standard apis, phone handles grabbing @2x version when necessary. example if use [uiimage imagenamed:@"find.png"]; , run on iphone 4, load find@2x.png automatically.

javascript - Date formatting incoming RSS feed best practice -

i importing rss feed wordpress blog , data coming in okay part although formatting on date bit more need sun, 20 feb 2011 07:43:06 -0800 ot display february 20th, 2011 using google feed api parse feed. , input appreciated. the date.js library can out here: date.parse( str ).tostring('mmmm dds, yyyy') where str data rss feed. live demo: http://jsfiddle.net/xzfpc/

sorting - Is there a partial sort command for tcl? -

as c++'s std::partial_sort do. lsort not powerful enough. there no built-in equivalent partial_sort . think choices either implement hand in tcl, undermine whatever efficiency sought gain; or write extension exposes partial_sort interpreter. wouldn't difficult -- tcl extensions pretty easy write. here's bit of code whipped should started: #include <algorithm> #include "tcl.h" using namespace std; static int partialsortcommand(clientdata dummy, tcl_interp *interp, int objc, tcl_obj *const objv[]); extern int partialsort_init(tcl_interp *interp) { if (tcl_initstubs(interp, "8.0", 0) == null) { return tcl_error; } if (tcl_pkgprovide(interp, "partialsort", "1.0") != tcl_ok) { return tcl_error; } tcl_createobjcommand(interp, "partialsort", partialsortcommand, (clientdata) null, (tcl_cmddeleteproc *) null); return tcl_ok; }

python - Google App Engine: how to tell sort location for a user value? -

in main model have total_value , sort value. when user enters value wish tell user order of total_value . how do this? in other words, if total_value s in database 5,8,10,25 , user enters total_value of 15 how tell him in 4th place? thanks! you need write query counts number of values smaller user's total_value . may slow if there many main entities. in case, may wish count first n values smaller, , stop (e.g., tell user ranked 1000+). query might this: # rank of total_value compared existing total_values (up 1,000) rank = main.all().filter('total_value <', total_value).count(1000) + 1

Codeigniter Image upload -

where can find tutorial concept uploading image , save image path in database user id , delete function. thanks! here concept form +--------+ +------------+ | avatar | | | browse +--------+ +------------+ +----------+ | | name +----------+ +----------+ | | age +----------+ +----------+ | | address +----------+ +----------+ | submit | +----------+ here 1 upload, database , delete should easy there http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-file-uploading-and-image-manipulation/ also review codeigniter pages subject also of note codeigniter: image upload edit---------------------------------------- i assuming listing images in table edit or delete them. way off base doing. assuming while use "user id" assign id image itself. for deletions this $this->table->set_heading('date', 'title', 'delete', 'update'); foreach($records $row){ $row-&g

java - While loop help -

i have project class have ask user input body mass index , body surface area calculator. have if else statement need put in while-loop. need have go through , if user enters 'w' bring weight variable , 'h' height. if user enters 'q' quit program. need on how create while loop. import java.util.*; public class assignment2 { public static void main(string[] args) { //scanner scanner stdin = new scanner(system.in); //variables final double meters_to_cm = 100; // constant convert meters centimeters final double bsa_constant = 3600; // constant divide bsa double bmi; // body mass index double weight; // weight in kilograms double height; // height in meters string classification; // classifies user bmi categories double bsa; // body surface area char quit = stdin.nextline().charat(0); system.out.print(&q

backbone.js - triggering events in multiple views -

i'm putting app using backbone.js, has 2 views right now, indexview , quizpartial. indexview renders bulk of page (some graphs , whatnot), , contains many quizpartials. issue when user clicks 'delete' link in 1 of partials, partial should deleted , appropriate model destroyed, while indexview renders button create new quiz. however, can't indexview respond event. code: class quizpartial extends backbone.view tagname: "div" classname: "quiz" events: "click a.delete": "delete_quiz" # works fine initialize: -> @render() delete_quiz: -> if confirm "are sure want delete test?" $(@el).remove() @model.destroy() false and index view: class indexview extends backbone.view tagname: "div" id: "quizzes_index" events: "click .quiz a.delete": "render_new_quiz_button" # never fires initialize: -> @render() # etc... is ther