Posts

Showing posts from February, 2014

algorithm - Union-Find: retrieve all members of a set efficiently -

i'm working union-find algorithm. in first part of program, algorithm computes partition of big set e . after that, want retrieve members of set s , contains given node x . until now, naively, testing membership of elements of e set s . yesterday reading "introduction algorithms" (by clrs, 3rd edition, ex. 21.3-4), and, in exercises, found that: suppose wish add operation print-set(x) , given node x , prints members of x 's set, in order. show how can add single attribute each node in disjoint-set forest print-set(x) takes time linear in number of members of x 's set, , asymptotic running times of other operations unchanged. "linear in number of members of x 's set" great improvement problem! so, i'm trying solve exersice... , after unsuccessful tries, i'm asking on stack overflow! recall union-find implemented upside-down tree, each set s = {v 1 , v 2 , ..., v n }, have v n - 1 edges, have same root (o...

How do I include unordered list in jquery serialize array -

i'm using: $.ajax({ url: "processform.php", type: "post", data: $(this).serialize(), success: function(d) { alert(d); } }); to collect form input array. part of form unordered list: <ul class="sortable list" id="section_order"> <li>diet</li> <li>complementary treatments</li> <li>herbal medicine , dietary supplements</li> <li>self practices</li> <li> other activities</li> </ul> which serialize function ignoring. how include order of list items in serialized array. thanks help

doctrine2 - DQL Perform a union in query -

i know there several post relatives question still can't mine ! i have 2 tables (studios , models). want perform union datatable. currently, have : $cnn = $this->doctrine->getconnection(); $inscr = $cnn->fetchall("(select s.thedate mydate, s.name designation, \'studio\' mytype studios s order mydate limit 2) union (select m.thedate mydate, m.nickname designation, \'hotesse\' mytype models m order mydate limit 2 )"); return $inscr; but nothing appears in datatable , can't perform var_dump or other. i test in rdbms , waited results. so, ? i found solution perform query , result $sql = "(select s.thedate mydate, s.name designation, 'studio' mytype studios s order mydate limit 2) union (select m.thedate mydate, m.nickname designation, 'hotesse' mytype models m order mydate limit 2 )"; $stmt = $this->e...

css stretching background image sprite technique -

i have div styling, , width dynamic. <style> #mydiv { background-image: url('http://icons.iconarchive.com/icons/manda-pie/chocolate/icons-390.jpg'); background-repeat: no-repeat; border: 1px solid red; width: 50%; height: 200px; background-position: -0px -0px; -moz-background-size: 448px 368px; background-size: 448px 368px; } </style> <div id="mydiv"></div> you see div stretches if stretch browser window. how make background image stretched right same way div does? fiddle http://jsfiddle.net/3dsgn/106/ use -moz-background-size:100% 100%; background-size: 100% 100%;

visual studio 2010 - When using GoTo Statment in if else blocks the expected result is not obtained in C# -

i have below program. using system; using system.collections.generic; using system.linq; using system.text; namespace mylabeledstatement { class program { static void main(string[] args) { int x = 100, y = 4; int count = 0; string[,] myarray = new string[x, y]; (int = 0; < x; i++) { (int j = 0; j < y; j++) { myarray[i, j] = (++count).tostring(); //console.writeline(myarray[i, j]); } } console.writeline("enter number find:"); int mynumber = int.parse(console.readline()); (int = 0; < x; i++) { (int j = 0; j < y; j++) { if (myarray[i, j].equals(mynumber)) { goto found; } else { ...

javascript - How can i prevent LastPass (chrome extension) from filling out my input field - make LastPass ignore my input field -

i want ignore last pass fill out input field, i'm using angularjs , html5 extention auto fill ofllowing input field. <input id="search-publishers-box" type="text" placeholder="search publishers" data-ng-model="publisherssearchquery.name" class="search-field-text" autocomplete="off"/> what should in order prevent last pass doing it, tried change place holder, model, adding autocomplete="off" change id of input field non of them worked me. any suggestions? here's take on this, , solve autofill problems (yes, they're obscure happen) – watch fields changes. since you're using angularjs , pretty easy $watch , or if you're using jquery , use .change and then, whenever there's change of more 1 character @ 1 time, can assume autofill , not typing. note breaks if decides paste field. another workaround allow change on field when there's keypress . edit here's...

jquery - How to set a inline form to occupy 100% width under the navbar brand in "navbar" -

Image
i pretty new bootstrap. trying have inline form in navbar beside navbar-brand. while re-sizing(responsiveness) window, form coming below navbar-brand link, not coming 100% , hence looking awkward. tell me going wrong. here's full html code, bootstrap 101 template <!-- bootstrap --> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class = "navbar navbar-inverse navbar-fixed-top"><!--style = "background-image: url('images/logo.png'); background-size: contain; background-repeat: repeat;"--> <div class = "row"> <div class = "navbar-header col-lg-4 col-sm-12 col-xs-12 pull-left" style = "background-color: red; height: 100%;"> <a class = "navbar-brand" href = "#">janasena party</a> ...

css - Deploy MVC 5 Bootstrap 3 Glyphicon Not Display -

Image
i've got display problem after deploy mvc 5.1 bootstrap 3.0.0 production. glyphicon doesn't appear , bootstrap css seems not load properly. on server (it fine in production): on client (this problem): download bootstrap package here : http://getbootstrap.com/getting-started/#download , paste files fonts folder of bootstrap package fonts folder of asp.net application. , make sure uploading font files server. so, press ctrl+shift+i --> "network" tab in chrome , see if resources loading. should solve problem.

php - If selected option value is empty select all values in column -

i trying values column when color selected option value empty. have created form, , dropdown menu looks colors <option value=""> <option value="61">8019 - smeđa <option value="28">8017 - smedja svijetla <option value="27">8004 - cigla crvena <option value="26">8003 - boja bakra dimensions <?php while($row = mysqli_fetch_array($dimensions)) { echo '<option value= "'.$row['artopis'].'">'.$row['artopis'].'</option>'; } ?> </select> if achoose dimension , leave color values empty, colors selected menu should printed. ex. if want srew 4,4x20 mm dimension, if dont choose color, leave blank, want print screw in colors. vijci_search2.php $col=$_post['color'] $dimen=$_post['dimensions']; $sql_color = (!empty($col)) ? "jos_ib_boje.bojaid=" . $col . " , " : ''; query $result ...

c# - Unable to cast object of type 'System.Reflection.RuntimePropertyInfo' -

i have library , console program. program dynamically load library. in library exist byte array. try array. in program: memberinfo[] bytearrayfile = htmlpackage.getmember("htmlfile"); fieldinfo field; try { field = (fieldinfo)bytearrayfile[0];//throw exception here } catch (exception e) { string err = e.tostring(); throw e; } byte[] htmlfilearray = (byte[])field.getvalue(htmlpackage); this error throw exception: "system.invalidcastexception: unable cast object of type 'system.reflection.runtimepropertyinfo' type 'system.reflection.fieldinfo'.\r\n @ ... so how it's fixed? fields ( fieldinfo ) , properties ( propertyinfo ) not share api - need work around it: memberinfo member = bytearrayfile[0]; byte[] htmlfilearray; switch (member.membertype) { case membertypes.field: htmlfilearray = (byte[])(((fieldinfo)member).getvalue(htmlpackage)); break; case membertypes.property: htmlfilearray =...

android - custom image layout border in dialog -

Image
this question has answer here: dialog transparent background in android 14 answers in app have situation: open dialog , set content view this: dialog dialog = new dialog(context); dialog.setcontentview(r.layout.dialog); dialog.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/patientsbg" android:orientation="vertical" > </linearlayout> and result this: i want have dialog image , no borders , spaces. idea ? just set dialog background transparent below: dialog dialog = new dialog(context); dialog.setcontentview(r.layout.dialog); dialog.getwindow().setbackgrounddrawable(new colo...

android - Can different iOS app with the same signature share data and resource? -

in android, uids created , assigned on per-package basis. can configure our apps same signature share same uid modify manifest file. i wondering ios has same mechanism? i don't think, it's possible because of sandboxing. read more here ios app programming guide: ios environment , app sandboxing

python - Filtering data in pandas -

i working pandas 0.13.0 i have data frame(a) 2.5 million records i want exclude hundreds of records applying 2 conditions simoultaneusly: records fulfill 2 conditions @ same time. i want see how many records exclude when applying both conditions: len(a) 2523250 b=a[(a.cond1=='120.a') & (a.cond2==2012)] len(b) 6010 but when apply conditions obtain final dataframe: c=a[(a.cond1!='120.a') & (a.cond2!=2012)] len(c) 2214968 in second case '&' working , 'or' doing wrong? review de morgan's laws . logical negation of & not switching == != , must swap & | , because want rows either cond1 != '120.a' or cond2 != 2012 , i.e., want exclude row if 1 of != conditions true because makes original & statement false . @edchum's comment above equivalent to c=a[(a.cond1!='120.a') | (a.cond2!=2012)]

javascript - Swapping an image onClick with jQuery from 4 buttons -

i've had through other questions , unable find solution. have 4 buttons , want them change colour of dress when click them using jquery. in dreamweaver have managed sort of working rather replacing image seems replace buttons, advice on i'm going wrong appreciated. created jsfiddle of works less, here is: http://jsfiddle.net/zd72f/ also sorry not linking fiddle properly, link i've added work. <body style="margin:0 0 0 0;"> <div class="background"> <div id="index-dress"> </div> </body> thanks in advance help! you need include jquery in fiddle changing src of image placed inside #index-dress div: $('#index-dress img').attr('src'........ instead of images you're doing @ moment: $('img').attr('src'........ final code should this: $(document).ready(function () { $('.buttons').click(function () { $('#index-dress...

c - How to combine two or three characters to one integer/character -

i getting characters uart example "\n43\n" or "\n912\n". intend make integer in order compare values in application. example: int = 43; int b; /*combine character getting uart copy integer "b";*/ if(a==b) { /*perform operation*/ } #include<string.h> #include<stdio.h> int main() { int number; char a[30] = "\n43\n"; number = atoi(a); printf("magic %d",number); if(number == 43) printf("this works....!\n"); return 0; } have heard ever atoi() edit : int main() { int number = 0; char a[30]; a[0] = '4'; a[1] = '3'; a[2] = '\0'; number = atoi(a); printf("magic %d",number); return 0; }

c - Server-Client not connecting -

i new socket programming in c. stuck on here. below server , client .c program files. problem not getting connected.any appreciated here client.c #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <arpa/inet.h> int main(void) { int host_socket =0,add_length,bufflen; struct sockaddr_in host_addr; struct hostent *h; char recvbuffer[1024]; host_socket = socket(af_inet,sock_dgram,0); host_addr.sin_family = af_inet; host_addr.sin_port = 5000; host_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); if(bind(host_socket,(struct sockaddr*)&host_addr,sizeof(host_addr))<0) { printf("\n not connecct server !!"); return 1; } recvfrom(host_socket,recvbuffer,(sizeof(recvbuffer)-1),0,(struct sockaddr*)&host_addr,&add_length); fputs(recvbuffer,st...

javascript - How to apply style to a specific element in JQuery array -

i learning basics of jquery, , can't solve problem: given 3 green <li> elements turn 1-st , 3-rd elements red color, , 2-nd element orange. code: <!doctype html> <html> <head> <title>element</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script> <meta http-equiv="content-type" content="text/html;charset=utf-8" > <style type="text/css" media="screen"> ul li{color: green;} </style> </head> <body> <ul> <li>text 1</li> <li>text 2</li> <li>text 3</li> </ul> <script> var lis = $("ul li").css("color", "red"); </script> </body> </html> i able make elements red, can't make 2-nd orange: lis[1].css("color", "orange");...

java - Should I use uppercase or camelcase in label enums? -

the title says all. in cypher , camelcase used labels. instance :car , :bike . api docs label uses uppercase when defining each label in enum, label.car.name() car , not car . using camelcase fits in more nicely cypher queries, conflicts java standard naming enum members. forces me use labels label.bike_seat instead of label.bikeseat in graph database. 1 should use? even though using uppercase enum members correct way in java, i'm still bit curious why neo4j people decided represent labels enums? oracle doc : because constants, names of enum type's fields in uppercase letters. check : http://docs.oracle.com/javase/tutorial/java/javaoo/enum.html

javascript - how to update the markers of a multi line on a brush? -

to draw multi line var city= focus.selectall(".city") .data(cities) .enter().append("g") .attr("class", "city"); var bad=city.append("path") .attr("class", "line") .attr("d", function(d) { return line(d.values); }) .style("stroke", function(d) { return color(d.name); }) .style("opacity",0.5); code markers of multi lines var point = city.append("g") .attr("class", "line-point"); point.selectall('.line-point') .data(function(d){ return d.values}) .enter() .append('circle') .attr("cx", function(d) { return x(d.timestamp) }) .attr("cy", function(d) { return y(d.limit) }) .attr("r", 1) .style("fill", "grey") .on("mouseover", function(d,i) { div.transition() .duration(200) .style(...

ruby on rails - CSS and JS not showing up in my HEAD when deployed to heroku -

i have deployed project heroku after of changes pushed github. worked fine except noticed new css updated did not go through. css files committed , pushed github, know not problem. when viewing source on heroku app, notice missing of .css , .js files in head section. there reason head different on heroku on local. running smoothly , didn't change config files since last push heroku... thanks. here link github project: https://github.com/michaelnavarro/careerfoundry application.js: // manifest file that'll compiled application.js, include files // listed below. // // javascript/coffee file within directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can referenced here using relative path. // // it's not advisable add code directly here, if do, it'll appear @ bottom of // compiled file. // // read sprockets readme (https://github.com/sstephenson/sprockets#sprockets-directives) details // supported ...

Actions Buttons in Android not visible -

i'm working on first android app following official tutorial. right im trying add action buttons mainactivity: @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu items use in action bar menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.main_activity_actions, menu); return super.oncreateoptionsmenu(menu); } res/menu/main_activity_actions.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" > <!-- search, should appear action button --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" android:showasaction="ifroom" /> <!-- settings, should in overflow --> <item android:id="@+id/action_settings" android:title="@string/action_settings" android:showasaction="never" /...

bash - Exporting data from expect script -

so i've written short expect script logs apc power distribution unit interface via telnet , polls current ampage. #!/usr/bin/expect set ip "192.168.0.1" set username "myusername" set password "mypassword" spawn "/bin/bash" send "telnet $ip\r" expect "*user name*" send "$username\r" expect "*password*" send "$password\r" expect "*apc*" send -- "phreading current\r" expect "*success*" send "quit\r" expect eof the script job , see amps on screen, displayed this: apc>phreading current e000: success 1: 7.5 apc>quit what need 'export' 7.5 figure, either text file or pass bash script variable. any ideas on how can this? thank you! expect extension of tcl, have access of tcl's constructs. if have expect script write directly file. see secti...

sitecore - Brightcove video once appears on page load then disappear immediately in IE browser? -

i working brightcove video, working fine in firefox , chrome in ie appears once on page load disappeared immediately, means video not showing in ie browser. what reason behind this? <script type="text/javascript"> var player; var modvp; function mytemplateloaded(experienceid) { player = brightcove.api.getexperience(experienceid); modvp = player.getmodule(brightcove.api.modules.apimodules.video_player); $('.stillimage').stop().fadeout(150); $('.brightcoveexperience').stop().fadeout(); } $('.video_resource_container .video_rotator .slideshow ul li:first').addclass('active-vd'); $('.video_resource_container .video_rotator .slideshow ul li input').click(function () { $('.video_resource_container .video_rotator .slideshow ul li').removeclass('active-vd'); $(this).parent().addclass('active-vd'); }); function ontemplateready(evt) { } function onmediacomplete(videoid, title, ...

Wicket: Readable Links(Mounting) in TabbedPanel for Links in Tabs -

how can i, in wicket, make tabbedpanel link in tab readable "/subpath/tab1","subpath/tab2". can use mountablepagelink ? ? you have tail end of uri pageparameter. done in application class like: mountpage("/subpath/${activetag}", foo.class); which can set active tab based on pageparameter. when create tabs can set 1 active 1 based on default or activetag passed in.

c - Copy a structure to a member of another structure -

i'm on sdcc 3.4 , midi project musical instrument, , it's couple of days i'm struggling this... find somehow difficult explain, here try make better example. basically, scanning button presses, send midi information , lit leds accordingly. need sort of database holding data related each button, of part must constant (ids of buttons , leds) , part can variable because can varied user. @ initialization phase need assign constant part structure , leave variable part unchanged. when user modifies function of button, need overwrite variable part , leave constant part unchanged. // structure constant part typedef struct { unsigned char btnid; // holds n. of input pin button unsigned char ledid; // holds n. of output pin led } sbtnconst; // structure variable part typedef struct { unsigned char ccnum; // holds cc number send unsigned char ccval; // holds cc value tu send } sbtnvar; // structure containing data typedef struct { sbtnconst c; sbtnvar v; } sbutton;...

How to integrate Admob with windows phone in cocos2d-x 2.2.1 -

want integrate admob cocos2d-x 2.2.1 in windows phone, there no direct connection implement that. how can ? engine version- 2.2.1 i new in cocos2d-x, trying add admob windows phone. project working fine windows there next task implement admob. please provide me way that. thank you

hadoop - How to create a random partitioned data in Hive -

i have following data: id int name string 1 2 b 3 c i want create new table in hive partition countryid , load data table , put random value in countryid. i'm using following commands not work: hive> set hive.exec.dynamic.partition.mode=nonstrict hive> create table test (id int, name string) partitioned (countryid int); hive> load data inpath '/my_data.txt' table test partition (countryid = rand()); i following error: failed: parseexception line 1:76 cannot recognize input near 'rand' '(' ')' in constant what doing wrong? i think want insert overwrite insert overwrite table test partition(countryid) select id,name, rand() countryid my_data; after create external table my_data.txt file.

wordpress - Css horizontal nested menu not working correctly -

i have website has wordpress generated menu makes horizontal menu submenu has subcategories. here fiddle http://jsfiddle.net/79rkd/3/ hover properties > property search , featured listings . submenu of property search not dissapear thing annoying. also hovering on suboptions of property search , featured listings deactivate link of featured linistings ans submenu not dissapear. here html: <nav id="site-navigation" class="main-navigation" role="navigation"> <div class="menu-main-menu-container"><ul id="menu-main-menu" class="menu"><li id="menu-item-33" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-33"><a href="#">home</a></li> <li id="menu-item-612" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-612"><a>properties</a> <ul class="sub-menu...

ruby - performing sql operation in rails console -

i have gem 'sqlite3' installed in rails application. where perform query check whether records exist in table. in rails console ran sqlite3 . c:\sites\iauth>sqlite3 sqlite version 3.8.2 2013-12-06 14:53:30 enter ".help" instructions enter sql statements terminated ";" sqlite> select * users; error: no such table: users sqlite> i have table users, how come says no such table exists. using devise authentication . below model. class user < activerecord::base # include default devise modules. others available are: # :confirmable, :lockable, :timeoutable , :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable end you need refer db file directly: sqlite3 db/development.sqlite3

css - How can I generate a class multiple times for a list of mixins? -

i'm 1 of developers on project, our sass delivered designer. know basics of sass, i'm not sure if possible. i have class want generate multiple times, , class name should change depending on mixin. these mixins: @mixin small-tablet { @media screen , (max-width:767px) { @content; } } @mixin mobile { @media screen , (max-width:480px) { @content; } } this part want add (pseudo-code): @include small-tablet, mobile { table.responsive-@mixin-name { display: block; } } and output should this: @media screen , (max-width:767px) { table.responsive-small-tablet { display: block; } } @media screen , (max-width:480px) { table.responsive-mobile { display: block; } } how can result? you try in way $mobile: 480; $smalltablet: 767; @mixin mq($width) { @media screen , (max-width:#{$width}px) { @content; } } @mixin generatemediaqueries { @incl...

c# - PropertyInfo to Expression<Func<TModel, TProperty>> -

i want create kind of webgrid 2.0 asp.net , razor. defining modelclass (tdata) webgrid should create html table on own. the properties of tdata should read via reflection (typeof(tdata).getproperties). attributes of properties should define css , html styling or data (displaynameattribute => columnheader). now came point, when want call htmlhelper.displayfor(...propertyinfotoexpression...) render datas content. how call displayfor, when got data(row)/model , propertyinfo? webgrid-class: public class tablemodel<tdata>{ private readonly ilist<tdata> _rows; private readonly ilist<tablecolumn<tdata>> _columns = new list<tablecolumn<tdata>>(); public tablemodel(ilist<tdata> rows) { _rows = rows; propertyinfo[] propertyinfos = typeof(tdata).getproperties(); foreach (propertyinfo property in propertyinfos) { if (!attribute.isdefined(property, typeof(nocolumnattribute))) { ...

javascript - Rewriting jQuery files with Angular -

i looking start using angularjs within application. have been able write controllers , them utilized front-end. trying refactor existing .js files jquery. example: original message.js file define([ 'jquery' ], function($) { 'use strict'; return function(router) { router('*', function(ctx, next) { if (typeof console !== 'undefined'); $('.message').on('click', function() { $(".message").show(); }); next(); }); }; }); attempted new message.js file define([ 'angular' ], function($) { 'use strict'; return function(router) { router('testpage.html', function(ctx, next) { if (typeof console !== 'undefined'); $('.message').on('click', function() { $(".message").show(); alert('its working)'; }); ...

ios - Odd Behavior When Using MFMessageComposeViewController -

Image
the issue i'm having both mfmessagecomposeviewcontroller uiactivityviewcontroller , message option. the dialog presented properly, when select recipient, entire recipient field slides under navigation bar. can see presenting view controller beneath it. also, when autocomplete list appears when typing address, list starts half way down screen, typically under keyboard. i created simple sample app, doesn't have issue. it's app. the thing can think of these dialogs presented view controller presented itself, otherwise have no idea issue. i ran same issue. in case caused using appearance selectors on uinavigationbar, looks might doing well. solved narrowing scope on appearance selectors uinavigationcontroller subclass. [[uinavigationbar appearancewhencontainedin:[mynavigationcontroller class], nil] setbackgroundimage:... forbarmetrics:...]; rather than [[uinavigationbar appearance] setbackgroundimage:... forbarmetrics:...];

vb.net - Reflection and loading of dlls -

i trying create generc vb.net import program loading in dlls usings method cant figure out how unload dll once finished . can hangs in memory , of course cant see in task manager nead way close dll after public shared function createinstance(byval plugin availableplugin) object dim objdll [assembly] dim objplugin object try 'load dll objdll = [assembly].loadfrom(plugin.assemblypath) 'create , return class instance objplugin = objdll.createinstance(plugin.classname) catch e exception return nothing end try return objplugin end function

How to include additional dependencies when packaging an sbt app using sbt-native-packager -

i trying include breeze-natives dependency when packaging app ( universal:packagebin , debian:packagebin ) while including breeze dependency. here came : val breezedependencysettings = { val breezeuniversalnativesdependency = librarydependencies in universal += d.breezenatives val breezedebiannativesdependency = librarydependencies in debian += d.breezenatives val breezedependency = librarydependencies += d.breeze seq(breezeuniversalnativesdependency, breezedebiannativesdependency, breezedependency) } and in project want package, use settings = (mysettings) ++ sbtnativepackager.packagearchetype.java_server ++ dependencies.breezedependencysettings however, breeze-natives dependency not included in final package created universal:packagebin . (breeze included correctly though) what doing wrong? not 100% clear on requirement have tried exportjars := true? see excerpt build in question here: https://stackoverflow.com/questions/23035100/how-to-remove...

SQL Server : 2 Pivot Questions -

Image
all pivot examples saw till use aggregate functions. have no idea how can achieve following: i have simple table test purposes: ;with cte ( select * (values (1, 'messi', 'graz'), (2, 'ronaldo', 'graz'), (3, 'weah', 'wien'), (4, 'nedved', 'wien'), (5, 'hagi', 'wien'), (6, 'puskas', 'istanbul'), (7, 'stoichkov', 'dubai'), (8, 'di baggio', 'dubai') ) t(cid, name, city)) i want achieve following: to rotate table this: and want rotate following query: select city, count(city) num_of_customers customers group city; which produces following result: i want display this: i never worked pivot tables until , grateful kind of help. ps: table name customers . both queries easy in dynamic fashion, nice if don't have fixed number of rows , need query adapt number of rows. the first query: declare @players varc...

highcharts - Tooltip issue on columnrange -

please @ example. i've created on jsfiidle. http://jsfiddle.net/cr1t/ldln2/1/ the issue i'm having tooltip floats above graph. text on column range seems have higher z-index. no matter try , set on div style sheet, shows threw. i'd have point detail in html, because want make hyperlink tag. plotoptions: { columnrange: { datalabels: { inside: true, enabled: true, usehtml: true, formatter: function () { if (this.y === this.point.low) { return '<div style="padding:2px;text-align:center;color:black;overflow:hidden;width:' + (this.point.plotlow - this.point.plothigh - 4) + 'px">' + this.point.low + '°c - ' + this.point.high + '°c </div>'; } } } } }, thanks anto i followed duplica...

r - wrapping ggplot around a function -

i have following code seems work when have below p<-ggplot(data=x.all.er, aes(x=year, y=value, fill = (factor(x.all.er$strategy))))+ geom_bar(stat = 'identity',position = 'dodge', colour = "black") + scale_fill_manual(values = mycols) + scale_y_continuous(breaks= seq(-0.3,0.3,by=0.025), labels = percent) + ylab("eret") + theme(axis.title.y = element_text(size=15, face = "bold"))+ xlab("year") + theme(axis.title.x = element_text(size=15, face = "bold")) print(p) but when try wrap around function gives me errors. appreciated. thanks! mybar<-function(ds, x, y, fillby, labels, mycols, xlabel, xbreaks, ylabel, title) { #my.cols =c("#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", # "#000000","#2171b5...

syntax - Java version of OCaml underscore -

if i'm testing like corrector c = new filecorrector("filenotfound.txt"); and know code fail, , c never used, there way can write code ocaml _ symbol? corrector _ = new filecorrector("filenotfound.txt"); why not not give variable name? new filecorrector("filenotfound.txt"); it looks odd because constructors shouldn't have side-effects. can throw, , literally can have side effects, it's not code doesn't anything. , far eclipse warnings concerned, preferred unused variable.

requirejs - How to use Jasmine to test if an instance is created? -

hi new using jasmine. issue follows: have number of modules, managed through requirejs. module creates instance of module b in it. possible use jasmine test whether instance of b being created in a? convey clearer idea of code, have: //in module define(['b',],function(b){ function test(){ var newtest = new b(); }; return {test: test}; }); now, how use jasmine test module indeed, creates instance of module b? in advance! regards here's 1 way check type of object in jasmine test: describe('chocolatefactory', function() { it('creates instance of chocolate', function() { var factory = new chocolatefactory(); var chocolate = factory.makechocolate(); expect(chocolate instanceof chocolate).tobe(true); }); });

jquery - Drag and drop doesn't work on IE -

i issue when execute code on ie, works fine on chrome , firefox not on ie. my code : $.event.props.push('datatransfer'); $cases.children('div').on('mouseenter', function(){ $cases.on({ dragstart: function(e) { e.datatransfer.setdata('text', $(this).text()); }, dragenter: function(e) { console.log('data == '+ e.datatransfer.getdata('text')); // return nothing $(this).addclass('ondraggableelement'); var $expendcase = $(this).children('div'); $(this).html(e.datatransfer.getdata('text')); $(this).append($expendcase); e.preventdefault(); }, dragleave: function(e) {}, dragover: function(e) { e.preventdefault(); }, ...

C++ Initializer_List into Vector of Pointers -

i've been trying streamline of code, condensing , making calls easier can. 1 of things i've been trying fuse 2 common overloads have on place one. follows: void myclass::addsomething(something & a) { vectorofsomething.push_back(&a) } void myclass::addsomething(std::vector<something*> a) { (unsigned int = 0; < a.size(); i++) vectorofsomething.push_back(a[i]); } the class abstract. vectorofsomething vector of pointers somethings. essentially, instead of having this: std::vector mysomethings = {&something1, &something2}; addsomething(mysomethings); i want this: addsomething({something1, something2}); so more similar first overload (no need user create vector of pointers first). looking around 2 ways saw either through: std::initializer_list or variadic templates, both of not afraid admit foreign me. i've given shot initializer lists have run ton of errors trying various things. i've managed function accept list, can...

machine learning - Extracting time, date, flight # from airplane eticket -

problem given (x, y) positions of every word in flight e-ticket, extract flight numbers , corresponding destination/arrival times + dates. my first try use regex flight numbers, dates, , times. match flights correct dates & times using (x, y) positions. done set of rules came with. issue these rules becoming longer , more complicated try make work variety of e-tickets. for example, "a320" "aegean airlines (a3) flight 20" or irrelevant "airbus a320". another example: "320p" time, 3:20pm, or part of irrelevant code appears in e-ticket. how approach it? topics should into? handwritten rules ok such things, need better tools simple regular expressions. try out gate framework , jape rule engine, regexes, operates so-called annotations (e.g. "token", "word", "noun", "number", sentence, etc.). here's gate manual give both - quick introduction , in depth feature description. p...

php - Laravel cookie::forget doesn't work? -

i have code: cookie::forget('vendor'); return redirect::route('vendor_login'); what supposed do, remove vendor cookie , redirect login page. however, doesn't delete cookie. understanding, expect send setcookie header vendor value of null , negative time. doesn't send setcookie header @ all. why this? this works perfectly: cookie::queue('paddle_vendor', null, -1); return redirect::route('vendor_login'); you can use queue method this: cookie::queue(cookie::forget('vendor')); return redirect::route('vendor_login'); which in way allows delete multiple cookies @ once too. more information checkout answer here: https://stackoverflow.com/a/33724308/247670 or antonio said: $cookie = cookie::forget('vendor'); return redirect::route('vendor_login')->withcookie($cookie);

go - Golang - Parsing nested JSON -

i'm using go-worker process resque jobs. job has payload has nested json structure this: [{ "key-a":"val-a", "key-b":"val-b", "files":[{ "key-a": [ {"a":"b","c": "d"}, {"e":"f","g": "h"} ], "key-b": [ {"a":"b","c": "d"}, {"e":"f","g": "h"} ] }] }] now go-worker gives me args ...interface{} represents json payload, not actual json text. there idiomatic way convert that( args ) correct types (could use package this.) using type assertions manually seems bit tedious such thing. if it's giving actual go objects (i.e. bunch of map[string]interface{} , not json string itself) there isn't can besides bunch of type assertions. you re-marshall json parse again correct structs, that's...

performance - Delete a pointer to C++ list is very very slow. Why? -

i trying rid of stl list fast. have declared pointer list. manipulations , delete pointer free ram. process of deletion pointer list slow , slow when list.clear(). slow. why happen? how can delete allocated ram fast? when dealing vector , deque deletion fast. below program demonstrates that. //============// // stl delete // //============// #include <iostream> #include <algorithm> #include <vector> #include <list> #include <deque> #include <cmath> #include <iomanip> #include <ctime> using std::cout; using std::cin; using std::endl; using std::list; using std::vector; using std::deque; using std::fixed; using std::setprecision; using std::showpoint; using std::sort; // main program int main() { // variables , parameters const long int i_max = static_cast<long int>(pow(10.0, 7.5)); const long int k_max = static_cast<long int>(pow(10.0, 6.0)); long int i; long int k; clock_t t1; clock_t ...

java - Cannot find Symbol Error. Cannot find getSelectedItem() and setBackground() methods -

when trying run program error because cannot find method. here first error code: error: cannot find symbol symbol: method getselecteditem() location: variable event of type java.awt.event.actionevent here second error code: error: cannot find symbol symbol: method setbackground(java.awt.color) location: variable x of type java.lang.object here program code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.random; public class panelcolor extends jframe implements actionlistener{ // declare instance data (primitives , objects used) private int width = 501; private int height = 501; jpanel paneln; jpanel panels; jpanel panele; jpanel panelw; jpanel panelc; container con; jcombobox box; dimension dpn; dimension dps; dimension dpe; dimension dpw; dimension dpc; //constructor public panelcolor(){ super("panel color"); con = getcontentpane(); con.setlayout(new borderlayo...

php - register namespace in silex without composer -

i'm using silex build api app i'm building, , want abstract controllers different files. i work pretty big corporation strict department, , won't let me install composer. reason, need register namespaces manually, via $loader->add() function, following error: fatal error: class 'app\controller\sessioncontroller' not found in c:\path\to\webroot\app\bootstrap.php on line 9 does know why autoloader isn't picking app namespace? currently, app structured follows: app/ controller/ apicontrollerabstract.php sessioncontroller.php bootstrap.php vendor/ www/ index.php index.php require_once "../app/bootstrap.php"; bootstrap.php $loader = require_once __dir__.'/../vendor/autoload.php'; $loader->add('app', __dir__ . '/../app/'); $app = new silex\application(); $app->mount('/session', new app\controller\sessioncontroller()); $app->run(); sessioncontroller.php nam...

r - How to subset a row from list based on condition -

i have data.table outcome , has column called hospital . , column called state . outcome has been sorted already. want subset nth hospital each state (if there's not nth returns na state). try solve below way.(since homework, showed third branch causes mistake). rankall <- function(out, num = "best"){ outcome <- readdata(outcome = out) //returns data.table sorted rate ... outcome <- lapply(outcome, function(x) ifelse(num <= nrow(x), x[num,], c(na,na))) outcome <- rbindlist(outcome) } the original outcome like > data hospital state 1: nyu hospitals center ny 2: doylestown hospital pa 3: avera heart hospital of south dakota llc sd 4: glendale adventist medical center ca 5: waterbury hospital ct --- ...

How to manage Login and Logout session in android - with Server Json object request -

friends, i have problem on how manage login , logout session in online android mobile application user login functionality. i have read many article on shared preference type of application. useful online application? thanks. yes can use sharedpreferences kind of stuff, time. example can have sharedpreferences object contains example data giving status (connected or not) , other information connected user.

ruby - Should I specify &block argument in def? -

in ruby, better (style?) specify method takes &block or not? the choice merely seems matter of style long method body contains yield . for example, given: def abc1(a, c) puts yield puts c end def abc2(a, c, &block) puts yield puts c end the following 2 calls: abc1('a', 'c') { puts 'b' } abc2('a', 'c') { puts 'b' } each print , return same things: a b c => nil so, if it's matter of style, what's convention (or better style)? with current code first 1 better. while using yield then, no need use &block , implicit . yes, 1 thing remind, have pass block while using yield , if not there error. although error can handled using block_given? . ruby's yield statement gives control user specified block method's body. so, if using again &block redundant, don't need use it.

asp.net mvc - How to use subreport across multiple reports or create parent report from subreport? -

i have crystal report called mainreport in visual studio, has subreport. contents of subreport header details required across couple of other reports. is there way re-use subreport across other reports or way change subreport being own parent report? any great! open sub report , go file ---> save subreport as , save report in of location. now can use sub report main report or inside main report. if not requirement let me know.

sharepoint - Organisational Wiki -

i have been tasked @ work creating organisational wiki document information such employees, teams (groups of employees), , systems (what support) within ms sharepoints wiki product. does else have wiki information? sort of roadblocks have run into? i couldn't find nuggets of information corporate internal wiki, these things tend internalized , not discussed. main goals have define (as organisation) define systems support define history/evolution of systems the initial goals more information associated organisation, not technical documentation or code samples developers. think can draw distinct line, i'll okay sharepoint's wiki product. is there other information other organisations consider type of project? have company intranet, supplement , tell story of side of organisation.

javascript - Iscroll causes links inside the scrolling parent to become unclickable on touch devices -

i'm trying use iscroll plugin ( https://github.com/cubiq/iscroll ) add scrolling div. finding renders links inside scrolling parent unclickable. disabling plugin fixes it. at first thought -webkit-transform doesn't seem case created standalone fiddle in. a demo can found here - http://jsfiddle.net/5frv4/ . go using mobile webkit browser see issue in action. iscroll initialised few simple options: var menuscroll = new iscroll('#menu', { mousewheel: true, scrollbars: 'custom', interactivescrollbars: true, }); i'm not sure can around issue. know else try? you try iscroll's option click: true to override native scrolling iscroll has inhibit default browser behaviors, such mouse clicks. if want application respond click event have explicitly set option true. please note suggested use custom tap event instead (see below). http://iscrolljs.com/#configuring

Using keypress() and keyup() when using an onscreen keyboard -

i have lovely piece of code drives search box on php page, making search box dynamic, , works perfectly. i'm trying adapt it, , @ bit of loss. at moment search must done on keyboard make search work. keypress() , keyup() functions within script. my problem i'm trying use search onscreen keyboard , no physical keyboard, there never keypress or keyup. is there can do think replace these. would best add amended version of code below (without keypress/keyup) each onclick of onscreen keyboard, or amend code react onscreen clicks? thanks if can help <!--javascript turn keystrokes search value--> <script type="text/javascript"> $(document).ready(function () { // hide submit button $(":submit").hide(); // bind event keypress in order override form submission when pressing enter key $("input[name='search_term']").keypress(function (e) { if (e.which == 13) { // prevent form...