Posts

Showing posts from May, 2013

ruby on rails - ActiveRecord Migration -

ive set database through active migrations before. when go setup new 1 on project doesn't seem right. typing command line bin/rails generate migration database date:date endpoint:text user:string domain:string however output this(snippet brevity) : bundler using binstub created different gem. deprecated, in future versions may need `bundle binstub rails` work around system/bundle conflict. usage: rails new app_path [options] options: -r, [--ruby=path] # path ruby binary of choice # default: /users/alexbozanic/.rvm/rubies/ruby-2.2.1/bin/ruby -m, [--template=template] # path application template (can filesystem path or url) [--skip-gemfile], [--no-skip-gemfile] # don't create gemfile -b, [--skip-bundle], [--no-skip-bundle] # don't run bundle install -g, [--skip-git], [--no-skip-git]

windows runtime - LoadListingInformationAsync throws a FileNotFound exception -

i have customer unable in-app purchasing 1 of windows 8.1 store apps. looking @ logs, see call load listing information: await currentapp.loadlistinginformationasync(); throws filenotfound exception the system cannot find file specified. (exception hresult: 0x80070002)' any idea why exception being thrown? we have less 100 in-app purchasing items. can reproduce on device? suggest run on ui thread: deployment.current.dispatcher.begininvoke(() => await currentapp.loadlistinginformationasync());

c# - Exception-proof HttpListener possible? -

last few days i've been building web server application in c# uses httplistener. i've learned quite lot on way, , still am. got working, setting headers here , there depending on situations. in cases things working fine, @ times exception error thrown. happens on few occasions. if not of them closing connection before data send. error occurs. of them caused browsers far can tell. like let's take chrome. whenever go mp3 file directly, sends 2 requests. , 1 of them causing error, other working , receiving part of content. after this, can listen mp3 , there no issues. streaming works. request gives me error, there nothing in headers use in code not output data, head requests. i'm quite puzzled here. ie has problem both opening mp3 files directly, , streaming via html5 audio tag. varies time time. open page, , 2 requests made. html page, , mp3. no error there. tho, there 3 requests. connects mp3 twice. 1 of connections being aborted straight after open page, , 2 r

haskell - Using functional dependency to eliminate type parameter -

i trying implement parsec stream wrapper remember last uncons 'd token in order provide look-behind capability. want wrapper work stream instance. here's have far: {-# language flexibleinstances, multiparamtypeclasses #-} module mstream import text.parsec import control.monad ( liftm ) data mstream s t = mstream (maybe t) s instance stream s m t => stream (mstream s t) m t uncons (mstream _ s) = fmap (\(t, s') -> (t, mstream (just t) s')) `liftm` uncons s getprevtoken :: stream s m t => parsect (mstream s t) u m (maybe t) getprevtoken = (\(mstream t _) -> t) `liftm` getinput mstream :: s -> mstream s t mstream = mstream nothing this works, don't having carry t parameter in mstream type constructor. surely should sufficient require s parameter, since t can derived s long there witness stream s m t . i've tried using type families , gadts, keep running obscure errors ambiguous type variables , unsatisfied functional depende

printing - JavaFX8 Print API : how to set correctly the Printable area -

Image
in javafx application , i'm using javafx 8 printing api print node , getting problem of printing area , despite have set pagelayout a4 paper .... here code : public static void printnode(final node node) throws nosuchmethodexception, instantiationexception, illegalaccessexception, invocationtargetexception { printer printer = printer.getdefaultprinter(); pagelayout pagelayout = printer.createpagelayout(paper.a4, pageorientation.portrait, 0,0,0,0 ); printerjob job = printerjob.createprinterjob(); if (job != null && job.showprintdialog(node.getscene().getwindow()) ) { boolean success = job.printpage(pagelayout, node); if (success) { job.endjob(); } } and here snapshot of node want print : and here getting when print node in method need hardware able margins. if set margins 0, printer has non printable margin around sheet. you can vie

Find by Protocol in Swift -

how can pass protocol parameter in swift? in objective-c this: id <currentusercontex> usercontex = [servicelocator locate:@protocol(currentusercontex)]; service locator: + (id)locate:(id)objecttype edit after qbyte answer tried using: servicelocator.locate(currentusercontex.self) but i'm getting 'currentusercontex.protocol' not confirm protocol 'anyobject' so tried: servicelocator.locate(currentusercontex.self as! anyobject) but get: could not cast value of type 'applicationname.currentusercontex.protocol' (0x7fec15e52348) 'swift.anyobject' (0x7fec15d3d4f8). i suggest use if currentusercontex name of protocol itself: servicelocator.locate(currentusercontex.self) if currentusercontex variable type protocol use: servicelocator.locate(currentusercontex) i hope solves problem

mysql equation inside where clause and between -

i need compute math equation , check if within range stored in table.something below table: +--------------+-------+--------+-------+--------+ | no | total | out of | grad | point | +--------------+-------+--------+-------+--------+ | 1000 | 833 | 1100 | | 12 | +--------------+-------+--------+-------+--------+ av tried achieve following query select no,sum(score) total,(100*count(scores.code)) "out of", grad, point scores,gradings (no=1000) , (exam=1) , ((sum(score)/(100*count(exams_scores.subject_code))*100) between gradings.range_begin , gradings.range_end) ; gradings table +---------------------------------------------------+ | id | range_begin | range_end | grad | point | +---------------------------------------------------+ | 1 | 70 | 80 | | 12 | +---------------------------------------------------+ | 2 | 60 | 70 | b | 11 | +---------------------

javascript - How can i use two different scope "this" in one function? -

so need inner text of given element through jquery event, , set text member of class e.g. myclass = function () { this.index = 0; this.onnavelementclick = function () { this.index = parseint(this.text()); } this.mymain = function () { $("nav#wow-so-much-inspiration").on("click", "a", this.onnavelementclick); } } myobject = new myclass(); myobject.mymain(); html: <nav id="wow-so-much-inspiration"> <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> </nav> but won't work because of 2 different scopes inside onnavelementclick() function... , don't idea of doing _this = this , i'm pretty sure there right way without doing macgyver coding. jquery event handlers take event object (including target on event triggered) first argument. can use $.proxy have event handler bound outer t

javascript - Preventing Meteor from removing MiniMongo data already sent to client when publish changes -

i have noticed when change published cursor - not data cursor points to, whole cursor - meteor send removed message client documents not appear in new cursor. mean in more technical terms: // client side tracker.autorun(function() { var somereactivevar = somereactivevar.get(); meteor.subscribe('mypublication', somereactivevar); } ... // server side meteor.publish('mypublication', function() { var someparameter = arguments[0]; return mycollection.find({ someattribute: someparameter }); }); now when somereactivevar changes, documents had been sent client side minimongo mycollection removed (if not part of new cursor). in cases want, question is: can prevent this? how? there's magic happening here, when perform meteor.subscribe inside tracker.autorun . basically, .stop() old subscription after each run. you have 2 options, 1- keep multiple subscriptions alive, using nonreactive block. note: you'll have write code clean-

javascript - Add text to random string -

if text starts http://vk.com add <iframe src=" at end , " width="100%" height="450px" allowfullscreen=""></iframe> @ end all http://vk.com/random$$ in database.. , link random.. example: http://vk.com/video_ext.php?oid=187139107&id=163792624&hash=15cbcf3a3c503bd8 to <iframe src="http://vk.com/video_ext.php?oid=187139107&id=163792624&hash=15cbcf3a3c503bd8" width="100%" height="450px" allowfullscreen=""></iframe> keep in mind, after "video_ext.php?" random. so.. here script take care of that: <?php $mysqli = new mysqli("localhost", "admin_user", "yarak", "admin_name"); if ($mysqli->connect_errno) { echo "failed connect mysql: " . $mysqli->connect_error; } if( $res = $mysqli->query("select * parts") ) { $i = 0; $done = array(); while( $

javascript - jQuery slide/toggle menu -

newbie in js / jquery here. first problem: when page loading or refreshing whole sub-sub menus blinked 0.5sec can "hide". have put script firstly on end of "body" tag, after blink i've put in "head" there way make hide, hide, not shown when page on load? second problem when i'm clicking on either blue or green square menu not sliding smoothly. it's bounce effect. because of "hide"? , last problem slidedown function. shall use slideup make go position hides? jquery(document).ready(function($) { $(".raid ul").hide(); $(".raid").hide(); $(".wod").one("click", function() { $(".wod ul li").slidedown(200); }); $(".mop").one("click", function() { $(".mop ul li").slidedown(200); }); $(".hfc").click(function() { $(".hfc").addclass('x');

c++ - Different behaviour between Clang and GCC when performing qualified name lookup -

consider following program: #include <iostream> namespace n { int j = 1; } namespace m { typedef int n; void f() { std::cout << n::j << std::endl; } } int main() { m::f(); } compiling clang gives following compiler error: prog.cc:10:22: error: 'n' (aka 'int') not class, namespace, or enumeration std::cout << n::j << std::endl; ^ 1 error generated. gcc not give compiler error. i'm trying figure out compiler should file bug report for. compiler has correct behaviour , why (references c++ standard)? wandbox - clang: http://melpon.org/wandbox/permlink/s0hkoxcfpgq5asmj wandbox - gcc: http://melpon.org/wandbox/permlink/i2kol3qtbvucjvbz clang correct on one. quoting c++11, 3.4.3/1 [basic.lookup.qual]: ... if :: scope resolution operator in nested-name-specifier not preceded decltype-specifier, lookup of name preceding :: considers namespaces, types, , templat

javascript - Ajax to get input textbox array and display the result to a div -

this display form <form name='foodlist' action='checkout' method='post'> <table> <tr> <td>product name</td> <td>price</td> <td>quantity</td> <td>amount</td> </tr> <tr> <td><input type='text' name='foodname[]' size='10' class='foodname' /></td> <td><input type='text' name='price[]' size='2' class='price'/></td> <td><input type='text' name='qty[]' size='2' class='qty'/></td> <td><input type='text' name='amt[]' size='2' class='amt'/></td> </tr> <tr> <td><input type='text' name='foodname[]' size='10' class='foodname' /></td> <td><input

How to disable the insertion point (cursor in textfield when typing) in iOS TexfField? (SWIFT) -

i looking everywhere, can not find answer. have textfield , want invisble. means hiding insertion point well. i found using .tintcolor , .textcolor , setting both uicolor().clearcolor() works intended.

ruby - Create hash-of-hashes using structure of the default hash -

i have following code: default = {:id => 0, :detail =>{:name=>"default", :id => ""}} employees = {} nr = (0..3).to_a nr.each |n| employee = default employee[:id] = n employee[:detail][:name] = "default #{n}" employee[:detail][:id] = "key-#{n}" employees[n] = employee end puts employees i expect values key :id in :detail hash key-0 , key-1 , key-2 . you need change: default = { :id=>0, :detail=>{ :name=>"default", :id=>"" } } to def default {}.merge(:id=>0, :detail=>({}.merge(:name=>"default", :id=>""))) end but, hey, while we're @ may ruby-ize rest: employees = (0..3).map |n| employee = default employee[:id] = n employee[:detail][:name] = "default #{n}" employee[:detail][:id] = "key-#{n}" employee end #=> [{:id=>0, :detail=>{:name=>"default 0", :id=>

Python regex findall alternation behavior -

i'm using python 2.7.6. can't understand following result re.findall : >>> re.findall('\d|\(\d,\d\)', '(6,7)') ['(6,7)'] i expected above return ['6', '7'] , because according documentation : '|' a|b, , b can arbitrary res, creates regular expression match either or b. arbitrary number of res can separated '|' in way. can used inside groups (see below) well. target string scanned, res separated '|' tried left right. when 1 pattern matches, branch accepted. this means once matches, b not tested further, if produce longer overall match. in other words, '|' operator never greedy. match literal '|', use \|, or enclose inside character class, in [|]. thanks help as mentioned in document : this means once matches, b not tested further, if produce longer overall match. so in case regex engine doesn't match \d because string stars ( ,

math - c++ quadratic equation code output error -

ok, creating quadratic equation solver in c++ , cant seem right output on imaginary numbers. real number roots come out fine (e.g. x= 2 , x = 5) when imaginary numbers come out, weird happens shows (x = -1.#ind)?? please me figure out? want show more x = 5.287*i. here code #include <iostream> #include <string> #include <cmath> #include <complex> using namespace std; int main() { cout << "project 4 (quadratic equation)\nlong beach city college \nauthor: mathias pettersson \njuly 15, 2015\n" << endl; cout << "this program provide solutions trinomial expressions.\nexample: a*x^2 + b*x^2 + c = 0" << endl; double a, b, c; double discriminant; //variable inputs cout << "enter value of a: "; cin >> a; cout << "enter value of b: "; cin >> b; cout << "enter value of c: "; cin >> c; //computations disc

c++ - C reading in from a vertical line character delimited file -

new c , trying read in text file, "stocks", delimited vertical line '|' characters. aim open file has string , float value on each line, in format: tom|149.62 jim|23.25 i have read other posts commas, colon , tab delimited files, "scanset" suggestion applied here [^|] between %s , %f doesn't seem work. seem have managed store first character of string @ least now, float value saved nonsense. later writing arrays declared after file basic case of displaying string , float value each line means can continue on own. appreciate can give me. #include <iostream> #include<stdlib.h> #include<stdio.h> using namespace std; // tom|149.62 // jim|23.25 int main() { file *stocks; char *stock_tickers[100]; float stock_prices[100]; if ((stocks = fopen("stocks.txt", "r")) == null) { fprintf(stderr, "error opening file.\n"); exit(1); } char tempchar; float te

javascript - Grunt concat for each module then minify -

trying grunt. have file structure this: /app --app.js --/module1 ----module1.js ----module1model.js --/module2 ----module2.js ----module2model.js how can concatenate & minify each module 1 file looks like: /app --app.min.js --module1.min.js --module2.min.js we want scalable when add module3, 4 it'll still work. thank help! you can use uglify solution , "dist" , "src" can changed according use: uglify:{ liveproject:{ files:{ 'dist/js/main.min.js' : ['src/js/*.js'], 'dist/js/m1.min.js' : ['src/js/easing.js','src/js/modernizer.js'], } } },

unix - Replacing a string with special characters -

i trying replace set of characters within variable. var1='&apos;abcd&apos;' i want replace ''' pipe looks like. |abcd| i have tried below. var1=$(sed 's/&apos;/|/g' <<< $var1) but not working. kindly me out. edit: original answer incorrect formatted question. this works var1=$(echo "${var1}" | sed 's/&apos;/|/g')

r - Fill missing sequence values with dplyr -

i have data frame missing values "snap_id". i'd fill in missing values floating point values based on sequence previous non-missing value (lag()?). achieve using dplyr if possible. assumptions: there never missing data first or last row i'm generating missing dates based on missing days between min , max of data set there can multiple gaps in data set current data: end snap_id 1 2015-06-26 12:59:00 365 2 2015-06-26 13:59:00 366 3 2015-06-27 00:01:00 na 4 2015-06-27 23:00:00 na 5 2015-06-28 00:01:00 na 6 2015-06-28 23:00:00 na 7 2015-06-29 09:00:00 367 8 2015-06-29 09:59:00 368 what want achieve: end snap_id 1 2015-06-26 12:59:00 365.0 2 2015-06-26 13:59:00 366.0 3 2015-06-27 00:01:00 366.1 4 2015-06-27 23:00:00 366.2 5 2015-06-28 00:01:00 366.3 6 2015-06-28 23:00:00 366.4 7 2015-06-29 09:00:00 367.0 8 2015-06-29 09:59:00 368.0 as data frame: d

javascript - how to access zeroth element in reduce to count repeats in an array -

on whim of node school, trying use reduce count number of times string repeated in array. var fruits = ["apple", "banana", "apple", "durian", "durian", "durian"], obj = {}; fruits.reduce(function(prev, curr, index, arr){ obj[curr] ? obj[curr]++ : obj[curr] = 1; }); console.log(obj); // {banana: 1, apple: 1, durian: 3} is sort of working. reason, reduce seems skip first element. don't know why. first time through array, index 1 . tried putting in logic like, if (index === 1){//put 'prev' property of 'obj'} . seems convoluted. i'm not how node school wants me solve problem. however, wonder what's way access zeroth element in array you're reducing. why zeroth element seemingly ignored reduction procedure? guess pass in fruits[0] after callback start value initially. what's best way access zeroth element? if no initialvalue provided, previousvalue equal first va

css - ion-content directive scroll div doesn't display data -

i have following simple html in ionic app <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">ionic blank starter</h1> </ion-header-bar> <ion-content> <ion-nav-view></ion-nav-view> </ion-content> </ion-pane> the problem ion-content directive wraps ion-nav-view content html <div class="scroll" style="-webkit-transform: translate3d(0px, 0px, 0px) scale(1);"></div> it seems if remove translate3d attribute content displayed, have assume there better way, or i'm missing. the content displayed template simple <div> <p>welcome main screen</p> </div> here's plunk of problem i'm experiencing http://plnkr.co/edit/qdekka5fxiqn2tgi3etp?p=info i find when update index.html following loads tabs.html. <body ng-app="starter" animation="slide-left-

java - corrupted double-linked list -

please me, little appreciated! when running java application, after times, here comes error: *** error in `/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java': corrupted double-linked list: 0x00007fd77c2cf640 *** the correct instruction must set variable , restart application. more information: immediately next, run-log print out: process finished exit code 134 i found error occurs @ point: private game game; private void backtomenu () { // switch menu screen game.setscreen(new menuscreen(game)); } exactly at: game.setscreen(new menuscreen(game)); some imports are: import com.badlogic.gdx.game; import com.packtpub.libgdx.canyonbunny.screens.menuscreen; the libgdx version 1.6.0, guide says libgdx version used in book 0.1.2 (learning libgdx game development second edition). i run desktop version (desktop module) of application under ubuntu 15.04. thanks lot! judging google search results "corrupted double-linked list&

c++ - How to put boost::multi_array in initialization list of constructor? -

i've got templated class dedicated holding boost:: multi_array . trying initialize array in initialization class, getting error: template <typename t> class hist2d { private: typedef boost::multi_array<t, 2> array_type; array_type matrixcount; public: hist2d(int width, int height): array_type matrixcount(boost::extents[width][height]){}; }; this gives following error: ctest.cpp: in constructor ‘hist2d<t>::hist2d(int, int)’: ctest.cpp:34:45: error: expected ‘(’ before ‘matrixcount’ hist2d(int width, int height): array_type matrixcount(boost:extents[width][height]){}; ^ ctest.cpp:34:45: error: expected ‘{’ before ‘matrixcount’ what these errors mean? it syntax error. not need declare type in initialization list. try this: hist2d(int width, int height): matrixcount(boost::extents[width][height]){} c++ compilation errors can confusing. you'll used them after while :d

javascript - Pass text of input to calling function (yes it is possible) -

i know question has been asked -and answered- multiple times. found new solution - not understand it. setup this: <input id="input1" onchange="gettext()"/> all answers found suggest use id value of input. function gettext(){ alert($("#input1").val()); } $(this).val() not work here. another way use value of #input1 use this.value in calling function: <input id="input1" onchange="gettext(this.value)" /> this passes value parameter function. however found jquery sample attaches function #input1 , makes $(this).val() work. $("#input1").change(function(e){ alert($(this).val()) }); against answers here @ stackoverflow seeing possible attach function input field , have access value of - ask myself how have write function , not attach jquery. or can attached jquery? why? here fidle setup play you either pass reference input object parameter in inline call callback this: <input id=

xaml - Changing PivotItem with swipe gesture crashes app (Visual C#, Windows Runtime, Windows Phone) -

in windows phone project (visual c#, windows runtime) i've got xaml page 2 pivotitems. use pivot_selectionchanged event change bottomappbar . works fine when pivotitem changed tapping header of inactive pivotitem , when use swipe gesture change it, content of next pivotitem doesn't load , debugger breaks in #if debug && !disable_xaml_generated_break_on_unhandled_exception unhandledexception += (sender, e) => { if (global::system.diagnostics.debugger.isattached) global::system.diagnostics.debugger.break(); }; #endif with no details exception. double-checked both xaml , visual c# code, seems ok. how can fix that? (disabling swipe gesture ok.)

php - Search for records with similar tag id -

i have tagging table looks this: id | product_id | tag_id --------------------------- 1 | 1 | 10 2 | 1 | 12 3 | 2 | 10 4 | 3 | 11 i'm creating search page take tags input user (1 or more) , search database records tags present. example: if user entered '10' table above result product_id 1 & 2. edit: there 2 user input include tag -> search product these tags exclude tag -> search products without these tags so search query have first ignore exclude tags search product 'include tag'. edit 2: the user can enter 1 or more tag. any idea how this? here simple approach using aggregation , having : select tt.product_id tagtable tt group tt.product_id having sum(tt.tag_id in ($excludedtags)) = 0 , sum(tt.tag_id in ($includedtags)) = #numberincludedtags; you need put in number of included tags second condition. also, assumes tags table not have d

r - Magrittr functions - how to package them? -

i have 2 related questions writing functions in magrittr package & including them in package. in normal way of writing function, can specify library(package.a) within function call if of steps uses function package.a . how call in pipe environment (from magrittr )? this part of question arose when tried package functions, , few of functions use magrittr 's way of creating functions. wasn't able add functions package. devtools package's combine function didn't recognize %>% pipe. had re-write them normal functions include them in package. how overcome this? update namespace file, see 1.5 package namespaces . add import(magrittr) , don't forget add imports: magrittr in description file. regarding comment on :: . while importing magrittr exported function using import(magrittr) don't have use :: operator point package. of course long did not create function same name in package override name imported package, need :: . ::

jquery - Bootstrap navbar menu logo not working -

Image
please take on bootply or below code snippet , using bootstrap 3.1 because want use awesome search box on site. having issue, navbar logo not working (it's not hovering it's not clickable). note: brand logo working fine in mobile version, having issue in desktop versions. so, if running below code snippet, click full screen see problem. i not css guy, can guys please me how fix this. thanks $(function () { // remove search if user resets form or hits escape! $('body, .navbar-collapse form[role="search"] button[type="reset"]').on('click keyup', function(event) { console.log(event.currenttarget); if (event.which == 27 && $('.navbar-collapse form[role="search"]').hasclass('active') || $(event.currenttarget).attr('type') == 'reset') { closesearch(); } }); function closesearch() { var $form = $('.navbar-collapse form[role=&

iPad Javascript Debugging -

we have huge client-side application doesn't work @ on ipad , have no idea why. unfortunately don't have book way of showing or explaining particular piece of javascript doesn't work because call tell, there none. can heavy javascript users give me clues how can troubleshoot this? ps - windows shop, willing go buy macbook pro troubleshoot if need be, i'd prefer save 2 grand if can. i don't use windows, assume use virtualization software run osx on pc , use safari remote web inspector: https://developer.apple.com/safari/tools/ it looks there 2 tools available if doesn't work: https://people.apache.org/~pmuellr/weinre/docs/latest/home.html http://www.telerik.com/platform#test

javascript - Angular ui-calendar events function called twice -

i developing project angularjs , using angular-ui ui-calendar. in code initialize eventsources model ui-calendar empty array ([]) , set ui-config "events parameter" custom function. function makes $http request , calls callback function given events function. however, found out when load page or change month viewed left or right buttons, events function called twice. how can solve that? here code: function calendarctrl($scope, data){ var date = new date(); var d = date.getdate(); var m = date.getmonth(); var y = date.getfullyear(); // stores events var events = []; /* config object */ $scope.uiconfig = { calendar:{ height: 450, editable: true, header: { left: 'prev,next', center: 'title', right: 'month,agendaweek,agendaday' }, buttontext: { month: "ay", week: "ha

inserting huge ammount of rows into mysql useing C# from csv file -

i need insert data csv files dates strings ints code every file have 28column , 6000 rows need insert data of multiple file when clicking on buttom tryed insert them row row using sql insert statment take around 2 mins finish , crash need make proccess faster , smooth check if row inserted no rows same data inserted database appreciated if there lot of duplicates in files, load rows list , use distinct method in system.linq before inserting database. type contained in list implement icomparable interface.

r - Counting Frequencies Using (logical?) Expressions -

i have been teaching myself r scratch please bear me. have found multiple ways count observations, however, trying figure out how count frequencies using (logical?) expressions. have massive set of data approx 1 million observations. df set so: latitude longitude id year month day value 66.16667 -10.16667 cpuele25399 1979 1 7 0 66.16667 -10.16667 cpuele25399 1979 1 8 0 66.16667 -10.16667 cpuele25399 1979 1 9 0 there 154 unique id's , 154 unique lat/long. focusing in on top 1% of values each unique id. each unique id have calculated 99th percentile using associated values. went further , calculated each id's 99th percentile individual years , months i.e.. cpuele25399 1979 month=1 99th percentile value 3 (3 being floor of top 1%) using these threshold values: each id, each year, each month- need count amount of times (per month per year) value >= ids 99th percentile i have tried @ least 100 different approaches th

javascript - Set Evenet Listener on Selectobox is disabled(DOMAttrModified) -

i set event listener on selectbox should triggerd while attribute changed disabled. tryed following: <select id="a"> <option>heino</option> <option>michael jackson</option> <option>tom waits</option> <option>nina hagen</option> <option>marianne rosenberg</option> </select> <button id="b">action</button> <script type="text/javascript"> var = document.getelementbyid("a"); a.addeventlistener('domattrmodified', function() { alert(0); }, false); var b = document.getelementbyid("b"); b.onclick = function() { a.setattribute('disabled', 'disabled'); }; </script> by changing disabled attribute attribute example working fine. have idea trigger event? solution browsers nice. thanks with a.setattribute('disabled', 'disabled') disable <select> , not specific &l

mysql - How do I add a boolean that can only have one true for one column name of the same type? -

i have table called computer , column office_id, computer_name, server. each office id have 1 computer server. if have multiple computers in office. 1 computer in office server , server required. there can't office no server. if try implement in computers table, need use trigger in mysql. other databases support things filtered indexes , computed columns making unnecessary, not mysql. instead, add column offices table: create table offices ( . . . , serverid int not null, foreign key (serverid) references computers(computerid) ); this guarantee each office has 1 server. might need trigger guarantee officeid in computers table matches officeid in offices table, though.

sorting - Python Pandas sort by column, but keep index same -

i created data frame consists of country, deal_category, , some_metric. it looks country metric_count channel 0 country1 123472 c1 1 country1 159392 c2 2 country2 14599 c3 3 country2 17382 c4 i indexed according country , channel using command df2 = df.set_index(["country", "channel"]) this creates following dataframe. metric_count country channel country1 category1 12347 category2 159392 category3 14599 category4 17382 country2 category1 1234 here's want do. i'd keep structure same , sort according metric counts. in other words, i'd display each country, top 3 channels based on metric count. for instance, i'd dataframe display each country, top 3 categories ordered descending metric_counts. country2 top category1 12355555 top category2 159393 top category3

ios - UIPercentDrivenInteractiveTransition doesn't get to animation's completion on fast gesture -

i have created interactive transition. func animatetransition(transitioncontext: uiviewcontrollercontexttransitioning) quite normal, container uiview , add 2 uiviewcontrollers , animation changes in uiview.animatewithduration(duration, animations, completion) . i add uiscreenedgepangesturerecognizer uiviewcontroller . works except when quick pan. in last scenario, app not responsive, still on same uiviewcontroller (the transition seems not have worked) background tasks run. when run debug view hierarchy , see new uiviewcontroller instead of previous one, , previous 1 (at least uiview ) stands supposed stand @ end of transition. i did print out , check points , can when problem occurs, the animation's completion (the 1 in animatetransition method) is not reached , cannot call transitioncontext.completetransition method complete or not transition. i see pan goes uigesturerecognizerstate.began straight uigesturerecognizerstate.ended without going through uigestur