Posts

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...