Posts

Showing posts from March, 2014

.net - TDD: Number of Asserts, and what to actually assert? -

i writing tests using tdd , have come against few queries. normally when writing unit tests, used use 1 assert per unit tests defined practice , easy see why test failing. in tdd, practice same, if case design 1 method using tdd going end more 1 unit test - need more 1 assert. the other concern assert ? i assert think return object ? so have create return type (could complex many properties) , ensuring these match on assert, technically 1 assert. or other way ensure mocks have made along way being called i.e. en moq following myservicemock.verify(x => x.itemsreceived(), times.once()); so can ensure method called once on mock, classed assert. goes original query, 1 assert per unit test need create additional unit tests ensure other methods on other mocks being called. what else doing here ? do assert methods called on mocks or values being returned expect. really forward input has on this. i see question has different concerns cover. first, r

Adding custom java rule to pmd maven plugin -

i've wrote custom rule pmd (in java). want rule executed in project. i've added rule pmd.xml: <rule name="myrule" message="some message" class="myrule"> <description> description </description> <properties> <property name="someproperty" value="1" /> </properties> <priority>3</priority> </rule> and there problem appeared. didn't know place rule definition - myrule.class. trying add maven dependency pmd: <dependency> <groupid>pmd.rules</groupid> <artifactid>customjavarules</artifactid> <version>1.0</version> </dependency> where customjavarules jar artifact (from local "file://" repo) containing myrule.class. jar found , loaded myrule.class still invisible pmd. i trying place class in various directories... poor results. has ever had similar p

css - Bootstrap dropdown content to the right of link -

Image
i making bootstrap mega menu in navigation meant floating left. have changed float right using pull-right class provided bootstrap dropdowns still appearing if nav still floating left. how can adjust dropdown content reflect floating change? attached image of problem: as can see dropdown caret arrow pointing @ merchandising off little bit, can adjust. content of dropdown should right of nav item, not left. bootstrap styles default, except following css: .dropdown-menu { position: absolute; top: 100%; left: -1px; z-index: 1000; display: none; float: left; min-width: 160px; padding: 10px 10px; margin: 0px 0 0; list-style: none; background-color: #fff; border-top: transparent; border-left: 1px solid rgba(0, 0, 0, .1); border-right: 1px solid rgba(0, 0, 0, .1); border-bottom: 1px solid rgba(0, 0, 0, .1); -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; -webkit-box-shadow: 0 0px 0px rg

android - How do I add a rotating spinner to my webview? -

i have made webview in require add loading /rotating spinner. have image same, not sure how go such when webview loads starts rotating , when entire view loaded stops. here code far: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_search_answers, container, false); mwebview = (webview)view.findviewbyid(r.id.webview); mwebview.setvisibility(view.visible); mwebview.setwebviewclient(new mywebviewclient(this, mwebview)); mwebview.getsettings().setpluginstate(pluginstate.on); mwebview.getsettings().setusewideviewport(true); mwebview.getsettings().setdefaultzoom(zoomdensity.far); mwebview.getsettings().setbuiltinzoomcontrols(true); mwebview.getsettings().setsupportzoom(true); mwebview.getsettings().setjavascriptcanopenwindowsautomatically(true); mwebvi

c# - why when creating a hash do you convert text to byte -

can please explain why 99% of time when creating hash, convert data byte[]. have been looking answer question, websites have viewed explain how create hash. i have seen sites using stream or chars, 99% of examples convert byte[]. sorry if seems newbie question, newbie , i'm curious reason why me better understand reason. thanks george hash functions operate on byte streams (or arrays). how defined. text in cases unicode , needs transformed particular utf first before have byte representation can work with.

java - PayPal IPN returns INVALID on live and VERIFIED on sandbox -

i have been trying implement paypal ipn system in our company website. when test script in ipn sandbox tool, validated , goes well, when move live, ipn returned invalid payment has been completed well. when check ipn history in account, can see ipn message http response 200: mc_gross=0.01&invoice=40&protection_eligibility=ineligible&item_number1=&payer_id=mypayerid&tax=0.00&payment_date=08:06:52 sep 03, 2013 pdt&payment_status=completed&charset=windows-1252&mc_shipping=0.00&mc_handling=0.00&first_name=myname&mc_fee=0.01&notify_version=3.7&custom=18528&payer_status=verified&business=bussiness_mail&num_cart_items=1&mc_handling1=0.00&verify_sign=aj.hl1f2a9aobifqcln.3j-qkkqgaf.rvw8er5rbgj6ssqfwbbsturtd&payer_email=mymail&mc_shipping1=0.00&tax1=0.00&txn_id=61052338b4613440h&payment_type=instant&last_name=mysurname&item_name1=paquete lite&receiver_email=mybussiness_mail&pay

How to edit CSS class via jQuery if statement -

i have if statement checks url "ivnt", div "carriage-promo" have height changed it's dafault of 0px, 40px. i not want add class or remove class, know how achieve , doesn't solve problem i'm afraid. consider: $(document).ready(function () { if(window.location.href.indexof("invt") > -1) { $('#promo-carriage').css{ height: '40px'} } }); however, not working me. suggestions? i'm quite sure syntax error, i'm new jquery/js! use parenteses .css() , height inside quote. $(document).ready(function () { if(window.location.href.indexof("invt") > -1) { $("#promo-carriage").css("height", "40px"); } });

solr - Adding filter queries (FS) to a soler query using solrj -

i trying query solr using solrj , can't seem find way , fq argument code here http request trying run select?wt=json&indent=true&fl=name,store&q=*:*&fq=!geofilt%20pt=45.15,-93.85%20sfield=store%20d=5} and here code solrserver server = new httpsolrserver("the host"); solrquery query = new solrquery(); query.setquery( "*" ); query.setparam("fl","name,price"); how add setparam fq "!geofilt pt=45.15,-93.85 sfield=store d=5" assume line query.setparam("fq","the fq field") nothing seems work me. thanks, shimon can use addfilterquery ? solrquery query = new solrquery(); query.setquery( "*" ); query.setparam("fl","name,price"); query.addfilterquery("{!geofilt pt=45.15,-93.85 sfield=store d=5}");

java - How to implement TCP connection handshaking with Spring Integration? -

i'm new spring integration , trying receive data devices on tcp. i've come following spring context: <bean id="serializer" class="com.somepackage.customserializer"/> <int-ip:tcp-connection-factory id="connectionfactory" type="server" port="${tcp.socket.connection.listener.port}" deserializer="serializer" /> the problem device's protocol upon initial connection sends handshaking sequence , expects magic answer before starts sending messages . a message pattern different handshaking sequence, cannot implement serializer distinguish between these two. if implement handshaking process interceptor. tried implement statefull serializer turned out serializers singletons, shared between different connections. could please advise how perform custom negotiation (handshaking) before default mechanisms (split

git - Error: 'Access Denied' from jslint on a jenkins job -

Image
i running jenkins job, jslint plugin. build fails following error, access denied @ workspace. should give file permission workspace? using git check out project , files checked out well. can 1 give me directions bellow mentioned error? started user anonymous building in workspace c:\program files\jenkins\jobs\test\workspace checkout:workspace / c:\program files\jenkins\jobs\test\workspace - hudson.remoting.localchannel@10d4b20 using strategy: default last built revision: revision 13460c60318e0c4859473d848dd81f76073fe34e (origin/master, origin/head) fetching changes 1 remote git repository fetching upstream changes origin seen branch in repository origin/head seen branch in repository origin/master seen 2 remote branches commencing build of revision 13460c60318e0c4859473d848dd81f76073fe34e (origin/master, origin/head) checking out revision 13460c60318e0c4859473d848dd81f76073fe34e (origin/master, origin/head) warning : there multiple branch changesets here [jslint] ready [jslint] c

sql server - SQL - If two records have same value in two columns, add third column -

i have table these values: col1 | col2 | col3 | 1 | 2 | 3 | 4 | 5 | 6 | 4 | 7 | 8 | 4 | 7 | 9 | i want make query returns row every record in col1 , col2 both different in every other record, if both same in 2 records, result should 1 single row values in col1 , col2 , col3 sum in third column. result should be: col1 | col2 | colnew | 1 | 2 | 3 | 4 | 5 | 6 | 4 | 7 | 17 | thank you. use group by on columns want "group by" (1 , 2 in case). use sum on column want "sum" (3 in case). select a.col1, a.col2, sum(a.col3) colnew test group a.col1, a.col2; sqlfiddle: http://sqlfiddle.com/#!3/070a3/4

io - How to write an array to file in C -

i have 2 dimensional matrix: char clientdata[12][128]; what best way write contents file? need update text file on every write previous data in file cleared. since size of data fixed, 1 simple way of writing entire array file using binary writing mode: file *f = fopen("client.data", "wb"); fwrite(clientdata, sizeof(char), sizeof(clientdata), f); fclose(f); this writes out whole 2d array @ once, writing on content of file has been there previously.

html - Height auto doesn't work even with clearfix -

probably not first time see question... can't solve problem. here live version http://jsfiddle.net/lndeh/ if change height .projectwrap , see trying achieve. have tried add clearfix etc. html <div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>sometext</span></a></div> </div> <div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>some text</span></a></div> </div> <div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>some text</span></a></div> </div>

c++ - Why doesn't myString.at(myString.length()) work? -

i'm including <string> library @ top of .cpp file when test out cout<<mystring.at(mystring.length()); it should print out last letter of string, or @ least think should. compiler throws hissy fit , spits bunch of jargon @ me. i'm used writing in javascript i'm not used to, well....having rules, me makes perfect sense return last character of string. string indexes zero-based run [0..mystring.length()-1]. should use mystring.at(mystring.length()-1); to last character

javascript - Disjunction of filters in ajax, request to flask-restless -

i have backend application flask-restless replies json data. set. request these data javascript $.ajax function. works perfect 1 filter, need more filters, don't know how them set. example 1 filter (it works): var page = 1; var filters = [{"name": "device", "op": "eq", "val": 1}]; var url = 'http://..../results?page=' + page; $.ajax({ url: url, data: {"q": json.stringify({"filters": filters})}, datatype: "jsonp", type: "get", contenttype: "application/jsonp", success: function(responsedata, textstatus, xmlhttprequest) {...} }); for 2 filters tried (it doesn't work): var page = 1; var filters = [{"name": "device", "op": "eq", "val": 1},{"name": "device", &q

xsd - Declaring an attribute for a different namespace in XML Schema -

i've been using xml format mix of different existing formats , custom elements , attributes, , thought should write schema custom bits. one thing use custom attributes on elements in existing formats, this: <ns1:something atta="b" attb="a" ns2:extraatt="c"/> i understand doing allowed cannot think how declare "extraatt" in xml schema or, worse, in dtd. i have tried reading specification , written in chinese far concerned. tutorials talk "name", "type", , "use", e.g. this one , that one . each schema document defines components (pieces of schema) 1 namespace. define attribute ns2:extraatt want schema document one: <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" targetnamespace="http://example.com/my-ns2"> <xs:attribute name="extraatt" type="xs:anysimpletype"/> </xs:schema> the declaration of element ns1:something

php - Parse XML File that is Dyanamically Generated -

i integrating api our monitoring software (prtg) our website , attempting use function generates list of data in xml format. generated needed, url doesn't point existing file. i tried using "simplexml_load_file" , "simplexml_load_string" , passing url no luck. i've tried use "file_put_contents" first save file, fails since url doesn't point file. how can made work? <?php $prtg_url = "http://prtg.domain.net:8080/"; $prtg_user = "username"; $prtg_hash = "passwordhash"; function getsensordata($deviceid) { $sensor_xml_file = $globals['prtg_url'] . "api/table.xml?content=sensors&output=xml&columns=objid,type,device,sensor,status&id=" . $deviceid . "&username=" . $globals['prtg_user'] . "&passhash=" . $globals['prtg_hash']; file_put_contents("sensor.xml", fopen($sensor_xml_file, 'r')); $sensors = simple

php - Two posts in same div - WP loop -

i need following in wordpress: <div class="posts-wrapped"> <div id="post-1" class="post"> <h1>title 1</h1> </div> <div id="post-2" class="post"> <h1>title 2</h1> </div> </div> <div class="posts-wrapped"> <div id="post-3" class="post"> <h1>title 3</h1> </div> <div id="post-4" class="post"> <h1>title 4</h1> </div> </div> i know how posts wp loop, how can wrap every 2 posts in .posts-wrapped div? i fetch posts wp_query. thanks! edit: tried few ways it. example this: $index=0; <div class="posts-wrapped"> <?php while ( have_posts() ) { $index++; ?> <div class="post"> <h1><?php the_post(); ?></h1> </div> <?php if(

ERROR while connecting JDBC -

import java.sql.*; public class jdbcdemo { /** * @param args */ public static void main(string[] args) { // todo auto-generated method stub try { class.forname("oracle.jdbc.driver.oracledriver"); connection c=drivermanager.getconnection("jdbc.oracle:thin:@hp-hp:1521:xe","system", "ashu41228"); if(c!=null) { system.out.println("database created"); } } catch (classnotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (sqlexception e) { // todo auto-generated catch block e.printstacktrace(); } } } java.sql.sqlexception: no suitable driver found jdbc.oracle:thin:@hp-hp:1521:xe @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ jdbcdemo.main

C# .NET BitConverter doesn't work for SQL Server stored VarBinary read -

we're storing integer in our sql server 2008 database varbinary . using entity framework, when reading varbinary value, returns, c# code, byte array. yes. know doesn't make sense store integer varbinary in database right off. there reason storage method. hence, integer value of 10762007 0xa43717 if examined table select statement. actual value in our code after reading byte array is: byte[] b = new byte[]{0, 164, 55, 23}; now, uninitiated might think simple conversion integer be: int myint = bitconverter.toint32(b); ...which not produce desired results. i figured problem out doing following: string bitstring = string.empty; string[] bitarray = new string[4]; ( int = 0; < 4; i++) { bitarray[i] = convert.tostring((int)b[i],2).padleft(8,"0"); bitstring += bitarray[i]; } int therealint = convert.toint32(bitstring,2); which taking integer representation of hex values, converting them bit string, appending them appropriately, , converting

ember.js - Handlebars data appearing outside of placeholders -

(this double-post of identical question on emberjs discuss forums.) when handlebars template {{value}} somewhere browser doesn't reasonably expect plain text, such <table>, seems behave in unexpected ways. i've created example page source , included below. can explain going on or why happening, , whether or not behavior intentional? to clarify, i'm not looking quick way around this. know how (as can see first text in example) i'm curious whether knows whether behaviour intentional or not - , why. example link: http://tinyurl.com/handlebarsplaceholders given table element should contain content in 'tr', 'th', , 'td' tags, assumption ember not able manipulate dom. try adding row , column , dropping value in. <table> <tr> <td>{{value}}</td> </tr> </table>

c++ - Expected class-name before '{' token -

when trying compile project header file (bobjr) code::blocks gives me error expected class-name before '{' token. wrong code? #ifndef bobjr_h #define bobjr_h class bobjr: public bob { public: bobjr(); }; #endif // bobjr_h this bobjr cpp: #include "bobjr.h" #include "bob.h" #include <iostream> bobjr::bobjr() { //ctor } you're missing definition bob . either need in same header of need #include header declares bob before declaring bobjr

objective c - OSX: Set App Icon Number -

this question has answer here: how draw badge on dock icon using cocoa? 3 answers this seems common question , searched it, came dry. whenever email or message on outlook, skype, etc. osx puts red number on icon number of messages received. how can set number own app? look @ link nsdoctile class reference. may need sign in it, unsure that. nsdoctile class reference edit: method name -(void) setbadgelabel: (nsstring *) string; looks may want.

django - Passed parameters without being encrypted -

i'm using django manage website ids post id, user id passed in clear. example can have /posts/1, /posts/2/ even if check if current user can read related post, secure pass parameters or should /posts/lkjfekj87dokdz98/ corresponds /posts/1/ example ? example of detail view called /post/1/ class detailview(generic.detailview): model = post def get_context_data(self, **kwargs): context = super(generic.detailview, self).get_context_data(**kwargs) if context['post'] not in self.request.user.allowed_post: raise permissiondenied return context i've found answer. technique named obfuscations. can used example https://pypi.python.org/pypi/django-unfriendly

video.js black stroke/border removal -

we've implemented video.js on http://www.hetlandgoed.be/realisaties/ strange thing black border gets added. can strip away top , bottom ones, not left , right ones. we're new this, appreciated! the video itself has blank lines @ left , right edges. can see if play in quicktime/vlc etc. the borders top , bottom because video element different aspect ratio - perhaps did intentionally balance out. ideally need new video without lines. otherwise hide video edges css: .video.carousel { width: 934px; margin-left: 3px; } #my_video_1 { margin-left: -3px; }

knockout.js - How can I change knockout validation based on an event -

i'm using knockout validation validation on form such: html <div> <span>client</span><input type="text" data-bind="value:client" /> </div> <div> <span>ismarried</span><input type="checkbox" data-bind="value:ismarried" /> </div> <div> <span>spouse</span><input type="text" data-bind="value:spouse" /> </div> js function household() { var self = this; self.client = ko.observable().extend({required:true}); self.ismarried = ko.observable(); self.spouse = ko.observable().extend({required:{ onlyif:function(){ return self.ismarried();}}}); } currently, when ismarried checkbox gets checked, spouse field wont validate until value has been entered cleared. is there way can modify bindings on knockout viewmodel based on event or otherwise make validation happen sooner? you use ko.validation.gro

Android 4.3 Virtual Device CPU/ABI - No system images installed (eclipse) -

Image
i'm trying set new device, can not continue process. think it's because target version 4.3. i know need download android sdk manager . can see has been installed reinstall arm eabi v7a system image , intel x86 atom system image again restart eclipse think work

How to implement the following Alloy model in Alloy API? -

i have following alloy model , i'm not sure how cenvert alloy java api. sig a{ b: int } i know can use a.addfield("b", expr) add atribute, should put in expr parameter make represents integers? thanks it easier parse entire alloy model string instead of creating ast manually. see post example. example uses computil.parseeverything_fromfile(..., <file_name>) but can replace computil.parseonemodule_fromstring("sig a{ b: int}") to parse directly string (note return type in latter case list<command> , , not compmodule in linked example, shouldn't problem you).

c# - Call C++ dll from two machine -

i have 1 c++ dll want call 2 machines. 1 machine sends data dll , want read data dll. when read data second machine returns zero. solve problem, must use shared memory? or need change in c++ dll? regards. dll's non executable. need program loads dll , uses it. communicate across computers common practice use sockets. since marked c# i'll assume on windows. can use winsock (c++ win32) or system.net.sockets sending data across computers. shared memory such memory files not work cross computer.

python - Adding the result of an array in a csv file -

i tried make algorithm: random draw between 0 , 1(tir).si tir '<'pred xestime2= 1 else xestime2=0. wish apply algorithm in df ['x3'] had 0 in values ​​of x3 columns. explains thats have error in code. coding: df = pd.read_csv(fname3, header=none) print df[:15] df['x2'] = df['x1'].round() print df[:15] s = stringio() df.to_csv("c:/users/lenovo/desktop/nouveau dossier (2)/resultats2.csv", header=none, index=false) #print(s.getvalue()) ##########################################"""""""" row in df['x1']: x = np.random.randint(0,2,10) row1 in x: if row1 < row: df['x3']=0 else: df['x3']=1 #print df[:15] df.to_csv("c:/users/lenovo/desktop/nouveau dossier (2)/resultats2.csv", header=none, index=false) since you've tagged pandas, i'll use read_csv : in [1]: df = pd.read_csv('foo.csv', h

grammar - Is there a better way to specify optional elements in rules of a CFG? -

consider language , compiler design , develop it. in language there particular statement part of grammar: (=<identifier>) . piece can recognized compiler. spaces allowed between brackets , equal sign , identifier. have these possibilities: (=<identifier>) ( = <identifier> ) (=identifier ) ( =identifier ) ... without considering whole grammar rules handle language feature, have (in bison-like syntax grammar rules): statement: obrckt eq id cbrckt | obrckt s eq s id s cbrckt | obrckt s eq id s cbrckt | obrckt s eq s id cbrckt | obrckt s eq id cbrckt | obrckt eq s id s cbrckt | obrckt eq id s cbrckt | obrckt eq s id cbrckt | ... the space terminal s can appear or not. way rules are, need specify possible combinations... there better way achieve result? as jim commented, use lexical tool handle these cases instead of writing them productions of grammar. for example, commonly use

jquery - Javascript: should I remove an event handler when removing the related HTML? -

this question has answer here: do need unbind jquery event before remove element? 3 answers i have following html on page: <div class="component"> <a href="#" class="delete">delete</a> </div> and have following script @ page load: $(document).ready(function(){ $('a.delete').on('click', function() { .... }); }); this page has other javascript code manipulates page , removes via: $('.component').remove(); my question: need remove (unbind) event handler before removing html? if not, there memory leak or other impact? thanks , regards! because you're using jquery, don't need worry it. similar .empty() , .remove() method takes elements out of dom. use .remove() when want remove element itself, inside it. in addition elements themselves, all boun

artificial intelligence - How to go about creating a prolog program that can work backwards to determine steps needed to reach a goal -

i'm not sure i'm trying ask. want able make code can take initial , final state , rules, , determine paths/choices there. so think, example, in game starcraft. build factory need have barracks , command center built. if have nothing , want factory might ->command center->barracks->factory. each thing takes time , resources, , should noted , considered in path. if want factory @ 5 minutes there less options if want @ 10. also, engine should able calculate available resources , utilize them effectively. 3 buildings might cost 600 total minerals engine should plan command center when have 200 (or w/e costs). this have requirements similar 10 marines @ 5 minutes, infantry weapons upgrade @ 6:30, 30 marines @ 10 minutes, factory @ 11, etc... so, how go doing this? first thought use procedural language , make decisions ground up. simulate system , branching , making different choices. ultimately, choices going make impossible reach goals later (if build

c# - TFS API not returning results in MVC application -

i have code retrieve changesets tfs server. code works great in console application. code looks this: tfsteamprojectcollection tpc = new tfsteamprojectcollection(new uri("http://tfs.....")); tpc.authenticate(); versioncontrolserver vcs = tpc.getservice<versioncontrolserver>(); versionspec = versionspec.parsesinglespec(versionfromstring, null); versionspec = versionspec.parsesinglespec(versiontostring, null); var histories = vcs.queryhistory( path + "/*.cs", versionspec.latest, 0, recursiontype.full, null, from, to, int32.maxvalue, true, true, true); foreach (changeset history in histories) { foreach (change change in history.changes) { // results here.... } } but when move code inside mvc application, there no error, returns empty list of histories @ line: foreach (changeset history in histories) i thought due insufficient privileges, used impersonation of network service. code not complaining impersonation, still

c# - Pass the file name of a saved file from one class to another -

i'll best explain. my program takes screen shots user can save desktop or pass media server. however, pass server first must have file location of image saving , must first save file using save file dialog , store location of in string triggers bool image has been save. code looks pass file server: // sfd safe file dialog uploadtoserver.httpuploadfile(settings.default.serveraddress , sfd.filename.tostring(), "file", "image/jpeg", nvc); i tried store sfd in following way pass call class: public string saveimagelocation { { return sfd.filename.tostring(); } set { sfd.filename.tostring() = value; } } but following error: error 1 left-hand side of assignment must variable, property or indexer what i'm trying achieve take file upload code , move class. can me error? this method/function (call). tostring() you cannot assign method/function (call) value.. .tostring() = value; try public string saveimagelocation {

sql - Need query to select direct and indirect customerID aliases -

i need query return related alias id's either column. shown here alias customer ids, among thousands of other rows. if input parameter query id=7, need query return 5 rows (1,5,7,10,22). because aliases of one-another. example, 22 , 10 indirect aliases of 7. customeralias -------------------------- aliascuid aliascuid2 -------------------------- 1 5 1 7 5 7 10 5 22 1 here excerpt customer table. customer ---------------------------------- cuid cufirstname culastname ---------------------------------- 1 mike jones 2 fred smith 3 jack jackson 4 emily simpson 5 mike jones 6 beth smith 7 mike jones 8 jason robard 9 emilie jiklonmie 10 michael jones 11 mark lansby 12 scotty slash 13 emilie jiklonmy

sql - Mysql group by in a CSV field -

what's best way perform group statement in csv-like column using sql (mysql)? table products color +-------------+--------------+ | product id | color | +-------------+--------------+ | 120 | red, blue | | 121 | green, black | | 122 | red, black | +-------------+--------------+ from table above need count how many times color appears , return this: +-------------+-------+ | color | count | +-------------+-------+ | red | 2 | | blue | 1 | | green | 1 | | black | 2 | +-------------+-------+ is possible without normalize database? if can't change table structure, can create table lists colors, use query: select colors.color, count(*) products inner join colors on find_in_set(colors.color, replace(products.color, ' ', ''))>0 group colors.color see working here . please notice can't optimized because can't make use on index.

css3 - CSS 3d transform perspective grid -

trying create block grid 3d transformed @ angle, when hover 1 of elements rotates in facing towards user. below see not-very-well working example (chrome - work safari too?). so have couple of problems think can notice them too, hope solvable @ all; rotating blocks towards user doesnt work well. perspective seems wrong: on last rows looks going different angle. , need scale(1,1.9) shouldn't necessary think, else small height. the perspective changes drag screen smaller size... finally animation (in chrome) doesn't go fluently. does, on occasions block first stretches , rotates @ once how solve this? or did build before? you can see mean here on jsfiddle (make run-screen wide) css: body{ -webkit-perspective: 1000; background:black; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } #grid{ margin:au

jquery datepicker range disable field -

i have 2 input fields. 1 datepicker range , other datepicker month only. want month input field (also month datepicker) become disabled if user selects date range... ive tried many things , tried searching no luck.. maybe can turn me in right direction.. in simple terms... if selects 1st input field (#daterange) want 2nd input field (#monthselect) disabled , want datepicker disabled on #monthselect thanks jquery datepicker: new picker.date.range($$('input[id="daterange"]'), { timepicker: false, columns: 2, format: '%y/%m/%d', positionoffset: {x: 0, y: 0}, onselect: function(date){ $('#monthselect').attr("disabled",true); } }); new picker.date($$('input[id="monthselect"]'), { positionoffset: {x: 0, y: 0}, pickonly: 'years', pickonly: 'months', format: '%y/%m', usefadeinout: !browser.ie }); my input field

How to read many input files in AWK? -

this question has answer here: awk: extract different columns many different files 3 answers i try understand how read many input files in awk puzzle "how can print 1st column file 1 , 2nd column file 2? input $ cat test1 1 4 2 5 3 6 $ cat test2 b c d e f goal $ awk **answer** 1 b 2 d 3 f awk 'nr==fnr{a[nr]=$1;next} {print a[fnr], $2}' file1 file2

angularjs - Angular dialogue box not resizing correctly -

folks, so using angular dialogue box, however, setting custom size dialogue box ruins format inside box. i have created plunkr this. http://plnkr.co/edit/yxf1knmqhado3im8dfby if @ "save" , "cancel" buttons, appear somewhere near center of page though part of modal-footer. does know how resolve this. thanks in advance they appearing right because modal-footer has css property set text-align: right . flow off of plunker because model-body being set 800px in code here: modal.css("width",'800px'); . you can add style override if want: .modal-footer.left { text-align:left; } updated plunker hope helps.

c# - Is there a way to improve copy of folder structure to a network location -

if copying many folders files inside can better create zip/rar folder , files, copy network path , unzip it. works faster copy paste is there way programatically , embed windows can try detect way faster , use 1 (normal way or "compress on fly") improve speed "compression on fly" waste unless there on other end can perform decompress or if compressed state acceptable. said: yes, can write app zips/rars files. yes, can have app copy zip/rar network directory. yes, can have app on other end wait file , unzip locally... can have detect "which way faster"?? although possible unlikely of benefit other large files... @ point should zip/rar , transfer...which make entire exercise rather pointless. of course, should evaluate data transferred using app see if candidate compression. video, example, might not be... more point here, each end have have application aware of each other (or @ least protocols involved). 1 app (we'll call

google api - Beginner node.js app using passport + googleapis -

i'm working node.js try , make book library app using google books api , passport google strategy authentication. far can authenticate , access api. maybe silly question, how data use on collection view? have access google data after authentication , need redirect collection how build data new view? app.get('/auth/google', passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/books', 'https://www.googleapis.com/auth/userinfo.profile'] })); app.get('/auth/google/callback', passport.authenticate('google', {failureredirect: '/'}), function (req, res) { // successful authentication, data , redirect user collection googleapis.discover('books', 'v1').execute(function (err, client) { oath2client.credentials = { access_token: req.user.accesstoken, refresh_token: req.user.refreshtoken }; var req1 = client.books.mylibrary.bookshelves.list().withauthclient(oath2cli

multithreading - How do I run the same linux command in more than one tab/shell simulataneously? -

is there tool/command in linux can use run command in more 1 tab simultaneously? want run same command: ./myprog argument1 argument2 simultaneously in more 1 shells (i want increase put code under stress later on) check if mutexes working fine in threaded program. i kind of looking wall does. can think of using tty's, seems lot of pain if have scale many more shells. why not like for in {1..100} ./myprog argument1 argument2 & done this in case shell bash. can other looping constructs in case of other shells.

php - PHPMD avoid static access to parent -

is there way avoid parent:: static accessor in php classes, or 1 of times use @suppresswarnings(staticaccess) ? on same lines, seems staticaccess warning popping in suspicious places. exception handling, instance - when throw new exception(...) , phpmd complains static access. but...there's not way (that i've found) i've got more warnings suppressors i'd like. normal? edit as requested, here's example - it's pretty straightforward: class aaa { private $somereasonforanexception = true; public function __construct() { echo 'aaa<br>'; if ($this->somereasonforanexception) { throw new exception("something happened that's worth noticing!"); } } } class bbb extends aaa { public function __construct() { echo 'bbb<br>'; parent::__construct(); } } $bbb = new bbb(); phpmd report 2 errors above: staticaccess error on exception , , s

android - WebView is not able to show Website -

here code: xml <webview android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" /> mainactivity.java excerpt @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); webview mywebview = (webview)findviewbyid(r.id.webview); mywebview.loadurl("http://www.google.com"); mywebview.setwebviewclient(new webviewclient()); } this should show google page upon starting app. every time run this, error of "webpage not available, webpage might temporarily down or may have moved new web address, etc" any ideas? make sure connected internet , have following permission in manifest: <uses-permission android:name="android.permission.internet"></uses-permission>

c# - How do I declare a Jagged array of 2 dimensions? -

i m trying declare 2d dynamic array below code: var marray= new[,] { { "1", "module 1.1", "module 1.2", " module 1.3", "module 1.4", "module 1.5" }, { "2", "module 2.1" } }; i getting error on second value "an array initializer of '6' expected" . can understant expecting 2nd having 6 values need dynamic of length. dont know array cannot resolve it. can please guide. thanks you're receiving compile error because sub-a

arrays - Matlab: Return input value with the highest output from a custom function -

i have vector of numbers this: myvec= [ 1 2 3 4 5 6 7 8 ...] and have custom function takes input of 1 number, performs algorithm , returns number. cust(1)= 55, cust(2)= 497, cust(3)= 14, etc. i want able return number in first vector yielded highest outcome. my current thought generate second vector, outcomevec , contains output custom function, , find index of vector has max(outcomevec) , match index myvec . wondering, there more efficient way of doing this? what described way it. outcomevec = myfunc(myvec); [~,ndx] = max(outcomevec); myvec(ndx) % input produces max output another option loop. saves little memory, may slower. maxoutputvalue = -inf; maxoutputndx = nan; ndx = 1:length(myvec) output = myfunc(myvec(ndx)); if output > maxoutputvalue maxoutputvalue = output; maxoutputndx = ndx; end end myvec(maxoutputndx) % input produces max output those pretty options. you make fancy writing general purpose function takes i

linux - Understanding input and output in ASM -

can please me understand happening here? new assembly language , have written simple code follows: (i developing on linux) what want accept integer user , display user has entered. .section .data number: .long 0 .section .text .globl _start _start: movl $3, %eax #read system call movl $0, %ebx #file descriptor (stdin) movl $number, %ecx #the address data read into. movl $4, %edx #number of bytes read int $0x80 #the entered number stored in %ebx. can viewed using "echo $? " movl number , %ebx movl $1, %eax int $0x80 but not getting expected result. instead getting ascii codes character inputting. for ex: input - 2 output - 50 input - 1 output - 49 input - output - 97 .... , on? what wrong? changes should make have desired result? basic concept missed understanding. input done in system's native codepage. if want convert numeral's ascii code corresponding

java - Allowing User to Resize JScrollPane -

when user moves cursor on border of jscrollpane , can turn cursor 2 little arrows pointing @ opposite directions of each other user may shrink or grow entire jscrollpane ? jscrollpane scrollpane = new jscrollpane(buddylist, scrollpaneconstants.vertical_scrollbar_as_needed, scrollpaneconstants.horizontal_scrollbar_as_needed); layoutconstraints.gridx = 0; layoutconstraints.gridy = 0; layoutconstraints.gridwidth = 3; layoutconstraints.gridheight = 8; layoutconstraints.fill = gridbagconstraints.both; layoutconstraints.insets = new insets(10, 6, 10, 36); layoutconstraints.anchor = gridbagconstraints.northwest; layoutconstraints.weightx = 0.8; layoutconstraints.weighty = 1.0; layout.setconstraints(scrollpane, layoutconstraints); add(scrollpane);//adds scrollpane straight panel class extends jpanel you looking @ wrong place. if want allow resizing of scrollpane, scrollpane wrong object at. it’s responsibility of parent container (or layout manager) give or take spac

ruby - Rails with HAML template Engine how label works in Haml? -

i new haml , not able understand old coder logic try identify label come on ui in haml template code main view page = render :partial => "application/select_search", :locals => {:n => "benefit_stream_inf", :options => @dynamic_benefit_options, :default => true} select_search page render in main plage label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models) now not give label in render how lable generated can 1 explain label assignment code label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models) finly got answer label = local_assigns[:l] ? l : t(n, :scope => local_assigns[:s] ? s : :models) local_assigns[:l] local variable used give label directly t(n, :scope => local_assigns[:s] ? s : :models) used fatch label value of translation file pass key , scope and translation file put @ config/local/en.yml

java - How to remove the tag in XML using JAXB -

i'm using jaxb convert java object xml file. in xml file, need remove tag without using xslt . for example :remove tag orders <order_list> <orders> <orderid>12324<orderid> </orders> </order_list> excepted result : <order_list> <orderid>12324<orderid> </order_list> i can suggest "naive" approach. the wrapper tag orders can configured using jaxb annotation @xmlelementwrapper . so, can create 2 models: 1 contain tag, not. can use model contains tag parse data, copy data model not contain tag , use serialize. @xmlrootelement(name = "index-annotations") public class orderlist { private collection<integer> orderids; @xmlelement(name = "orderid", type = integer.class) public collection<integer> getorderid() { return orderids; } } @xmlrootelement(name = "index-annotations") public class outputorderlist extends orderlis

c++ - constructing the vector from an array -

i have tried initialize std::vector array, vector contains zeros although array initialized properly. code: lbfgsfloatval_t * k_array = new lbfgsfloatval_t[100]; for(int = 0; < 100; i++) k_array[i] = (lbfgsfloatval_t)i; vector<lbfgsfloatval_t> k_vector(k_array, k_array+100); cout << k_array[0] << " " << k_array[1] << " " << k_array[99] << endl; cout << k_vector[0] << " "<< k_vector[1] << " "<< k_vector[99] << endl; where lbfgsfloatval_t works double or float . output: 0 1 99 0 0 0 edit: have found problem already. not related code i've posted in question. this equivalent code have posted, uses int instead: #include <iostream> #include <vector> int main() { int * arr = new int[100]; for(int = 0; < 100; i++) arr[i] = (int)i; std::vector<int> vec(arr, arr+100); std::cout << ar