Posts

Showing posts from February, 2012

comparison - Comparing two functions in JavaScript -

i'm developing mobile app wife's 1st grade class can practice sight words. i'm novice javascript able pull off first objective take javascript array , extract random word it. second objective have user type in word see, click button , have word entered compared random word. attempted second function did not it. don't errors in console i'm bit lost on how working. appreciated me , great group of 1st graders. here code have far. <!doctype html> <html> <body> <h1>practice spelling test</h1> <p id="aword"></p> <input id="yourturn"> <button onclick="myfunction()">new word</button> <button onclick="checkspelling()">check spelling</button> <p id="result"></p> <script> var sightword = ["hoof", "hook", "shook", "hood", "wood", "took", "book", "good"

php - Can CodeIgniter Helper Functions use database functions? -

one of codeigniter controller functions needs call recursive function part of functionality. function call chokes if put inside controller class, , can't access database functions ($this->db->get()) if put outside class. making helper function fix problem? you can instance: $ci =& get_instance(); after able use $ci->db queries..

scala alternative for using index variable -

suppose have matrix, has basis column , non-basis column. , need ability obtain basis part of matrix or non-basis. colums bases specified in array declared var base: array[boolean] currently i'm doing like: def getmatrix(matrix: densematrix[double], pred: boolean, m: int, n: int): densematrix[double] = { var = densematrix.zeros[double](m, n) var scanpos: int = 0 var insertpos: int = 0 (el <- base) { if (el == pred) { a(::, insertpos) := matrix(::, scanpos) insertpos += 1 } scanpos += 1 } return } but code ugly , hate it. there must more elegant solution , i'm asking it ps: densematrix class breeze library , may considered 2-d array i'm not sure if breeze offers better way this, this: def getmatrix(matrix: densematrix[double], pred: boolean, m: int, n: int): densematrix[double] = { val data = base .zipwithindex .filter(_._1 == pred) .map(b => matrix(::, b._2).

php - Let only registered users download from my Amazon S3 bucket -

i'm building php website keep content files on amazon s3. website files (with php code) hosted on traditional server. users register on website , after registering , logging in have access files on s3. the question is, how let logged in users download files , prevent else downloading? aws iam have involved somehow? i don't want expiring urls. want give access files specific user , don't want them share link else period of time. in future want limit access files registered users - depending on type of user account user have access different files. thx in advance replies! this can done... use ror instead of php application controls access data in s3 bucket. have buckets app can access , file access limited credentials in app. make sense? i have public bucket store assets (publicly available images) , bucket application can access. users in application can access bits of bucket based on credentials. the database stores reference exact s3 file / lo

python - Is it possible to insert a row at an arbitrary position in a dataframe using pandas? -

i have dataframe object similar one: onset length 1 2.215 1.3 2 23.107 1.3 3 41.815 1.3 4 61.606 1.3 ... what insert row @ position specified index value , update following indices accordingly. e.g.: onset length 1 2.215 1.3 2 23.107 1.3 3 30.000 1.3 # new row 4 41.815 1.3 5 61.606 1.3 ... what best way this? you slice , use concat want. line = dataframe({"onset": 30.0, "length": 1.3}, index=[3]) df2 = concat([df.ix[:2], line, df.ix[3:]]).reset_index(drop=true) this produce dataframe in example output. far i'm aware, concat best method achieve insert type operation in pandas, admittedly i'm no means pandas expert.

postgresql - SQL: Unique constraint when column is a certain value -

create table foo ( dt date not null, type text not null, constraint unique_dt_type unique(dt,type) -- check constraint(?) ) having brain-dud when trying think of right syntax create unique constraint when condition exists. given, type can have values a-f , there can 1 a per date, there can multiple b-f . example of table: 2010-01-02 | 'a' -- 1 2010-01-02 | 'b' -- can have multiple 2010-01-02 | 'b' 2010-01-02 | 'b' 2010-01-02 | 'c' -- can have multiple 2013-01-02 | 'a' -- 1 2010-01-02 | 'b' -- can have multiple 2010-01-02 | 'b' 2013-01-02 | 'f' -- can have multiple 2013-01-02 | 'f' tried reading check/unique syntax there weren't examples. check came close limited range , wasn't used in conjunction unique scenario. tried searching, search skills either not par, or there aren't similar questions. postgresql can address needs via it's "partial

html - Add tooltip tail to a CSS dropdown menu? -

Image
i dropdown menu have tooltip tail under each dropdown. css dropdown tutorial easy, can't figure out how add arrow. see jsfiddle html <nav> <ul> <li><a href="#">home</a></li> <li><a href="#">tutorials</a> <ul> <li><a href="#">photoshop</a></li> <li><a href="#">illustrator</a></li> <li><a href="#">web design</a> <ul> <li><a href="#">html</a></li> <li><a href="#">css</a></li> </ul> </li> </ul> </li> <li><a href="#">articles</a> <ul> <li><a href="#">web design</a

visual studio 2010 - If a radiobutton is checked,then use the hidden password characters -

i wondering if possible like: if "radiobutton1" checked, have display text in "textbox2.text" password characters. is possible? use usesystempasswordchar property: textbox2.usesystempasswordchar = (radiobutton1.checked);

ruby on rails - Routing Resources Doesn't Set up Routing Properly -

normally expect resources set routes where /groups/:id however, when call rake routes get get /groups(.:format) groups#show also, whenever use view helper method groups_path(group.id) provides url link as /groups.1 finally in routing file resource :groups this case edit, update, , destroy actions well. finally, doesn't produce index action. have create after write resources method. what's wrong , how fix this? pluralize resource: resources :groups

javascript - Ajax function not working in any of IE version -

//ajax functions <script language="javascript"> function ajaxfunction(item) { var type; try { type = new xmlhttprequest(); } catch (f) { try { //xmlhttp=new activexobject("msxml2.xmlhttp"); type = new activexobject("msxml2.xmlhttp"); } catch (f) { try { type = new activexobject("microsoft.xmlhttp"); } catch (f) { alert("your browser not support ajax!"); return false; } } } type.onreadystatechange = function () { if (type.readystate == 4) { document.getelementbyid('type_div').innerhtml = type.responsetext; } } type.open("post", 'get_type.php?f=' + item, true); type.send(null); } < /script>

c++ - How can you initialize an object from a variables value? -

i generate name of initialized object getting user input. possible? there way name object based on variables value? i know in code below "test x" doesn't work , know why... there way work? have been trying figure out 2 days now. closest thing came maybe stringstreams... or worse... isn't possible? help? #include <iostream> using namespace std; #include <string> class test { public: string wtf; }; int main() { test y; // showing normal initialize y.wtf = "a"; // assign value string x; cin >> x; // initialize string , input test x // trying initialize object based on input x.wtf = "a"; // assign value cout << y.wtf; // printing both test cout << x.wtf; return 0; } my intent have single array holds employee numbers (concatenated "emp" or in beginning) initiate objects each employee. user input employee number, 1234, ,

asp.net mvc - orchard - click on screen and will display widget etc -

i remember seeing in tutorial cant remember how access it. using orchard can d/l moudles/gallary when viewing website can select anywhere on screen , tell widget , layer on (on bottom of screen) was designer tools? yes. enable shape tracing feature designer tools module. see http://docs.orchardproject.net/documentation/customizing-orchard-using-designer-helper-tools details.

postgresql - SQL: Typecast in a Unique Index -

create table foo ( dt date, ts timestamp ); what's proper way create unique constraint date value of ts occurs once per dt ; example: dt | ts 2010-01-02 | 2010-01-02 17:19:08 2010-01-02 | 2011-11-11 01:01:01 2010-01-02 | 2011-11-11 17:19:08 -- error on insert (already 2011-11-11) attempt: invalid syntax, i'm trying achieve: create unique index unique_tsdate_per_dt on foo(dt,ts::date); incomplete attempt - possibly subquery? create unique index unique_tsdate_per_dt on foo(dt) ts::date -- ? i think you're looking function form of ::date cast: create unique index unique_tsdate_per_dt on foo(dt, date(ts)); then you'll results this: => insert foo (dt, ts) values ('2010-01-02', '2010-01-02 17:19:08'); => insert foo (dt, ts) values ('2010-01-02', '2011-11-11 01:01:01'); => insert foo (dt, ts) values ('2010-01-02', '2011-11-11 17:19:08'); error: duplicate key value viol

linux - setgid bit not preserved by git on new directory in `.git` folder? -

i have bare git repository setup user fred : /home/fred/foo.git i have set group of every file in foo.git bar : $ chown -r fred:bar /home/fred/foo.git (note fred not member of group bar ) and have set setgid bit on every directory in foo.git : $ find foo.git -type d -print0 | xargs -0 chmod g+s however when fred commits git repository, group not preserved in files. specifically in objects directory see: foo.git/objects: drwxrws--- 46 fred bar 4096 apr 7 23:43 . drwxrws--- 7 fred bar 4096 apr 6 17:12 .. drwxrws--- 2 fred bar 4096 apr 6 17:11 07 drwxrws--- 2 fred bar 4096 apr 6 17:11 10 drwxrwx--- 2 fred bar 4096 apr 7 22:14 14 <--- here drwxrws--- 2 fred bar 4096 apr 6 17:11 17 ^--- here notice in objects/14 setgid bit not set. consequently when new object added directory: foo.git/objects/14: drwxrwx--- 2 fred bar 4096 apr 7 22:14 . drwxrws--- 46 fred bar 4096 apr 7 23:43 .. -r--r----- 1 fred fred 2595 apr 7 22:14 95482f8..

cookies - recall form value not working for textareas -

im trying modify script http://www.dynamicdrive.com/dynamicindex16/formremember2.htm to work textareas, , not input text boxes. heres im guessing relevant parts of script, cant figure out myself rememberform.prototype.savevalues=function(){ //get form values , store in cookie (var i=0; i<this.fields.length; i++){ if (this.fields[i].type=="text") this.cookiestr+=this.fields[i].fname+":"+escape(this.fields[i].value)+"#" } if (typeof this.togglebox!="undefined"){ //if "remember values checkbox" defined this.persistdays=(this.togglebox.checked)? this.persistdays : -1 //decide whether save form values this.cookiestr=(this.togglebox.checked)? this.cookiestr+"toggleboxid:on;" : this.cookiestr } else //if checkbox isn't defined, remove final "#" cookie string this.cookiestr=this.cookiestr.substr(0, this.cookiestr.length-1)+";" setcookie(this.cookiename, this.cookiestr, this.persistdays) }

php - mysql multiple unique keys with on duplicate key reference -

i have table structure id,f1,f2,f3,f4 id primary key , f1 , f3 unique keys my question when use on duplicate key update which key considering valuation consider query insert t1 (f1,f2,f4) values (.....) on duplicate key update f4=...." as shown above consider key f1 ? or f3 or id and if have query this insert t1 (f1,f2,f3,f4) values (.....) on duplicate key update f4=...." what key consider ? thanks guys :) from mysql manual , emphasis mine: if specify on duplicate key update, , row inserted cause duplicate value in unique index or primary key , update of old row performed. an insert attempt cause duplicate unique constraint on table cause alternative action triggered. note advised (in general) not use on duplicate key syntax tables contain multiple unique indexes: in general, should try avoid using on duplicate key update clause on tables multiple unique indexes.

resharper - Disable VS 2010 format on paste for razor but not c# -

i'd use resharper formatting razor in vs 2010. (because vs indents incorrectly) want disable vs format on paste razor still format on paste on in c# files. is possible? (is possible in vs2012) note: can disable c# and razor setting: tools > options > text editor > c# > formatting > [uncheck] automatically format on paste can't disable razor, perhaps there's extension? or way have resharper take control? try going tools | options -> text editor | html | miscellaneous , turning off format html on paste . haven't tried myself, may work.

hadoop - Is there a better way of handling static columns than grouping in Pig? -

i have lot of denormalized data need calculations on. there's 28 columns, 1 of id column, 5 of need sum, , rest of need report. 22 of these columns same single id. i'm grouping on 23 columns , summing 5. seems me has undue overhead. there better way handle it? here's script after initial load: grouped = group inputdata (site_id_col, meta_id_col, item_id_col, seller_id_col, category1_col, category2_col, total_watch_col, item_title_col, auct_type_col, currency_col, item_price_col, shipping_type_col, shipping_fee_col, start_date_col, total_qty_col, qty_avail_col, status_id_col, auct_duration_col, end_date_col, login_atol_col, login_latest_col); filtered = foreach grouped generate flatten(group), sum(inputdata.impression_col), sum(inputdata.click_col), sum(inputdata.bidcount_col), sum(inputdata.qty_sold_col), sum(inputdata.ck_trans_col), sum(inputdata.gmv_col); store filtered 'output/'; so, whether or not faster depen

compiler construction - undefined reference to ruserok error -

i've run strange "undefined reference to" compile error cannot seem find resolution for. i'm trying configure/compile pam 1.1.6 gumstix overo using yocto project generated arm compiler (arm-poky-linux-gnueabi-gcc), keep getting following error during compilation: .libs/pam_rhosts.o: in function `pam_sm_authenticate': modules/pam_rhosts/pam_rhosts.c:117: undefined reference `ruserok' collect2: error: ld returned 1 exit status so, did investigating , found out during configure, following test code compiled , executed determine availability of ruserok, ruserok_af , iruserok. /* end confdefs.h. */ /* define $2 innocuous variant, in case <limits.h> declares $2. example, hp-ux 11i <limits.h> declares gettimeofday. */ #define $2 innocuous_$2 /* system header define __stub macros , few prototypes, can conflict char $2 (); below. prefer <limits.h> <assert.h> if __stdc__ defined, since <limits.h> exists on frees

jquery - Randomly Rotate PHP files in sidebar on page refresh -

i have 4 php files have small php , jquery game inside. the files follows: /game1.php /game2.php /game3.php /game4.php every time page refreshed want 1 of games show in sidebar. when page refreshed again, different game , so. is there way include files in sidebar @ random via kind of query on page refresh, if so, please me code. thanks! $games = array('game1.php','game2.php','game3.php','game4.php'); session_start(); $used = array(); if (isset($_session['used'])){ $used = $_session['used']; } $usable = array_diff($games,$used); if (sizeof($usable)==0){ $usable = $games; $_session['used'] = array(); } $inuse = $usable[array_rand($usable)]; $_session['used'][] = $inuse; include($inuse);

multithreading - Qt slot simultaneous disconnect and call from different theads -

i'm newbie qt. haven't found answer in reasonable time , decided ask here. i have thread, let's call thread1 qt object have connected slot. signal emitted same thread ( thread1 ). , i'm disconnecting slot thread2 . is operation thread safe? there problems, if signal emitted , slot disconnected @ same time? just looking @ docs, looks safe me: http://qt-project.org/doc/qt-4.8/qobject.html note: functions in class reentrant, connect(), connect(), disconnect(), , disconnect() thread-safe. http://qt-project.org/doc/qt-4.8/qobject.html#disconnect note: function thread-safe. also make sure using queued connections when connecting signal of 1 thread slot of another. auto-connect may misbehave (and direct connection) if both objects happen in same thread during time of connection. hope helps. edit: more thread safety: http://qt-project.org/doc/qt-4.8/threads-reentrancy.html http://qt-project.org/doc/qt-4.8/threads-qobject.html

c++ - Passing vector by reference -

using normal c arrays i'd that: void do_something(int el, int **arr) { *arr[0] = el; // else } now, want replace standard array vector, , achieve same results here: void do_something(int el, std::vector<int> **arr) { *arr.push_front(el); // function above } but displays "expression must have class type". how properly? you can pass container reference in order modify in function. other answers haven’t addressed std::vector not have push_front member function. can use insert() member function on vector o(n) insertion: void do_something(int el, std::vector<int> &arr){ arr.insert(arr.begin(), el); } or use std::deque instead amortised o(1) insertion: void do_something(int el, std::deque<int> &arr){ arr.push_front(el); }

Use 8 individual border images instead of border-image in CSS -

i've been provided 8 individual images (top left, top, top right etc) border around main (fixed width) content box. if given single image, i'd use border-image . what's best way use 8 images? divs absolute positioning? or such pain should combine them one? what's hard combining images one? has numerous other advantages, reducing number of http requests client needs make, example. an alternative use css3's multiple background image feature, you'd set each image layer in box.

regex - Why does capturing named groups in Ruby result in "undefined local variable or method" errors? -

i having trouble named captures in regular expressions in ruby 2.0. have string variable , interpolated regular expression: str = "hello world" re = /\w+/ /(?<greeting>#{re})/ =~ str greeting it raises following exception: prova.rb:4:in <main>': undefined local variable or method greeting' main:object (nameerror) shell returned 1 however, interpolated expression works without named captures. example: /(#{re})/ =~ str $1 # => "hello" named captures must use literals you encountering limitations of ruby's regular expression library. regexp#=~ method limits named captures follows: the assignment not occur if regexp not literal. a regexp interpolation, #{} , disables assignment. the assignment not occur if regexp placed on right hand side. you'll need decide whether want named captures or interpolation in regular expressions. cannot have both.

How to I copy an existing Xamarin Sudio iTouch project to a different folder? -

i have existing xamarin studio itouch ios project named doctorregistration2012. want copy project , call doctorregistration2013. want open copied project in xamarin studio , continue develop. how can done quickly? you can copy directory origin project lives in, name new directory whatever want, , if open .sln solution file in new directory in xamarin studio should fine. you can rename solution right mouse clicking on solution in solution explorer , select "rename." please let me know if i'm misunderstanding something!

haskell - How do I terminate a socket server in ghci? -

i wrote webserver with, say, webserver package, , can start in ghci with: :main localhost 8000 if ctrl-c , run again, get *** exception: bind: resource busy (address in use) so socket seems bound ghci session. how can free port binding can :reload , start again without quitting ghci? this happens if underlying server implementation not set reuse_addr option on socket. usually if terminate server abruptly, operating system keeps server's old port in 2msl state couple of minutes in order prevent new servers on port accidentally receiving old messages intended previous connection. if set reuse_addr when attempting bind port, specify wish forcefully reuse before 2msl period over. the way can fix modify code underlying web server using set reuse_addr option before binding listening socket.

Lua - SQLite3 isn't inserting rows into its database -

i'm trying build expense app android phones, , need way display expenses. plan (for current step) allow user view expenses. want show calendar-like screen, , if there @ least 1 expense day, use different color button. my problem in inserting information sqlite3 table. here code: require "sqlite3" --create path local path = system.pathforfile("expenses.sqlite", system.documentsdirectory ) file = io.open( path, "r" ) if( file == nil )then -- doesn't exist, copy in resource directory pathsource = system.pathforfile( "expenses.sqlite", system.resourcedirectory ) filesource = io.open( pathsource, "r" ) contentssource = filesource:read( "*a" ) --write destination file in documents directory pathdest = system.pathforfile( "expenses.sqlite", system.documentsdirectory )

How to find specific rows in csv document in python -

what i'm trying read csv document , find values in sn column > 20 , make new file rows sn > 20. i know need do: read original file open new file iterate on rows of original file what i've been able find rows have value of sn > 20 import csv import os os.chdir("c:\users\robert\documents\qwe") open("gdweights_feh_robert_cmr.csv",'rb') f: reader = csv.reader(f, delimiter= ',') zerovar = 0 row in reader: if zerovar==0: zerovar = zerovar + 1 else: sn = row [11] zerovar = zerovar + 1 x = float(sn) if x > 20: print x so question how take rows sn > 20 , turn new file? save data in list, write list file. import csv import os os.chdir(r"c:\users\robert\documents\qwe") output_ary = [] open("gdweights_feh_robert_cmr.csv",'rb') f: reader = csv.reader(f, delimiter= ','

jquery - Automatically reload a page after uploading a file -

Image
following answers on post able produce satisfactory job. it's perfect. i'm trying make kind of warning panel loading news txt file on dropbox public folder. update file , content shown on page. i have 2 files produce result. important codes are: pag01.html load file avisos.html use format contents data file containing updated news. <div id="quadro" class="avisos"> <script> var url = 'https://dl.dropbox.com/u/42709342/avisos.html'; // 3. ok got data function afterreadfromdropbox(data) { $('#quadro').html(data); } // 2. ok document ready, lets grab data dropbox function whendocumentisready(){ $.get(url, afterreadfromdropbox ); } // 1. when document ready make call $(document).ready( whendocumentisready ); </script> </div> avisos.html just load data file avisos dropbox public folder. <div id="avisosmsg" class="avisosmsg"> <script> var url = 'https://dl.drop

css - Susy Compass omega is adding #margin-left: -1em; -

i using susy framework create grid website , liking it. can't figure out why #margin-left: -1em being added when use omega in span columns. cannot seem find information , throws error when validate css: .second parse error #margin-left: -1em; my code looks below //this default number of columns $total-columns: 12; //width of each column $column-width : 4em; //space between columns $gutter-width : 1em; //space on right , left of grid $grid-padding : $gutter-width; .first{ @include span-columns(6,12); } .second{ @include span-columns(6 omega,12); } and generates this .first { width: 49.15254%; float: left; margin-right: 1.69492%; display: inline; } .second { width: 49.15254%; float: right; margin-right: 0; #margin-left: -1em; display: inline; } your code compiles fine me compass. line in question has asterisk, not hashmark: *margin-left: -1em; a line of css starts asterisk hack works ie <= 7. to disable

jquery - Getting all options in a select element -

i have select element user can add , remove options. when user done click save cannot figure out how options select. have found jquery selected need of them. tried this: var str = ""; $("#wordlist").each(function () { str += $(this).text() + ","; }); alert(str); but concatenates option 1 long string ends in comma. that code says on box. expect have used $("#wordlist option") options. guessing if options "this", "that" , "the other" got thisthatthe other, , code (that text inside #wordlist element, includes options inside element. array performing .each() on has single element: "thisthatthe other", iterate on once , add comma). you want concatenate text of each of options in #wordlist (i think), try var str = ""; $("#wordlist option").each(function () { str += $(this).text() + ","; }); alert(str); to give string

asp.net mvc - How to submit @using (Html.BeginForm()) and submit its content to controller -

i'm trying send 6 values 6 different text boxes controller. how can without using javascript? @using (html.beginform("save", "admin")) { @html.textbox(valueregular.tostring(format), new { @name = "pricevalueregularlunch" }) @html.textbox(valueregular1.tostring(format), new { @name = "pricevalueregularlunch1" }) @html.textbox(valueregular2.tostring(format), new { @name = "pricevalueregularlunch2" }) <input type="submit" name="savebutton" value="save" /> } [httppost] public actionresult saveprices(int pricevalueregularlunch) { return redirecttoaction("lunch", "home"); } here's controller should like: public class admincontroller : controller { [httppost] public actionresult saveprices(int pricevalueregularlunch, int pricevalueregularlunch1, int pricevalueregularlunch2,

compiler construction - Compile an 8xk program for TI-84 Plus Silver Edition Calculators -

i interested in writing own app ti-84 plus silver edition calculator (not program using calculator's built in language). know of compiler .8xk files, file extension ti-84 apps use? also, provide me sample code app show how hard make one? have no idea language used, , want know. the easiest way write flash application use ti-basic + basic builder alternatively, can take dive z80 assembly , though learning curve steep. here example assembly learning z80 assembly in 28 days . ld hl, (stack_ptr) ; load stack pointer ld (hl), e ; push low-order byte inc hl ; move stack pointer next byte of available space ld (hl), d ; push high-order byte inc hl ld (stack_ptr), hl ; save new stack pointer if speed of assembly ease of basic, there several asm libraries ( xlib example) available, i'm not sure how work flash apps. you might axe , programming language near-assembly speeds.

iphone - How do you solve TabBarController view position problems? -

Image
i'm using storyboard. hierarchy follows: uinavigationcontroller uiviewcontroller contianer view uipageviewcontroller container view uitabbarcontroller uiviewcontroller containerview uiviewcontroller (with date , fields) uilabel my problem last view controller's view positioned incorrectly; appears if placed 20 pixels below should be. have no clue can , i've searched online might me out. here image of prototype looks right now: here image of storyboard file:

php - extending PDO as CodeIgniter library -

i know ci 2.1.3 support pdo. it'll more comfortable me using pdo functions instead of codeigniter function, , want extend pdo , use library , create pdo object once loaded controller or library; possible, isn't it?, attempt far: class mypdo extends pdo { public function __construct($dsn='mysql:dbname=mydbname;host=localhost', $username='myusername', $password='mypassword', $driver_options=array()) { parent::__construct($dsn, $username, $password, $driver_options); } } and simple usage: class otherlibrary{ var $ci; var $something_id; public function __construct(){ $this->ci =& get_instance(); $this->ci->load->library('mypdo'); $this->something_id = 'foo'; } public function is_something_exist(){ try{ $q = "select * something_id = '$this->something_id

osx - Is there a way to indicate anything done on Mac OS X across processes in the same way as named mutex in Windows? -

this question has answer here: ideal way single-instance apps on mac 5 answers hypothetically have created several applications on mac os x use 1 shared resource or service. in applications want check if service or resource created in same way named mutex being used on windows in order not create everywhere. what's best way in cocoa? if wish control access shared resource common unix/os x may create & lock file - file can 0 bytes long. the system-level way of doing use flock (manual pages section 2), c-level way use stdio flockfile (manual pages section 3), think framework-level ways have been deprecated might wrong (apple appears in process of changing how filesystem operations supported has deprecated before supplying replacements). note : file locking not same finder-level locking - former gives mutex, latter preventing modification.

java - Wicket: Using a editable Inline-label inside a ListView and update a model after change this label value -

i need use editable label or inline-label in listview , after change value of component want know how can update property of object displayed in listview add(new listview[someobject]("listsomeobject", listdata) { override protected def onbeforerender() { ... super.onbeforerender() } def populateitem(item: listitem[someobject]) = { var objvalue = item.getmodelobject() item.add(new label("total", objvalue.tostring(getformatter()))) } } }) in code above, object someobject has property called total, listview shows set of someobject, when label total changed in line of listview corresponding object someobject should updated new value of label total. someone can provide useful example me task? thanks you should use model display property. example propertymodel. method getobject() called on display. propertymodel call getter selected property. can have object have getter retrieves formatted value intere

How to deploy ambari for an existing hadoop cluster -

as mention in title, can skip step of install hadoop cluster cluster exist , in service? ambari relies on 'stack' definitions describe services hadoop cluster consists of. hortonworks defined custom ambari stack, called hdp. you define own stack , use services , respective versions wanted. see ambari wiki more information defining stacks , services. that being said, don't think it's possible use pre-existing installation of hadoop ambari. ambari used provision , manage hadoop clusters. keeps track of state of each of stacks services, , states of each services components. since cluster provisioned difficult (maybe impossible) add ambari instance.

jquery - tab panel like stackoverflow -

i wondering last 2 days, how implement tab pannel stackoverflow eg. https://stackoverflow.com/ (tag question pannel: interesting,feature,hot....) i server-side developer(java), have no experience web design. , need type of tab panel personal works. i tried search in google not found similar stackoverflow.com. though found this tab pannel ,but don't know how source code. please help,if know similar link source code or have suggestions here options you: http://jqueryui.com/tabs/ http://twitter.github.io/bootstrap/javascript.html#tabs http://os.alfajango.com/easytabs/ they open source , easy download. come example code. they customizable styling too. here example using easytabs styling such want: http://jsfiddle.net/hh95r/ take particular note of css .tabs , .tabs:hover adds border.

php - Changing table background color through AJAX jquery? (ASK) -

before ask problem changing table background color through ajax jquery? i can change background color. got problem mirror <input id="cek" name="cek" type="text" /> always got value 0. bcakground color cann't change green. does logic correct? best methode problem? please advice you this: $("#cek").css("background-color", "red");

GDB scripting - execute command only if not debugging core file -

i'm adding features find useful gdb startup script. few of startup commands apply "live" targets, or have components make sense live targets. i'd able test presence (or absence) of core file, , skip or amend these commands appropriate. i looked around in python api, couldn't find tells me whether inferior core file or live program. i'm fine scripting solution works in either gdb or in python gdb scripting interface. it doesn't there way that. i'd expect attribute on gdb.inferior , there isn't one . file feature request in gdb bugzilla .

javascript - JQuery Ascensor JS Plugin Not Working -

i trying build single-page scrolling website leveraging ascensor jquery plugin, , having lot of trouble getting setup correctly. documentation @ http://kirkas.ch/ascensor/ helpful, still must missing something. want simple 3-floor layout, top bottom. seems layout of "building" gets generated correctly, unable move between "levels." arrow keys , links don't move page @ all. can little code? guidance appreciated. thanks, brett <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>ascensor test</title> <script src="jquery-1.9.1.js"></script> <script src="jquery.scrollto-1.4.3.1.js"></script> <script src="jquery.ascensor.js"

c# - How to read tables from a particular place in a document? -

when use below line reads tables of particular document: foreach (microsoft.office.interop.word.table tablecontent in document.tables) but want read tables of particular content example 1 identifier identifier. identifier can in form of [srs oraganisation_123] identifier [srs oraganisation_456] i want read tables in between above mentioned identifiers. suppose 34th page contains identifier want read tables point until come across second identifier. don't want read remaining tables. please ask me clarification in question. say start , end identifiers stored in variables called mystartidentifier , myendidentifier - range myrange = doc.range(); int itagstartidx = 0; int itagendidx = 0; if (myrange.find.execute(mystartidentifier)) itagstartidx = myrange.start; myrange = doc.range(); if (myrange.find.execute(myendidentifier)) itagendidx = myrange.start; foreach (table tbl in doc.range(itagstartidx,itagend

java - how to count frequency for a 2d array -

hi im trying count frequency of 2d array . trying display frequency in way example if table : 0: 1 2 0 1: 2 0 1 2: 1 0 2 i want able count frequency : 0: 0 2 1 1: 2 0 1 2: 1 1 1 so way table should how many times 0 has appeared in first column , how many times 1 has appears in first column , on. the code have far (int t = 0; t<s;t++) { int count= 0 ; (int p = 0; p<s; p++) { if(table[p][t] ==p ) { count++ } else if(t+1 != s) continue; else table[p][t] = count; count = 0; } } thanks for each column, make hashmap<int, int> . key entry, value frequency in column, e.g. column: 1) iterate on elements of column 2) every element of column, if exists in hashmap key already, value, increment 1 , add new value under same

drupal 7 - User registration form change Username to name -

i want change label of registration form 'username' name. had used 'string overrides' module. not effecting. there way out. please me out. implement custom module , alter registration form. /** * implements hook_form_form_id_alter(). */ function mymodule_form_user_register_form_alter(&$form, &$form_state) { $form['account']['name']['#title'] = 'your replaced value'; //username default } mymodule custom module name.

javascript - how to sync a device calendar for event addition using phonegap -

i developing phone gap project calendar. need add reminder , event( whatever process done in device calendar). looking sync process of device calendar both iphone , android using phone gap. new field, please guide me programming steps of examples. thanks in advance. you need use javascript api access calendar on target device. although phonegap not provide standard calendar api ( http://docs.phonegap.com/en/2.5.0/index.html ), there community plug-ins have been created phonegap calendar plug-in android: https://github.com/phonegap/phonegap-plugins/tree/master/android/calendarplugin phonegap calendar plug-in ios: https://github.com/phonegap/phonegap-plugins/tree/master/ios/calendarplugin

javascript - popup windows in not opened in codeigniter -

i using codeigniter , in 1 of views have following function triggered when employee code not exist in database(using jquery ajax - works fine). confirm popup displayes when entered code not valid when result of confrim true, following code not fire popup window! function popup(){ if(confirm("employee_code not available! \nsave code new employee?")){ //var new_emp_window = "<?php echo base_url().'index.php/it_inventory/new_employee'; ?>"; widnow.open('www.google.com', 'width=500, height=500'); }else{ alert("ohh!"); $('#employee_code').val('').focus(); } } first of change www.google.com http://www.google.com . browser handles urls without protocol prefix relative paths. check popup blocker not active on browser.

c# - How to solve Redirect Loop -

i have web application, , users use chrome preferred browser of choice, following error when have logged out of application, , try log in. "this webpage has redirect loop". my web application uses forms authentication, , formauthenticationmodule redirects user login page of application, cannot use approach: <customerrors mode="on" defaultredirect="~/myerrorpage.aspx" > <error statuscode="401" redirect="~/noaccess.aspx"/> </customerrors> instead, have added following page_load event of loginpage . if (request.isauthenticated && !string.isnullorempty(request.querystring["returnurl"])) { response.redirect("~/noaccess.aspx"); } however, since have added approach, users seem "redirect loop" error. after clearing cookies, seems well, problem occur again. is there permanent fix can add code, or there else can prevent issue happening? try adding web

What are the differences between gitlab team and gitlab group? -

i'm using gitlab 5.0 manage git repositories , i've never used github before gitlab. when create group, see new directory group name in /home/git/repositories. team, no such thing done. also, group, can create project group , assignments (for users of group) done automatically. i can't see other differences between group , team , understand that. thank in advance , sorry bad english (i'm french), gitlab 6.0 (august 2013, 22d) see commit 3bc4845 : feature: replace teams group membership we introduce group membership in 6.0 replacement teams. old combination of groups , teams confusing lot of people. , when members of team changed, wasn't reflected in project permissions. in gitlab 6.0 able add members group permission level each member . these group members have access projects in group. changes group members reflected in project permissions. can have multiple owners group, simplifying administration. why re

list - ocaml bubble sort -

my basic idea implement bubble sort of type ('a list -> 'a list) . use variables sorted , result . if change of elements in list, sorted becomes 1. otherwise, sorted remains 0. result 1 cycle of comparison. i think there wrong sorted variable. can figure out problem is? let rec sort (l: int list) : int list = let sorted=0 in let result = match l | []->[] | x::xs-> if xs=[] x else let y::ys = xs in if x<y x::sort(xs) else let sorted=1 in y::sort(x::ys) in if sorted=0 result else sort(result) it seems me you're trying use sorted mutable variable. ocaml variables immutable. once bind variable value, binding can't changed. each of let sorted = statements defines new variable named sorted . last test show sorted equal 0. testing first definition of sorted, can never have other value 0.

php - Using PHPExcel to export to xlsx -

i using phpexxcel export html table generated using mysql , this. <?php $query = "select `firstname`,`lastname`,`branch`,`gender`,`mobileno`, `email` `student_details` branch in ('$branch') , `year`='$year' , tenthresult > '$tenth' , twelthresult > '$twelth' , (cgpa > '$cgpa' || cgpa = '$cgpa')"; $result = mysql_query($query); confirm_query($result); $objphpexcel = new phpexcel(); $objphpexcel->setactivesheetindex(0); $rowcount = 1; $objphpexcel->getactivesheet()->setcellvalue('a'.$rowcount,'firstname'); $objphpexcel->getactivesheet()->setcellvalue('b'.$rowcount,'lastname'); $objphpexcel->getactivesheet()->setcellvalue('c'.$rowcount,'branch'); $objphpexcel->getactivesheet()->setcellvalue('d'.$rowcount,'gender'); $objphpexcel->getactivesheet()->setcellvalue('e'.$rowcount,'m

asp.net - setting width of select box of asp dropdownlist -

i have gone through similar questions (answers) asked before. not have need. need width of drop down constant time. when drops down & items wider width. wider items should displayed tooltip. how do this? , deal select element? why every post have answers in terms of "select". using asp dropdown. how use select it? anyway, here's css ddl: .ddl2 { margin-top: 10px; margin-bottom: 10px; border-style: solid; border-width: thin; border-color: gray; height: 20px; max-width: 150px; } this works (only in firefox) when nothing selected. ddl drops, selectbox takes width of widest element. edit: try { dataset dscountry = objbindddl.binddropdownlisttoacountry(); ddlcountry.datasource = dscountry.tables["acountry"]; ddlcountry.datatextfield = "countryname"; ddlcountry.datavaluefield = "id"; ddlcountry.databind(); ddlcountry.items.insert(0, new listitem(&quo

fortran - Compilation error: Undefined symbols for architecture x86_64 -

i trying use fortran library perform fft called "2decomp&fft"( http://www.2decomp.org/download.html ). library has in-built fft engine , works fine code. in order use fftw3 engine library, instead of in-built engine, instructions say: edit 'src/makefile.inc' file in 2decomp, change fft engine 'fft=fftw3'. need set fftw_path variable in same file point fftw installation. recompile everything. i installed fftw3.3 on local mac , followed instructions , recompiled library. after when trying compile code library, getting following error while linking. undefined symbols architecture x86_64: "_dfftw_destroy_plan_", referenced from: ___decomp_2d_fft_mod_decomp_2d_fft_finalize in lib2decomp_fft.a(fft_fftw3.o) "_dfftw_execute_dft_", referenced from: ___decomp_2d_fft_mod_c2c_1m_z in lib2decomp_fft.a(fft_fftw3.o) ___decomp_2d_fft_mod_c2c_1m_x in lib2decomp_fft.a(fft_fftw3.o) ___decomp_2d_fft_mod_c2c_1m_y in lib2decomp_fft.a(ff

python - Accessing multiple dictionary values -

i have 2 dictionaries in below format d=defaultdict(<class 'collections.ordereddict'>, {u'1': ordereddict([(1746l, 1), (2239l, 1)]), u'2': ordereddict([(1965l, 2)]),u'3': ordereddict([(2425l, 1),(2056l, 4)])}) e={2056l: 3, 1746l: 3, 2239l: 2, 1965l: 3, 2425l: 4} how can create dictionary of format?? {u'1':{1746l:(1,3),2239l:(1,2)},u'2':{1965l:(2,3)},u'3':{2425l:(1,4),2056l(4,3)}} >>> {i: {j: (d[i][j], e[j]) j in d[i]} in d} {u'1': {1746l: (1, 3), 2239l: (1, 2)}, u'3': {2056l: (4, 3), 2425l: (1, 4)}, u'2': {1965l: (2, 3)}}

Rails upload a file and render it as an HTML page -

i building website ror 3. need provide page clients wherein edit pricing info regarding application. quite confused on how this. pricing page needs displayed html table different columns has got pricing info. i thinking of different ways this. 1) allow client create , upload html page , save file in public directory , render when client clicks on pricing link. 2) clients may not have bare technical knowledge, hence make client upload other formats word, excel etc , parse , store html file in public directory. 3) provide client real time editing tools in client edit in fixed format, , after wards save file , render later. also, wouldn't store these infos in database. there quite few number of clients , hence managing these data in database become cumbersome. storing these plain html files , rendering later ideal thing me. there might other better steps in doing well. please suggest might better, or other option suit needs? want clients have mechanism provide there pr

linux - Get fat32 attributes with python -

how can fat32 attributes (like archived, hidden...) in linux without spawning new process fatattr utility call ? may there python binding or linux/fs functions (fat_ioctl_get_attributes, http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/fs/fat/file.c ). or maybe can done python-xattr ? as can see in function name, kernel function fat_ioctl_get_attributes called userspace via ioctl , , i'm not aware of other binding. therefore, can read attributes calling ioctl yourself, this: import array import fcntl import os fat_ioctl_get_attributes = 0x80047210 fatattr_bits = 'rhsvda67' def get_fat_attrs(fn): fd = os.open(fn, os.o_rdonly) try: buf = array.array('l', [0]) try: fcntl.ioctl(fd, fat_ioctl_get_attributes, buf, true) except ioerror ioe: if ioe.errno == 25: # not fat volume return none else: raise return buf[0] finally: os

c# - NHibernate: identifier of an instance of object was altered from x to y -

i have situation nhibernate. have piece of code: private void unlinkproductsfrompriceagreement(namevaluecollection collection, iunitofwork unitofwork) { // price agreement id int priceagreementid = collection.getint("id"); foreach (int productid in collection.getids("unlinkproductslist")) { // product price iproductprice productprice = productpricerepository.find(p => p.priceagreement.id == priceagreementid && p.product.productid == productid).firstordefault(); // remove product price productpricerepository.delete(productprice); } } i exception when run code: qe.common.core.exceptions.persistencyexception ---> nhibernate.hibernateexception: identifier of instance of qe.vending.core.domainobjects.product altered 210036 0 @ nhibernate.event.default.defaultflushentityeventlistener.checkid(object obj, ientitypersister persister, object id, entitymode entitymode) in d:\csharp\nh\

Pick up only fully written files in java -

i have directory in aix receive files external application. java program should pick files written application.it should not pick incomplete files being still written external application. can sample? try apache camel file poller , stratergies os or file renaiming detect file access in progress

css3 - HTML email: @media queries that work on mobile and Outlook -

i'm coding html email viewed both in outlook , in mobile devices. i'd use tables outlook (i need multi-column set up), , single column divs mobile devices (or < 400px). i'm trying @media queries, , know outlook's css support extremely shoddy, i'm wondering if knows hack can make outlook "ignore" @media query < 400px, , apply styles >400px part. tried this: @media (max-width: 480px) { .mobile-email { background-color:green; } } @media (min-width:500px) { .mobile-email { background-color:red;} } the trouble seems outlook ignores both. there way can make sort of thing work in outlook? thanks in advance! in honesty i'd steer clear. html emails horrile horrible business. adding media queries mix asking trouble. blackberrys don't support media queries start... http://www.emailonacid.com/blog/details/c13/media_queries_in_html_emails outlook barely standard css since switched it's rendering engine ms word

appcentre reports: Your iOS app does not appear to have Facebook Login integration -

it seem facebook appcentre review team , myself talking different things in relation above alert , allthough have asked them explain mean several times reply canned answer: your ios app not appear have facebook login integration. please either implement facebook login or remove integration listed platform in developer app. can read more here: http://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk . in app have implemented code "hellofacebooksample" comes facebook sdk. works. can login, can post, can logout. when in facebook app on ipad , click on name of ios app appears in post, facebook app moves background , app moves foreground. me looks facebook login integration, appearantly review team refers else , seem unable explain me other sending me same canned message on , on again. though "share" button not hard find include following instructions when submit app details page review facebook appcentre: make sure have latest