Posts

Showing posts from August, 2015

php - Get related rows in one table using a table with relations -

i have 2 tables. 1 stores content records, other 1 stores relations between content-records. table "content" table "relations" +---+-----+------+------+ +---------+----------+ |id |num |text |value | |id_local |id_foreign| +---+-----+------+------+ +---------+----------+ |1 |111 |aaa |12345 | |2 |3 | +---+-----+------+------+ +---------+----------+ |2 |222 |bbb |23456 | |2 |5 | +---+-----+------+------+ +---------+----------+ |3 |333 |ccc |34567 | |4 |1 | +---+-----+------+------+ +---------+----------+ |4 |444 |ddd |45678 | |2 |1 | +---+-----+------+------+ +---------+----------+ |5 |555 |eee |56789 | |3 |6 | +---+-----+------+------+ +---------+----------+ |6 |666 |fff |67890 | |4 |5 | +---+-----+------+------+ +---------+----------+ reading table "relations"

sql server - How to do arithmetic operations on data fields and aggregate functions in where clause? -

i'm using query return distribution of float field around average: select count(*) [count], result ( select round(result - avg(result) over(), 1) result results) group result this query returns distance between records , mean. now, need filter records out of ±3sd range. thought perhaps achieve changing query this: select count(*) [count], result ( select round(result - avg(result) over(), 1) result results having abs(result - avg(result)) over() < 3 * stdev(result) over()) group result but sql server giving me 2 errors: column 'results.result' invalid in having clause because not contained in either aggregate function or group clause. windowed functions can appear in select or order clauses. how can achieve i'm looking for? google isn't kind me today :-( as second error message indicated, windowed functions can appear in select or order clauses - rather including them in having clause, include them in inner

html - Sticky footer with the flexible box layout model? -

i trying implement sticky footer flexible box layout model implemented in recent versions of chrome , firefox. given markup inside body element: <header> header </header> <div> content </div> <footer> footer </footer> my idea use following css: html, body { height: 100%; } body { margin: 0; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; } div { -webkit-flex: 1; flex: 1; } footer { background-color: yellow; } this works fine long content less 100% of viewport height. when content becomes larger, however, chrome 28 begins paint footer on top of content. buggy behaviour (and if: how can workaround it) or css wrong? you can test chrome's behaviour here: http://jsfiddle.net/symjp/ . firefox display thing intended. chrome/chromium 25/26. if regression in recent chrome versions, bug reported? added apparent error persists in chrome

c# - Writing a generic with chaining instead of columns of grid -

i have columns in script following : <script> $("#grid").kendogrid({ height: 400, columns: [ "productname", { field: "unitprice", format: "{0:c}", width: "150px" }, { field: "unitsinstock", width: "150px" }, { field: "discontinued", width: "100px" }, { command: "destroy", title: "delete", width: "110px" } ] }); </script> i want write extension method using generic , chaining need in c# : <% page.grid<product>() .columns.add(c=> { c.add("productname").title("product name"); c.add("unitprice").title("unit price").width("150px"); }).render(); %> how can write c# method extension need use method in asp.net form. i f

playframework 2.0 - HTML attribute in Scala Template -

i java developer started learn play framework. have been trying below template working cant seem it. have got following in scala template @navitem(label: string, link1: string) = { @{if (application.isauthenticated()) { <li class="active"> <a href="@link1">label</a> </li> } else { <li class="disabled"> <a href="@link1">{label}</a> </li> } } } i calling later in template so <ul class="nav"> @navitem("search documents", "/search") </ul> the generated link has href localhost:9000/@link1 instead of localhost:9000/search . not sure whats going on. ps: if change template below works fine. want understand why above template wont work. @navitem(label: string, link1: string) = { <li class="@(if (application.isauthenticated()) "active" else "disabled")">

Android Studio with Google Play Services -

i'm trying test google play services new android studio. have project dependency google_play_services.jar. when try rebuild project following errors: information:[tstgp3-tstgp3] crunching png files in source dir: c:\users\ans\androidstudioprojects\tstgp3\tstgp3\src\main\res information:[tstgp3-tstgp3] destination dir: c:\users\ans\androidstudioprojects\tstgp3\build\classes\res-cache\tstgp3-tstgp3 information:compilation completed 2 errors , 0 warnings in 2 sec information:2 errors information:0 warnings c:\users\ans\.androidstudiopreview\system\compiler\tstgp3.3f17bd41\.generated\android_buildconfig_generator\tstgp3-tstgp3.74fc5b25\production\com\example\tstgp3\buildconfig.java error:error:line (4)error: duplicate class: com.example.tstgp3.buildconfig c:\users\ans\.androidstudiopreview\system\compiler\tstgp3.3f17bd41\.generated\aapt\tstgp3-tstgp3.74fc5b25\production\com\example\tstgp3\r.java error:error:line (10)error: duplicate class: com.example.tstgp3.r it seems

twitter bootstrap - CSS3 + HTML5SHIV + CSS3PIE Border-radius NOT working on IE8 but working on IE7,9,10 -

the site i'm working - http://www.quickseorankings.com/dev/ , built with: twitter bootstrap html5 + css3 html5shiv css3pie issue: border-radius @ navbar link(active) not working on ie8 css3pie. working on ie7,9,10 (using browserstack testing) css location: /css/ css3pie htc file location: /root/ same location index.html htc coded as: behavior: url(pie.htc); fix attempt #1: behavior: url(/pie.htc); , behavior: url(../pie.htc); tried using php 1 - behavior: url(pie.php); behavior: url(/pie.php); fix attempt #2 added htaccess: addtype text/x-component .htc fix attempt #3 used: http://fetchak.com/ie-css3/ - htc solutions different approach vs css3pie. still didn't work.. fix attempt #4 added: -pie-border-radius: 10px; not working. fix attempt #5 added: position:relative !important; zoom:1; z-index:0 !important nothing... followed other fix on forum, still didn't work.. appreciate help! fix suggestion scottsimpson: isolation test,

javascript - Change Value of Input Field when Clicking Button -

i have set of radio buttons user can click. each radio button should able populate 4 input fields different values based on button user selected. in case option 1 option 2 option 3 the radio button values should correspond following input field values (note added option 1 values default input field see jsfiddle ) option 1 #inputvaluea = option 1 - blue #inputvalueb = option 1 - red #inputvaluec = option 1 - yellow #inputvalued = option 1 - green option 2 #inputvaluea = option 2 - car #inputvalueb = option 2 - bus #inputvaluec = option 2 - train #inputvalued = option 2 - bike option 3 #inputvaluea = option 3 - cake #inputvalueb = option 3 - sugar #inputvaluec = option 3 - rice #inputvalued = option 3 - beer what looking try , figure out javascript write populate different input fields each time radio button pressed based on above values. i have created jsfiddle here see demo. my code is <!-- radio buttons --> <div data-toggle=

osx - Python and Homebrew Vim -

on mac, use macvim homebrew of editing. ~|⇒ vim --version vim - vi improved 7.3 (2010 aug 15, compiled jun 20 2012 13:16:02) compiled root@apple.com normal version without gui. features included (+) or not (-): -arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments -conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +persistent_undo +postscript +printer -profile +python/dyn -python3 +quickfix +reltime

ruby on rails - active_admin and adding multiple images to gallery -

i'm using active_admin , carrierwave gems. have 2 simple models: class image < activerecord::base attr_accessible :gallery_id, :file belongs_to :gallery mount_uploader :file, fileuploader end class gallery < activerecord::base attr_accessible :description, :title, :file, :images_attributes has_many :images accepts_nested_attributes_for :images, allow_destroy: true mount_uploader :file, fileuploader end now active_admin form gallery looks this: form |f| f.inputs "gallery" f.input :title end f.has_many :images |ff| ff.input :file end f.actions end now can upload 1 file, click "add new image" , upload one. instead of it, i'd click "add new image", select multiple files , upload them @ once. idea how can implement it? for gallery form multiple image uploads can try this admin/galleries.rb form |f| f.inputs "gallery" f.input :name end f.has_many :images |ff

AutoMapper and interface typed collections -

i'm new automapper. sorry if simple. this sample domain: i have basket. contains list of food. food either banana or pickle. i have dtos mirror each class in domain. goal: basketdto, map , contents basket. this code fails. after last line have basket, it's filled dtos instead of regular entities :( class program { static void main(string[] args) { mapper.createmap<basketdto, basket>(); mapper.createmap<pickledto, pickle>(); mapper.createmap<bananadto, banana>(); var dto = new basketdto { food = new list<ifood> { new pickledto { name = "bigpickle" }, new bananadto { name = "smallbanana" }, } }; var basketfromdto = mapper.map<basket>(dto); } } // domain classes , interfaces ----------

sql - A table still exists when dropped -

when used command worked, means table dropped drop table <table name> ; but when query sql>select * tab; my dropped tables not showing. other tables bin$+np+vhp7rf2hlc1aojf+gg==$0 are. how drop type of table? you're using recent version of oracle , table has been placed in recyclebin . rid of in first instance can use drop table <table_name> purge; to quote the documentation on drop table: specify purge if want drop table , release space associated in single step. if specify purge, database not place table , dependent objects recycle bin. ... using clause equivalent first dropping table , purging recycle bin. clause lets save 1 step in process. provides enhanced security if want prevent sensitive material appearing in recycle bin. the recyclebin can come in handy though... it's additional back-up when you've accidentally dropped wrong table. if specify purge when dropping table you'll never able ret

php - I have 3 types of search but it do dusplication -

i have 3 types of search by governorate by district by city each time user select governorate system display right answers but if user choose district duplicate result mean show same result of governorate , 1 related selected district or village but want display user have selected district or governorate or village not all code: <?php if(isset($_post['listbyq'])) { //********************by governorate**************************************// if($_post['listbyq']=="by_gov") { $bygov = $_post['governorate']; $sql = mysql_query("select user_id,first_name, last_name, birth_date, registered_date, s.specialization_name, g.governorate_name, d.district_name, v.village_name members u inner join specialization s on u.specialization = s.specialization_id

java - gmail like listView with checkBoxes: which ones are selected? -

i have list view has check box text. when checkbox gets selected, opens action mode. can delete item. question is: how can find out in deletecurrentitem() checkbox selected since don't use listview's internal checked state? public class mainactivity extends activity implements loadermanager.loadercallbacks<cursor> { private simplecursoradapter msimplecursoradapter = null; private final string[] projection = { databasehelper.key_id, databasehelper.key_title, databasehelper.key_date }; private actionmode mactionmode = null; private actionmode.callback mactionmodecallback = new actionmode.callback() { // called when action mode created; startactionmode() called @override public boolean oncreateactionmode(actionmode mode, menu menu) { // inflate menu resource providing context menu items menuinflater inflater = mode.getmenuinflater(); inflater.inflate(r.menu.context_menu, menu); return true; } // called each time

vb.net - .NET Number format - Separator on 2 digits -

number format not working expected : console.writeline(string.format("{0:##,##,##,###.####}", 12345678)) 'outputs 12,345,678 'expected output 1,23,54,678 based on format provided how expected output? if specific culture (say india) can specify in string formatter: var culture = new cultureinfo("gu-in") console.writeline(string.format(culture, "{0:##,##,##,###.####}", 12345678)) which give output: 1,23,45,678 this gujarati. other indian cultures ("hi-in" hindi, "kn-in" kannada, etc) work well.

json - Overriding default parameter names in ExtJS 4 Store -

i'm trying override default parameter name limitparam in proxy store. want make jsonp call http://search.twitter.com/search.json?q=kathmandu&rpp=2 instead of setting rpp directly want map limitparam , set it's value. it's not setting through limitparam. reason i'm doing parameter keys store sends (sort, dir, etc) not match parameters on server side (which i've no control over). in advance. ext.require('ext.grid.view'); ext.require('ext.util.point'); ext.application({ name: 'helloext', launch: function() { /*ext.create('ext.container.viewport', { layout: 'fit', items: [ { title: 'hello ext', html : 'hello! welcome ext js.' } ] });*/ console.log('ok1'); ext.define('video', { extend: 'ext.data.model', fields: ['from_user', 'from_user_

html - Variable sized banner and content under it with scroll -

this want: http://jsfiddle.net/txvxj/ <div style="position: fixed; overflow: scroll; bottom: 0; left: 0; right: 0; top: 0px; background: red;">a<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1</div> <div style="position: fixed; top: 0; left: 0; right: 0; height: height: auto; background-color: yellowgreen;"><img src="http://prog.hu/site/images/logo.gi

php - Merge two queries into single query -

i have function gets information database, namely amount of songs in songs table , amount of artists artists table have songs in song table: function getinfo() { try { $q = $this->connection->prepare('select artist_id '.tbl_song.''); $q->execute(); if ($q->rowcount() > 0) { $songs = $q->rowcount(); } else { $songs = '0'; } $q = $this->connection->prepare('select id '.tbl_artist.' exists (select * '.tbl_song.' s a.id = s.artist_id)'); $q->execute(); if ($q->rowcount() > 0) { $artists = $q->rowcount(); } else { $artists = '0'; } return "<span class='italic'>current songs: </span>".$songs." <span class='italic'>active artists: </span>".$artists; } catch (pdoexception $e) { echo result

c++ - Binary Tree (Not Binary Search Tree) Creating New Node and Children -

i trying implement method create node insert binary tree (not bst). struct node{ struct node *left; int data; struct node *right; }; typedef struct node *n; void createnewnode() { char r; // stands response (whether or not left or right child should created) int d; //data stored in node n newnode = new(struct node); //creates new node cout<<"enter data new node:"<<endl; cin>>d; newnode->data = d; cout<<"any left child? y/n"<<endl; cin>>r; switch (r) { case 's': createnewnode(); // thought make recursive , if child going created, method call on again break; case 'n': newnode->left = null; // if child not created pointer null break; } cout<<"any right child? y/n"<<endl; cin>>r; switch (r)

java - How to initialize a char array to accommodate the HTTP POST Content-Length -

i'm writing http server (for learning purposes). once receive http post request, want print parameters sent client, problem i'm sending "name=marcelo" , i'm getting incomplete result. content length: 12 char 0: char 1: char 2: n char 3: char 4: m char 5: e char 6: = char 7: m char 8: char 9: r char 10: c char 11: e here's code (js java, i.e., nashorn): //initialize array of characters var content = new chararray(contentlength); print('content length: ' + content.length); bufreader.read(content); for(var c in content) { print('char ' + c + ': ' + content[c]); } i understand content-length number of bytes of request content data (not number of characters) so, efficient way construct char array based on request's content-length? apparently you're not reading http headers before reading post body. thus, first 2 characters of content array \r , \n respectively , 2 last characters

asp.net - How to store multi-line textbox content before page is closed and retrieve it when page loads again? -

i tried find approaches in internet on how store data somewhere without saving database , found strange silence issue. i have database , web page (user form) multi-line textboxes on it. page.response.redirect reload page new parameters in address string. it's ok if data saved database. in many cases shouldn't done. , in these cases textboxes lose text. i have 3 conceptual approaches: 1) keep data in cache locally, new me, don't know how; 2) use database anyway , keep temporary data in temporary table; 3) may can use viewstate save , load state each particular control somehow. please, me find better way. if have idea, or know useful detailed article, great, guys. need practical information, abstractions no more. thank you. 1) if talking html5's local storage not compatible browsers. so, unless want leave users of ie9 , below out, have user server side approach 2) works , recommend solution if want persist data long periods 3) viewstate stor

Issue with setInterval and trigger. javascript jquery -

what trying create nav has drop down menu button, when viewport width less 600px. code using works, drop down menu stay down until screen size above 600px. right work, except if click drop down menu , change viewport size resets before click. ideas? my code $(function () { resizeok = true, timer = setinterval(function () { resizeok = true; }, 100); $(window).on('resize', function () { if (resizeok) { resizeok = false; if ($("#header").width() <= 600) { $("#nav").hide(); $(".menu").show(); $(".menu2").hide(); $(".menu").click(function() { $("#nav").show(); $(".menu").hide(); $(".menu2").show(); }) $(".m

java - unable in removing an element using iterator -

i had entered 3 elements using vector , trying remove specific elemnts list unable so. i getting following error while compiling: iterator.java:28: error: 'void' type not allowed here {system.out.println(e.printstacktrace());} ^ 1 error where doing wrong. import java.io.*; import java.util.*; import java.lang.*; class iterator { public static void main(string[] args) { vector<integer> v= new vector<integer>(); //vector<string> v= new vector<string>(); v.addelement(new integer(10)); v.addelement(new integer(20)); v.addelement(new integer(30)); //v.addelement(new string("mayank")); //v.addelement(new boolean(true)); //enumeration e = v.elements(); iterator = v.iterator(); while(i.hasnext()) { system.out.println(i.next()); } try{ v.remove(10); } catch(exception e) {s

c++ - Assign values of each line of my file to an array -

this question has answer here: read integers text file c++ ifstream 2 answers i have file has several lines , each lines have unknown integer values separated space characters. want assign each line's integers different lines of array. tried find example code there no. example input file is: 1 23 4 44 12 8 10 2 66 3 22 5 maybe mean push values array of arrays. if know number/size of vales per line, per file create statically (or allocate if not). then read values , push them array of array. just here: how work dynamic multi-dimensional arrays in c?

Why won't git ignore a bin folder in my submodule? -

git isn't correctly ignoring bin folder of 1 of submodules. ideas why? here git status in submodule: mbpr:$ git status # on branch master # untracked files: # (use "git add <file>..." include in committed) # # bin/ # gen/ here git status in root: mbpr:$ git status # on branch develop # changes not staged commit: # (use "git add <file>..." update committed) # (use "git checkout -- <file>..." discard changes in working directory) # (commit or discard untracked or modified content in submodules) # # modified: cwac-loaderex (untracked content) # here .gitignore: mbpr:$ cat .gitignore .metadata bin gen local.properties this works correctly other submodules, submodule in particular refuses ignore bin , gen folders. have deleted , re-added submodule repeatedly, no avail. thanks! each submodule being full repo on own, expect .gitignore parent repo not apply submodule. that mean need add .gitign

Chat with Node.js and socket.io -

i trying make chat in node.js , socket.io using express. tried follow tutorial here: i make personal chat, based on tutorial. in tutorial link above, user connects server after enters name prompt. want change this. basically, connect server after inserting name in output , click on button "login": // when client presses "login" $('#playerlogin').submit( function() { var uname = $('#username').val(); if (uname != "") { $('#username').val(""); var socket = io.connect('http://localhost'); socket.emit('adduser', message); return false; }); the reason want because, if connect server in advance, , add username (when clicking login) unusual happens: let's enters website, , exits it, without logging in. then, users receive "undefined has disconnected". problem. can me how solve annoying problem?

SQL Server Profiler missing after installation -

does know if there type of bug in installation of sql server 2008 r2? seems if have express edition installed, upgrade (developer, enterprise, etc.) sql server tools don't come express never show because express edition installed on computer. *even though paid enterprise edition this has happened me on 3 different computers. have copy binn folder computer works. today decided try uninstall express edition before upgrading - instead of letting microsoft handling upgrade , worked. i'm thinking maybe bug... i know question old , answered, having same problem. wanted upgrade express developer , none of these answers helped me. what i´ve done able add features is: open sql server installation center. click on maintenance > edition upgrade , follow steps. click on installation > new installation or add features existing installation , follow steps. there can add new features new version of sql server. hope helped..

css - Bootstrap collapse js file giving error -

i have following test code: <html lang="en"> <head> <meta charset="utf-8"> <title>ti productions</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- le styles --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <style type="text/css"> body { padding-top: 60px; padding-bottom: 40px; } </style> <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> </head> <body> <div class="navbar"> <div class="navbar-inner"> <div class="container"> <!-- .btn-navbar used toggle collapsed navbar content --> <a class

MS Visual Studio Unit Tests take forever to close - even if there's no code in the test -

why happening? have no code in test: [testclass] public class apiclienttest { [testmethod] public void apitestsampleusecase() { testcleanup(); } public void testcleanup() { //deleteusers(); } } yet when run this, takes ~1 minute complete. passes, takes forever. set breakpoint after deleteusers , gets hit immediately; delay after test has completed. check bin directory - incomprehensible reason, mstest copies referenced assemblies new directory every time run tests. (these safe delete, though.) maybe else causes slow down after many runs... according this answer , this documentation , can disable behaviour. i'd recommend switching nunit if possible, preferrably in combination fluentassertions (due not insignificant number of weird design decisions in mstest, such behaviour, lack of easy-to-use parameterized tests, , fact test run if [testinitialize] throws exception).

bash - sed copy substring from fixed position and copy it in front of line -

i'm dealing many csv files , can't find way sed select substring @ fixed position (chars 9-16) , copy @ beginning of line. this have: abc09638006924340017;some_text;some_other_text this need: 00692434;abc09638006924340017;some_text;some_other_text the following code in sed gives substring need (00692434) overwrites whole line: sed 's/^.{8}(.{8}).*/\1/') i'm using sed "clean" linestrings , inserting variables, called in bash script @ end imports data in postgres. why prefer remain within sed, hint appreciated i'm not real expert. you need escape curly braces ( \{\} ) parentheses ( \(\) ) , append original string ( & ) in replacement: text="abc09638006924340017;some_text;some_other_text" echo $text | sed "s/^.\{8\}\(.\{8\}\).*/\1;&/" output: 00692434;abc09638006924340017;some_text;some_other_text since want extract fixed-length substring @ fixed position, bash-builtins: text="abc0963

Correct way to set the path of a BackgroundImage in JavaFX CSS -

Image
i have anchorpane , want style giving backgroundimage have in package : here's css tried: #body { -fx-background-image:url("/images/flowerspattern_beige_background.jpg"); } using javascript set anchorpane's css id body ; didn't work. tried check other questions asked, didn't help. please can clarify how, exactly, should done? if css file loaded normally, replacing: "/images/flowerspattern_beige_background.jpg" with "../images/flowerspattern_beige_background.jpg" should work. the path relative css file's directory, .. accesses parent directory ( src ); /images refers images directory; /flowerspattern_beige_background.jpg accesses image.

c++11 - C++ memory management patterns for objects used in callback chains -

a couple codebases use include classes manually call new , delete in following pattern: class worker { public: void dowork(argt arg, std::function<void()> done) { new worker(std::move(arg), std::move(done)).start(); } private: worker(argt arg, std::function<void()> done) : arg_(std::move(arg)), done_(std::move(done)), latch_(2) {} // error-prone latch interface isn't point of question. :) void start() { async1(<args>, [=]() { this->method1(); }); } void method1() { startparallel(<args>, [=]() { this->latch_.count_down(); }); startparallel(<other_args>, [=]() { this->latch_.count_down(); }); latch_.then([=]() { this->finish(); }); } void finish() { done_(); // note manual memory management! delete this; } argt arg_ std::function<void()> done_; latch latch_; }; now, in modern c++, explicit delete code smell, as, extent delete this . however, th

Perl print unless regex and line counts -

i have working sorting through zone file automated deletions.. perl -i -ne 'print unless (/#$domainname/ , \$n=7) .. not \$n--' named.conf.ext (escaping n required work, guess else thinks main script has n variable passed?) this call within perl script , clean not having call shell re-run perl perl script it, , having main script it. not perl expert here can tell :) have tried things like open (datain, "<named.conf.ext"); open (dataout, "> named.conf.tmp"); while (<datain>){ print unless (/#foo.com/ , $n=7) .. not $n-- dataout; } close dataout; close datain; and few variants, complains syntax error @ test line 4, near "-- dataout" i'm sure i'm being spacey @ this, , answer right in front of me, 2 days, think brain needs kick start in where. thanks it's normally print dataout; which short print dataout $_; so want print dataout unless (/#foo.com/ , $n=7) .. not $n--; or longer

lucene - Elasticsearch - higher scoring if higher frequency of term -

i have 2 documents, , searching keyword "twitter". suppose both documents blog posts "tags" field. document has 1 term in "tags" field, , it's "twitter". document b has 100 terms in "tags" field, 3 of them "twitter". elastic search gives higher score document though document b has higher frequency. score "diluted" because has more terms. how give document b higher score, since has higher frequency of search term? i know elasticsearch/lucene performs normalization based on number of terms in document. how can disable normalization, document b gets higher score above? as other answer says interesting see whether have same result on single shard. think , depends on norms tags field, taken account when computing score using tf/idf similarity (default). in fact, lucene take account term frequency, in other words number of times term appears within field (1 or 3 in case), , inverted document freque

c# - Prevent Range Validator to show error message with regular expression validator in asp.net -

i have 1 textbox id txtnumofbooks validating against following 3 validators: <asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" controltovalidate="txtnumofbooks" display="dynamic" errormessage="please enter number of books" setfocusonerror="true" cssclass="style4" validationgroup="createvac"> </asp:requiredfieldvalidator> <asp:regularexpressionvalidator id="regularexpressionvalidator2" runat="server" controltovalidate="txtnumofbooks" display="dynamic" errormessage="please enter valid number" validationexpression="[0-9]\d*[0-9]" cssclass="style4" validationgroup="createvac"> </asp:regularexpressionvalidator> <asp:rangevalidator id="rangevalidator1" runat="server" controltovalidate="txtnumofbooks" display="dynamic" errormessage="n

osx - Steps to convert a new xcode cocoa project using 1 controller per nib -

i want start off new xcode project using 1 nib per controller. default seems xcode creates: 1. delegate .h/.m 2. mainmenu.xib and looking @ targets project, see 'main nib file base name' set mainmenu, principal class nsapplication. since cocoa mvc based, how things mvc based on default template? how can wire things 'mainwindowcontroller' instead of default setup? if can explain steps me appreciated. you don't want subvert or change default setup, understand , work within it. mvc description of responsibility rather hard requirement naming. the delegate .h/.m app delegate name, responsibility app controller. gets setup when app starts , deals application level events. shouldn't isn't related application level management. the mainmenu.xib container / archive of first views , controllers created when application opens. there no model in template display main window static string on it... your goal of using 1 nib per controller

java - What is the correct path to display an ImageIcon png file for Windows 7? -

Image
i wanted test having program simple png image on it. wrote short program this, can't seem path right. have checked, checked again, rechecked, , quadruple checked path name not right, image not display, no matter do. used short class wrote oracle in imageicon documentation (the creaetimageicon() ) accomplish this, doesn't seem help. i'll post entire program below, short. package practiceimages; import java.awt.borderlayout; import java.awt.toolkit; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jlabel; public class imageiconguitest { public static void main(string[] args) { imageiconguitest gui = new imageiconguitest(); gui.display(); } private imageicon createimageicon(string path, string description) { java.net.url imgurl = getclass().getresource(path); if (imgurl != null) { return new imageicon(imgurl, description); } else { system.err.println("couldn&#

c - String formatting, strtok issues -

i'm working on program separates words in string, , prints each word on different line. having difficulty output. ex. "this string" prints ""this "is" "a" "string" " instead of "this" "is" "a" "string" code: #include <string.h> #include <stdio.h> void wholestring(char s[]) { int i; (i=0; i<strlen(s); ++i) { } return; } int main(){ const int mysize = 100; char mystr[mysize]; char *newstr; fgets(mystr, mysize, stdin); wholestring(mystr); newstr = strtok (mystr, " "); while (newstr != '\0'){ printf ("\"%s\" \n", newstr); newstr = strtok ('\0', " "); } return 0; } there 2 problems seeing in code newstr = strtok (mystr, " "); this have issues if input within quotes example "this string" instead