Posts

Showing posts from May, 2010

php - Why preg_match() didn't work with my expression? -

i have in php expression: preg_match("/\<div id=\"servertc\">(.+)\<\/div>/",$data,$out); and in $data contain: <div id="servertc">nowy serwer evolution!<br><br> ~ server info ~<br> ip: axera.pl (port: 7171)<br> online: 24/7<br> world type: pvp (protection level: &gt;100)<br> house rent: disabled.<br> ~ rates ~<br> experience player: x2<br> magic level: x15<br> skills: x30<br> loot: x3<br> spawn: x3<br> houses: 100 level<br> guilds: 8 level (create via website)<br> red skull (24h): 25 unjustified kills per day<br> black skull (48h): 50 unjustified kills per day<br> idle kick time = 15 minut<br> ~ exp stages ~<br> 1-50: x 650<br> 51-75: x 450<br> 76-100: x 300<br> 101-150: x 150<br> 151-175: x 100<br> 176-190: x 75<br> 191-230: x 35<br> 231-250: x 20<br> 251-280: x 15

java - Android changing XML layout Changes data fields -

here's head scratcher...(at least me) have contact list displays list of contacts db. when user clicks on 1 of contacts edit activity comes up. works laid out currently, need have edit activity display last name entry before first name. thinking fields should have 1 one relationship, went ahead , moved edittext(xml) last name above first name in edit activity thinking should referenced id of edittext. after doing so, program displaying first name in last name field , vise-versa. have tried wiping user data on emulator no difference. realize 1 of uh-duh! type questions, if can point out obvious me, appreciated. code shown in now-working state: i've removed chunks have nothing issue. having @ me! ken xml: <edittext android:id="@+id/contact_edit_first_name" android:inputtype="textpersonname" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight

apache - How to prevent users from using javascript links -

this question has answer here: security risk in using jquery ajax 5 answers i have website makes ajax calls server-side script when button pressed. problem user type following address bar: javascript:callajaxroutine(); how prevent happening? the people in comments right in saying you'll never able out of code 100%, can couple of things ward off less serious: encapsulate function in object, it's not in global namespace, obfuscate code no 1 is case of doing this: (i'm going use jquery here, it's not essential, shortens code) instead of: <script> var callajaxroutine = function () { // ajax ajax(); } $('#button').on('click', callajaxroutine); </script> you take function out of global namespace , put inside object: <script> // sets object containing self-execu

boolean logic - Odd JavaScript Behavior When Comparing Numbers Larger than 1000 -

i wrote javascript function supposed check if amount greater 0 , less amount. example, if total amount due $800.00, , user tries pay $1100, want function first check amount being paid ($1100) greater 0 (true) , amount being paid less total amount due (false). pretty sure logic fine, function hasn't been working correctly: function validate_payment_amount() { var payment_amt = get_amount_paying(); // 1100.00 var amt_due = get_amount_due(); // 800.00 console.log('is ' + payment_amt + ' greater 0?: ' + (payment_amt > 0)); console.log('&&'); console.log('is ' + payment_amt + ' less or equal ' + amt_due + '?: ' + (payment_amt <= amt_due)); return payment_amt > 0 && payment_amt <= amt_due; } the function evaluates correctly if payment_amount less 1000 , here console output: is 999.00 greater 0?: true && 999.00 less or equal 892.50?: false so above works fine. howe

html5 - Showing several images at the same time -

i app , want show 2 images. 1 under other. i have tried lots of things data role content dont know doing wrong. any idea? my html5 code: <div data-role="page" id="p3"> <div data-role="content" id="orienthorizontal" style="padding:0px;"> <img src="imagens/horizontal/6.jpg"/> <a href="#positionwindow" id="videoicon" data-rel="popup" data-inline="true" data-transition="slidefade" data-position-to="window"><img src="icon/video-icon.png"/></a> </div> <div data-role="content" id="orienthorizontal" style="padding:0px;"> <img src="imagens/horizontal/6.2.jpg"/> </div> </div> css: #orienthorizontal{position:absolute} either define css such divs must display on separate lines, or can insert <br/> tag

How to make a script like e.g. 'script/mailman_server' work for multiple users in a Rails app -

i have rails app uses mailman gem ( link ) collect inbound pop3 mails , stuff them. works fine, wish have multiple users sign , receive mails pop3 configuration. mailman run in 'script/mailman_server', , unfamiliar how make script (thats running own process) work multiple users. enlighten me on subject or link resource touches subject? this code of now # script/mailman_server #!/usr/bin/env ruby require "rubygems" require "bundler/setup" require "mailman" mailman.config.pop3 = { :username => 'some_name@some_email.com', :password => 'some_password', :server => 'pop.gmail.com', :port => 995, :ssl => true } mailman::application.run default email.receive_mail(message) end end # app/models/email.rb class email include mongoid::document include mongoid::timestamps field :from, type: string field :subject, type: string field :body, type: string belongs_to :cust

if statement - Basic Python Script If Statment -

i messing around basic magic 8 ball program , im trying make aloww yes or no questions thinking except questions have first word "will" or "do" how can make allows words ? here script: import random import time print "welcome magic 8 ball !" while true: def magic8(a): foo = ['yes', 'no', 'maybe', 'doubtful', 'try again'] random import choice print choice(foo) = raw_input("question: ") if == "exit": exit() #if stament here print "determining future..." time.sleep(2) magic8(a) if a.split(none, 1)[0].lower() in {'will', 'do'}: print "determining future..." time.sleep(2) magic8(a) # function names not capitalized str.split() splits sentence on whitespace, str.lower should handle uppercase.

Python Comparing Lists -

i want compare 2 lists , want know if element corresponds element. example: 'a' should correspond 'b' here, return true. list1 = [a,b,c,d] list2 = [b,a,d,c] 'a' , 'b' correspond each-other (they share same spot on lists). how make function return true if correspond? list1 = [a,b,c,d] list2 = [c,d,a,b] this return false. i this: >>> operator import eq >>> list1 = ['a','b','c','d'] >>> list2 = ['c','d','a','b'] >>> any(map(eq, list1, list2)) false of course, if want full boolean 'correspondence' list can omit any function: >>> map(eq, list1, list2) [false, false, false, false]

c# - Inserting data into SQL database using EF -

i'm trying create httppost method create new database entry. should take 2 foreign ids different database tables , "name". here's model: public class domena { public int domenaid { get; set; } // domains id public int tldid { get; set; } // foreign id public int klientid { get; set; } // foreign id public string nazwa { get; set; } public virtual tld tld { get; set; } public virtual klient klient { get; set; } } right, have : // get: /domena/add_domain public actionresult add_domain() { viewbag.tldid = new selectlist(db.tlds, "tldid", "typ"); viewbag.klientid = new selectlist(db.klienci, "klientid", "klientid"); return view(); } // // post: /domena/add_domain [httppost] [validateantiforgerytoken] public actionresult add_domain(domena domena) { if (modelstate.isvalid) { db.domeny.add(domena); db.savechanges(); return redirecttoaction("index"); }

scala - I am trying to compare two Tuples -

i trying write function compare tuples of similar type. def comparetuples(tuple1: (string, string, int), tuple2: (string, string, int)): (string, string, int) = { // if tuple1.int < tuple2.int return tuple1 else tuple2. } how access third element or int in each tuple? thanks to access value in tuple t , can use t._1 , t._2 , etc. for result in def comparetuples(tuple1: (string, string, int), tuple2: (string, string, int)): (string, string, int) = { if (tuple1._3 < tuple2._3) tuple1 else tuple2 }

jquery - PrettyPhoto Not Working According to Documentation -

i followed of documentation on site, can't work. i copied script load head, activated script before body close, , put prettyphoto hook on link. but when click on link, nothing animates, opens full size image link pointed on it's own page. <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script> <link rel="stylesheet" href="css/prettyphoto.css" type="text/css" media="screen" charset="utf-8" /> <script src="js/jquery.prettyphoto.js" type="text/javascript" charset="utf-8"></script> </head> <body> <a href="superlow.jpg" rel="prettyphoto"> sldjflkdjsf </a> <script type="text/javascript" charset="utf-8"> $(docume

PHP Script Undefined Property and Invalid Argument Errors -

i trying run php file , keep getting errors like undefined property: stdclass::$games and invalid argument supplied foreach() this picture of error http://imageshack.us/a/img845/6270/34356212.jpg , below script running minus steam api key. <?php $api_key = '........'; //steam api key, required work $lines = file('parse1.txt'); //reads in file list of user numbers $game_id = 550; //steam game id, 440 tf2 foreach ($lines $usernumber) { //loops line line $link = 'http://api.steampowered.com/iplayerservice/getownedgames/v0001/?key=' . $api_key . '&steamid=' . $usernumber . '&format=json'; $json = file_get_contents($link); //reads link (this ^) $data = json_decode($json); foreach ($data->response->games $game) { if ($game->appid == $game_id) { $playtime = $game->playtime_forever; if (($playtim

python - Django Filtering performance if using [:max] -

assume have table 100000 entries doing : a = model.object.all()[:10] will sql limit request 10 or django generate sql table , provide me 10 entries? that's python question more django, want make sure not doing wrong. django use sql limit. limiting querysets class m(models.model): pass ... print m.objects.all()[:10].query # select "app_m"."id" "app_m" limit 10

post - PHP: Why does $_POST have a larger size limit than $_GET? -

i know $_post has larger size limit $_get, why? $_get limited by? $_get transferred within url , therefore limited maximum size. there no theoretical maximum url size defined http standard , limited many browsers , servers. refer faq advices application use urls smaller 2000 chars $_post transfererred within request body theoretical unlimited, $_get there limits browsers , servers. higher. for info: adjust maximum post size in php use ini value post_max_size=...

Run a Windows command in Perl outside of CGI enviroment -

i have specific proprietary application, dual use, running "account.exe" in cgi context (eg inside web server) make account.exe output html page , such. running "account.exe" outside of cgi context causes account.exe enable command line functions. now question: want run account.exe outside cgi context in perl. have tried system(1, "command"); have tried system("start command"), tried bat wrapper clears (set variable=) every enviroment variable has cgi do, still account.exe "detects" run web server , outputs html. how can run windows command in cgi script in perl (using strawberry perl) , making impossible "account.exe" application detect execution came web server? there many ways how account.exe possibly detect how run. environment variables 1 way; seems have ruled 1 out. normally processes can see parent , parent, other way. so either can lot of testing until fool specific technique process using, or mi

java - Is it a sensible optimization to check whether a variable holds a specific value before writing that value? -

if (var != x) var = x; is sensible or not? compiler optimize-out if statement? there use cases benefit if statement? what if var volatile variable? i'm interested in both c++ , java answers volatile variables have different semantics in both of languages. java's jit-compiling can make difference. the if statement introduces branching , additional read wouldn't happen if overwrote var x, it's bad. on other hand, if var == x using optimization perform read , not perform write, have effects on cache. clearly, there trade-offs here. i'd know how looks in practice. has done testing on this? edit: i'm interested how looks in multi-processor environment. in trivial situation there doesn't seem sense in checking variable first. when cache coherency has kept between processors/cores check might beneficial. wonder how big impact can have? shouldn't processor such optimization itself? if var == x assigning once more value x should not 'dir

actionscript 3 - Does sharedObject.getLocal work with Air for iOS? -

so, i've created save system game.the thing works fine on flash , air desktop, not air ios when wrap ios app.does sharedobject.getlocal work ios? if not, else can use? yes, should work. if var mysharedobject.getlocal("game") not work, have corrupted system, or old version of ios. sure, post code you're using. also, make sure have correct render mode type of application. 2nd option: check memory. if don't have enough memory support sharedobject, won't store memory. test, add code: if(mysharedobject.size != 0) { textfield.text = "works." }else{ textfield.text = "nowork." make textbox input called 'textfield' , sharedobject variable 'mysharedobject'.

Python 2.7 - Quotes added to command when using Popen to execute from variable -

i'm trying send command through socket client server execute command on server , send output me. works fine if command 1 word no options. if use option such netstat -an or dir c:\ command isn't recognized , output looks quotes put around command before being executed ( '"netstat -an"' not recognized internal or external command). know aren't saved in variable way because printed before being executed error check. please help. here code looks like: commout = subprocess.popen([data], stdout=subprocess.pipe, shell=true) (out, err) = commout.communicate() try make data array of arguments (the first being actual command). for example: commout = subprocess.popen(['netstat', '-an'], stdout=subprocess.pipe, shell=true) the first element string representing actual command ( netstat ), next element string representing first argument ( -an ). to clarify, popen(['echo', 'a', 'b'] equivalent echo b on

c++ - DBX Output Different When Using "." or "->" -

there's function that's not working , don't understand why, , dbx isn't helping. below i'm talking about. (dbx 12) print ((ccfundexpenseobject *)s1)->getfundbranchgroup() ((class ccfundexpenseobject *) s1)->getfundbranchgroup() = -2019 (dbx 13) print (*((ccfundexpenseobject *)s1)).getfundbranchgroup() (*((class ccfundexpenseobject *) s1)).getfundbranchgroup() = 1 logically, both lines should have same result, right? if want more context, here's explanation of code: getfundbranchgroup() returns short stored in ccfundexpenseobject . that's it. s1 void*

c++ - How do I use cin in a while loop? -

i'm trying user input name(s) using while loop array , cin, after last person's name input, program crashes instead of moving on. there way fix this, or need change code? i'm new c++, can answers given possible? #include <iostream> #include <string> using namespace std; int main() { unsigned int numberofplayers; number://loop here if more 4 players cout << "number of players: "; cin >> numberofplayers; if(numberofplayers > 4 || numberofplayers < 1){ cout << "invalid number, please enter number 1 4." << endl; goto number; } string name[numberofplayers]; cout << "enter name" << endl; int = 1; while(a < numberofplayers + 1){ cout << "player " << << ": "; cin >> name[a]; cout << "hello, " << name[a] << ".&quo

testing - Change every time the content of a javascript, in a "while"? -

i need javascripts. using --> javascript onclick create(element) div viz popup box , use in php page , inside while. problem when use <div id="test" class="popup"> because everytime of cause make print "test" javascript. function openpopup() { document.getelementbyid('test').style.display = 'block'; } and takes first line make print, , forgets of others. how can use make each line different others?

javascript - Inserting removing elements from the DOM -

i have code inserts div content whenever user clicks button. angularjs way insert or remove elements dom? if elements want add somehow related or near button, use directive. dom manipulation performed directive. however, there seems exception rule: if want insert modal dialog box -- i.e., doesn't have placed somewhere specific -- might want use service. listen few minutes of misko regarding this. if want dialog, see http://angular-ui.github.io/bootstrap/#/dialog , here so answer uses in plunker.

sass - Add custom CSS to sprites generated with Compass -

i have code in my_images.scss file: $icon-layout:smart; $icon-sprite-dimensions: true; @import "icon/*.png"; @include all-icon-sprites; the output this: .icon-sprite, .icon-asterisk, .icon-camera, .icon-clock, ... { background: url('/../../media/img/icon-s00227a988a.png') no-repeat; } .icon-asterisk { background-position: -108px -18px; height: 18px; width: 18px; } .icon-camera { background-position: -54px -18px; height: 18px; width: 18px; } how can change code include custom css in output. want generate this: .icon-sprite, .icon-asterisk, .icon-camera, .icon-clock, ... { background: url('/../../media/img/icon-s00227a988a.png') no-repeat; /* custom css here */ display: inline-block; } important i have not solution this: since these built using @extend need add selector named .icon-sprite , include custom styles. so: .icon-sprite { display: inline-block; } $icon-layout:smart; $icon-sprite-dimensions: true;

string - Easy way to work with text without having to escape quotation marks in Clojure? -

i'm playing around text parsing in repl, , want dump in bunch of data string, whether it's bibtex entry or ebnf notation etc. typically there might quotation marks in string, , it's tedious , error-prone have manually escape them.. is there alternative way of doing this, such ruby's %q|i can use "quotation marks"| or heredocs etc? or possible write macro or modification of reader enable this? there has been some discussion more robust quoting syntax, no changes support seem imminent. in meantime, handle repl interaction mention, might find useful. note doesn't work every repl out there -- don't support read-line terribly well: (defn read-lines [] (->> (repeatedly read-line) (take-while #(not= % ".")) (mapcat #(list % "\n")) (apply str))) use running (read-lines) @ repl, pasting content, , adding line . itself: user=> (read-lines) #_=> "works" #_=> s

excel - Returned Recordset is closed (mysql DB accessed via ODBC in VBA) -

long time viewer first time poster. i'm working on database application front-end in excel. hence using vba access mysql database. driver i'm using odbc driver (windows) , have valid connection database lots of other queries function well. what i'm trying return results series of sql statements rather trying combine 1 massive statement (which work difficult maintain/understand). have added flag flag_multi_statements = 67108864 connection string suppressed driver syntax errors. but when run following: querydb.open sqlquery, conn the recordset (querydb) remains closed no apparent error. sql statement can found here . i may generating errors aren't being returned vba here appreciated. note : sql statements work can paste statement phpmyadmin , returns correct (non-empty) results. don't know if statements problem perhaps use of create temporary table ... or use of multiple statements in general. also guess driver may trying return result each sql s

c++ - How to allocate memory on the heap via user input? -

is there way create function can allocate chunk of memory onto heap caller can pass size want allocate , return valid address caller use? know how allocate specific size there way have caller pass desired amount? absolutely: in c malloc / calloc / realloc take size parameter, , not care size came from; same goes new . for example, if allocate user-specified number of double s, this: cout << "enter number of double elements want allocate" << endl; int count; cin >> count; // can c-style allocation... double *chunkmalloc = malloc(sizeof(double)*count); // ...or c++ style: double *chunknew = new double[count]; // don't forget free allocated chunks: free(chunkmalloc); delete[] chunknew;

.net - Send username and password in clear text to web service over HTTP -

i have vb.net (2008) console application consumes web service. started writing using old/legacy (pre-wcf) technology of importing wsdl wsdl.exe (or "add web service" in visual studio), creates classes based on system.web.services.protocols.soaphttpclientprotocol. however, realized not best way (thanks john saunders' comments in previous question -- how serialized xml of object passed web service? ). so, i've got code converted on wcf (using "add service reference", creates classes based on system.servicemodel.clientbase); , works more or less same, except 1 key point: security. the web service consuming written in java; , while both (me, , team developed web service) work same company, don't have control on how publish , expose web service. requirement pass username & password (basic http authentication) on http, not https. know that's not secure way it; that's battle can't fight right now. this worked fine using old way.

javascript - Multiple hero-units to be the same height -

i have <div> 3 span4 s inside it, hero-unit inside each span4 . inside each hero unit text , picture. here demo: http://jsfiddle.net/ggmwx/256/ and code, in case link breaks in future: <div class="row-fluid"> <span class="span4"> <div class="hero-unit" id="col1"> <h1 class="heading">one</h1> <p>lorem ipsum</p> <img src="http://dummyimage.com/100x400/000/fff" class="image" /> </div> </span> <span class="span4"> <div class="hero-unit" id="col2"> <h1 class="heading">two</h1> <p>lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum </p> <img src="http://d

Django Multiple Authentication Backends Based On Status -

i wondering how tell django authentication backend use based on if user marked staff or if not. can done? since authentication backend used django user object, not known @ time we're calling backend wether user marked staff or not. is still possible use different backends staff , non-staff user, chaining backends explained in specifying authentication backends . example if settings are: authentication_backend = ( 'myapp.auth.staffuserbackend', 'django.contrib.auth.backends.modelbackend', ) where myapp.auth.staffuserbackend recognizes staff users, happen when user authenticates: the credentials checked against staffuserbackend . if user staff , credentials correct, staffuserbackend returns user object , we're done. if user not staff, credentials checked against modelbackend . if credentials valid standard user, modelbackend returns user object , user authenticated usual. if credentials not accepted backend, authenticati

c++ - How to determine, what type do I have on input -

i've got iterator through undefined type: (typename type::const_iterator haystackiterator = hayheap.begin(); haystackiterator != hayheap.end(); ++haystackiterator) { //some inner logic } and nice, know type *haystackiterator able modify inner logic pursuant information... there simple function make this? if (*haystackiterator.isinstanceof(vector<string>){ //do } else if (*haystackiterator.isinstanceof(string){ //do else } i can use these includes : #include <cctype> #include <iostream> #include <iomanip> #include <set> #include <list> #include <map> #include <vector> #include <queue> #include <string> put inner logic in function, , overload function: void innerlogic(vector<string> const& vec) { //do } void innerlogic(string const& str) { //do else } void loop() { (typename type::const_iterator haystackiterator = hayheap.begin(); haystackiterator !=

http post - Best method to Upload images to php server in Android ? -

in application need upload image android php server. used multipartentity , worked me.can suggest me method faster this.i need upload 4 pictures application @ 1 time.so takes lot of time , want reduce this. any suggestion please.... in advance

jquery - Get td's value dynamically on click of a button -

i need value <td id='itemcadapreco'> when click on button id of 'btnremover':. here jsfiddle: http://jsfiddle.net/6apax/ <tr id='itemcada'> <td id='itemcadaid'>1</td> <td>descrição aqui</td> <td id='itemcadaqtd'>12</td> <td id='itemcadapreco'>r$ 10,00</td> <td>r$ 12000,00</td> <td style='width: 15px;'><button id="btnremover">x</button></td> </tr> $(function(){ $("#btnremover").click(function(){ alert($(this).closest("#itemcadapreco").text()); }); }); edit: guys generated dynamically on loop , id "itemcadapreco" repeat, call id on click not work, need use 'closest' or that. thanks! what might want $(function(){ $("#btnremover").click(function(){ alert($(this).closest("tr").

Rails method works in console but not through browser -

here's in model: :after_save after_save def after_save self.delay.do_thing end def do_thing dir.mkdir("#{rails.root}/my/path") system("cd #{rails.root}/my/path && wget -with-some-flags") end this works flawlessly in development. however, in production, nothing happens. no errors, nothing. i've checked several things like: sending command log before it's run make sure it's built correctly running command manually check it's working opening production rails shell , doing myobject.do_thing , works! switching between ticks , system() command, check if subshells adding absolute command paths, /usr/bin/wget instead, works in command line not in web browser. checked permissions of folder it's saving to i know do_thing method running because creates folder in process of doing thing , appear in filesystem, not result of wget. i'm genuinely stumped here. ideas?

sql - Different approach of using IN clause in MySql -

today have posted answer query this select * table_name column_name in (val1,val2,...) some user has posted answer query this select * table_name val1 in (column_name) as can see here position of column_name , values interchanged. from mysql docs expr in (value,...) returns 1 if expr equal of values in in list, else returns 0. if values constants, evaluated according type of expr , sorted. search item done using binary search. means in quick if in value list consists entirely of constants. mysql> select 2 in (0,3,5,7); -> 0 mysql> select 'wefwf' in ('wee','wefwf','weg'); -> 1 as says above one(my query) correct. both above queries produce same output. also why not other approach in listed in mysql documentation ? this question serves canonical information source regarding use of in. purpose have detailed, high quality answers detailing proper use on in in queries. you raised question connected a

c# - Sliding effect on buttons -

Image
i have user control looks this: i want achieve effect in when user clicks on button, every other button slides side ways , content according clicked button appears in rest of available space. this: and this: how can achieve effect? working c# , xaml...

c++ - How to support many document types in MFC like MS office applications or Visual studio -

how make mfc application support multiple document types ms office , visual studio, when click new file window types supported appear choose , open appropriate document/view. i'm not experienced in mfc document/view architecture . of books i've read don't cover part. same on document/view cover basics drawing triangles, circles, squares. want master mfc document/view architecture, best book or tutorial that? another thing how create mdi application don't support document/view , [it has no deal documents] deals database example mdi childs forms controls , how in c# easy set parent mdi parent , mdi child, show, appear how can achieved in mfc? type of dialog use. there's no magic involved, lot of work. if want support document types x, y , z, need figure out models need represent them. similar document types may share similar models. e.g. in visual studio, vb.net solution , c# solution may share same model, since both .net solutions. yet native c++ may r

CSS issue - margin top - Google Chrome -

on joomla site have problem margin-top in google chrome. firefox & ie ok. there 27 pixels, menu above. use theme yootheme (but not able solve problem). if enter style: ul.menu.menu-dropline { margin-top:27px; } google chrome version ok; not firefox & ie anymore. unfortunately not css profi - can help. kind regards winfo i found these lines in css code. cause difference in behavior between ff , webkit browsers. -webkit-margin-before: 1em; -webkit-margin-after: 1em; -webkit-margin-start: 0px; -webkit-margin-end: 0px; -webkit-padding-start: 40px; quick solution: add following css code. ul.menu.menu-dropline { -webkit-margin-before: 27px; }

ruby - How to run code before each test case in all tests in MiniTest? -

i need run code before each test in tests in minitest. before did: minitest::unit::testcase.add_setup_hook ...code run before each test end after upgraded minitest version 4.7.2 shows following error: undefined method `add_setup_hook' minitest::unit::testcase:class (nomethoderror) i using ruby mri 2.0.0p0. solution module myminitestplugin def before_setup super # ...code run before test cases end def after_teardown # ... code run after test cases super end end class minitest::unit::testcase include myminitestplugin end add_setup_hook removed in 4.6.0. https://github.com/seattlerb/minitest/commit/792a480ebeb32983b9150adae575b7c396e2ae63 use before_setup instead.

c# - Detect characteristics in audio stream -

i want write/program/develop algorithm can recognize many characteristics in data line in/mic audio. audio stream music , want filter out characteristics distinguish songs each other, distinguishing mean can call genres of songs apart. one crucial thing absolutely want detect kind of bar/beat song has. example want know if song in 3/4 time. the helpful articles found bpm detection not enough distinguish song song. the fft start different characteristics audio stream don’t know begin. possible bar/beat fft? there tutorials/code examples this? is fft enough characteristics of audio stream or there other algorithms getting characteristics in audio streams? preferably in c# because that’s programming language have experience with. possible in c# or language better? to sum question up, i’m looking information finding characteristics in audio stream beat/bar , other information distinguish songs. i enjoyed reading related articles blogger: http://www.redcode.nl/blo

yii extensions - Advantages of using Yii rights? -

in addition creating rbac file, other advantages of yii rights module? yii rights module yii rbac doesn't support? allows manage access in backend: create roles on fly , attache user. role access has weak binding code because based on module-controller-action-oriented permissions can give user. can managed backend interface on fly. has task (not role) oriented access - when can create custom task (text editing example) , base logic on permissions tasks instead of roles

database - postgresql - start on mac - `pg_ctl` not working -

i want use pre-installed postgresql on local machine (mac os 10.7.5), when run which psql find (in /usr/bin/psql ), running pg_ctl -d /usr/bin/psql -l /usr/bin/psql/server.log start results in: -bash: pg_ctl: command not found how can start/use postgresql database? need install (with homebrew) or can use pre-installed 1 on mac? tried using initdb command ( initdb /usr/bin/psql -e utf8 ) , go tthe same message: -bash: initdb: command not found . also, psql same postgres ? (i tried which postgres , got nothing) update: i'm using psql commands in command line, getting there following message (for psql -l , psql -a instance): psql: not connect server: no such file or directory server running locally , accepting connections on unix domain socket "/var/pgsql_socket/.s.pgsql.5432"? os x ships command line client (for interacting postgres databases) not server. you need install server. check the postgres site or grab postgres.app

visual studio 2010 - Add textboxes in last row of gridview -

i working on windows form app using c#. have gridview on form contain 5 columns sr no, item name, item price, item qty , item amount. want have set of 5 textboxes in last row of gridview can enter required values there , upon entering last value, wholw row comprising of 5 items should added gridview , again last row should contains set of textboxes newer entry. how can achieve this? also possible have entries made in gridview itself? need fetch entries db , after user done, gridview entries stored again in db. please note app wpf ease have used windows form window.

c++ - Pointers and reference issue -

i'm creating similar structure list. @ beginning of main declare null pointer. call insert() function couple of times, passing reference pointer, add new elements. however, seems wrong. can't display list's element, std::cout breaks program, though compiler without warning. #include <iostream> struct node { node *p, *left, *right; int key; }; void insert(node *&root, const int key) { node newelement = {}; newelement.key = key; node *y = null; std::cout << root->key; // line while(root) { if(key == root->key) exit(exit_failure); y = root; root = (key < root->key) ? root->left : root->right; } newelement.p = y; if(!y) root = &newelement; else if(key < y->key) y->left = &newelement; else y->right = &newelement; } int main() { node *root = null; insert(root, 5); std::cout << root->key; // works if delete co

Thymeleaf: Concatenation - Could not parse as expression -

i'm having issue when trying concat multiple values in template. according thymeleaf here should able + them together... 4.6 concatenating texts texts, no matter whether literals or result of evaluating variable or message expressions, can concatenated using + operator: th:text="'the name of user ' + ${user.name}" here example of found works: <p th:text="${bean.field} + '!'">static content</p> this doesn't: <p th:text="${bean.field} + '!' + ${bean.field}">static content</p> logically, should work not, doing wrong? maven: <dependency> <groupid>org.thymeleaf</groupid> <artifactid>thymeleaf-spring3</artifactid> <version>2.0.16</version> <scope>compile</scope> </dependency> here how i've set templateengine , templateresolver up: <!-- spring config --> <bean id="templater

Managing files in cloud (Dropbox, GDrive) using javascript -

i want make browser application, manage user's files in file cloud's dropbox or google drive. possible in javascript without php? how can access user's files? dive https://www.dropbox.com/developers/chooser - here valuable samples on javascript.

jquery - Autocomplete pop-up for 41.000 entries in Javascript/Html? -

i have tried use jquery autocomplete pop-up 41.000 entries select 1 of these. works far slow user perspective. is there open source library offering autocomplete capable of supporting many entries? or there other similar design/feature use have autocomplete on 41.000 entries? alternatives if no solution available? your problem not autocomplete data, solution should can index or cache results. there many indexing mechanism available, used lucene indexing perform task such heavy data.

How to convert .flac to .mp3 using PHP -

for personal website i'd implement gadget me , friends. aim of script should convert uploaded .flac audio file .mp3 choosing music quality eg 128kbit/s or 320kbit/s. possible if so, how? interesting core part (converting), rest have implement :) thanks :)) niklas are familiar ffmpeg? if installed on server, can try running on cli ffmpeg -i input.flac output.mp3 if works, can go on trying passing command application shell (if use example php application , debian linux hosting.) to include bitrate can use ffmpeg -i input.flac -ab 128k output.mp3 or ffmpeg -i input.flac -ab 320k output.mp3 if can use it, see documentation: http://ffmpeg.org/ffmpeg.html possible, have use different command bitrate depending on version.

ruby - Report/Reports on model in rails -

hi create model relations other once i'm surprised pluralize option of rails. mean. i create model this: rails g model report name:string.... like did with: rails g model patient name:string... rails g model doctor name:string.... doctor has many patients can go console , type: patient.doctor => gives me doctor patient doctor.patients => gives me patients doctor (note patients in plural) and here strange thing, did same report , expect have command: patient.reports (note plural) but instead of if want retrieve patient reports have do: patient.report (note singular)... , works! does can illuminate blindness? the methods retrieve related object(s) depends on how you've declared in model. some examples: class patient < activerecord::base belongs_to :doctor # singular end class doctor < activerecord::base has_many :patients # plural end then can do: patient.doctor # => return associated doctor if exists doctor.patients

vb.net - How to get value in the splitted string -

i have example string has been splitted using symbol "\" dim string = "123\456\7890\" dim leftstring = a.substring(0, msg.indexof("\")) textbox1.text = leftstring in textbox1 show number of "123" , , how can number of "456" , "7890"? dim string = "123\456\7890\" dim asplit string() = a.split(new [char]() {"\"c}) dim a1 string = asplit(0).trim '123 dim a2 string = asplit(1).trim '456 dim a3 string = asplit(2).trim '7890

javascript - AngularJs. $location service. Url modification -

suppose, have follwing code angularjs: angular.module('somename', []). config(function ($routeprovider, $locationprovider) { $routeprovider. when('/test/:userid', { controller: testdatactrl }). when('/users/:userid', {controller: userdatactrl}). otherwise({redirectto: '/index.html'}); $location.path('/newvalue') }); but fragment throws referenceerror: $location not defined archivarius. ok, no problem. added third parameter $location function , got error -- unknown provider: $location archivarius. so, how can instance of $location service? in other words, have ugly url like: http://localhost:7000/myservice/1?html=true#/index and routes above doesn't work, because supposed service url looks like http://localhost:7000/myservice/#/index or http://localhost:7000/myservice/index but because of internal redirect

javascript - can't fetch data from json with jquery ajax -

i started learning json using jquery , i'm having difficulties, i've spent 2 days, i've followed lots of tutorial both on youtube , blogs show isn't have in case. json different mine. got multiple keys i've 1 "news" the json response server this: { "news":[ { "id":48927, "name": "the title goes right here", "url": "www.example.com", "date":"16 august 2013", "image":"img.example.com\/image.jpg" }, { "id": 48908, "name":"the title goes right here &#8212; photography", "url":"www.example.net", "date":"17 august 2013", "image":"img.example.net\/image2.jpg" } ] } in reality server more this: {"ne

internet explorer - HTML overlay on Flash in IE 10+ -

i'm having odd problem overlaying text in div on top of flash object. know wmode parameter key ie 9 , below, , able working fine in ff, safari, ie 8 , 9, etc. code (i'm not using z-index or in css, absolute positioning): <!--[if ie]> <object width="960" height="280" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param name="movie" value="/assets/flash.swf"> <param name="wmode" value="opaque"> <![endif]--> <!--[if !ie]>--> <object width="960" height="280" data="/assets/flash.swf" type="application/x-shockwave-flash"> <!--<![endif]--> <img src="image.jpg" /> </object> <div class="copy-left" > <h2 style="color:#ffffff">title</h2> <p style="color:#ffffff">text 2</p> </div> but reason

Rails 4 - if @model.save cases -

how write if/unless statement, looks if and unless that? respond_to |format| if @request.save if @request.product.require_approval ## unless @request.project ## stuff... else other stuff... end else format.html { render action: 'new', notice: 'there error request.' } format.json { render json: @request.errors, status: :unprocessable_entity } end end thanks in advance. unfortunately don't think can combined two. example think solution clear stick if : if @request.product.require_approval && !@request.project there articles can find online suggest avoiding chaining conditions unless , why think should stay if : http://www.railstips.org/blog/archives/2008/12/01/unless-the-abused-ruby-conditional/ http://37signals.com/svn/posts/2699-making-sense-with-rubys-unless

android - Attaching listener to dialog -

i need notified when there changes on screen. using this.getwindow().getdecorview().getviewtreeobserver().addongloballayoutlistener(new viewtreeobserver.ongloballayoutlistener() { @override public void ongloballayout() { log.d("tag", "global layout"); } }); but doesn't work when dialog(custom, alert, progress, etc.) shown or dismissed. understand dialogs shown on overlay listener isn't attached them. how can desired functionality? you need dialog.setondismisslistener or dialog.setoncancellistener they'll called when related dialog dismissal happens or being canceled.