Posts

Showing posts from July, 2014

ios - How to change color for tab bar non selected icon in swift? -

how change color tab bar non selected icon , text? found answer ( how change inactive icon/text color on tab bar? ), can't implement swift. the below sets defaults uitabbaritem's, can add appdelegate . change text color. uitabbaritem.appearance().settitletextattributes({nsforegroundcolorattributename: uicolor.blackcolor()}, forstate:.selected) uitabbaritem.appearance().settitletextattributes({nsforegroundcolorattributename: uicolor.whitecolor()}, forstate:.normal) for changing icon' color can either set image given state image have color. self.tabbaritem.selectedimage = [[uiimage imagenamed:@"selectedimage"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; self.tabbaritem.image = [[uiimage imagenamed:@"notselectedimage"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; or can way : add extension uiimage class (from this answer ) : extension uiimage { func imagewithcolor(color1: uicolor) -> uiimage {

animation - jquery scroll to different page and same page -

i know how animate scroll on link on same page. know how jquery page scroll external page. problem need use same hash link animate external page , internal page well. let me explain further suppose have 3 links, link link b-1 link b-2 and link b-1 , b-2 on same page , in succeeding divs. i'm in link , when click link b-2, should go page links b-1 , b-2 , animate scroll area link b-2 is. if click link b-1 while on same page, should animate scroll top. same thing should happen if on link a's page , clicked on b-1, should go page b-1 , b-2 , animate scroll b-1's section. if click b-2 on same page, should animate scroll section. does make sense? can me please? thank you if have access source code of external link, can pass variable set cookie in browser. , cookie when reach external link. in cookie put value scrolltoblock = b2. , when value cookie on external link enter, know scroll. you can read cookies here: set cookie , cookie javascript

SQL Server 2008: can 2 tables have the same composite primary key? -

Image
in case, tables reserve_details , payment_details ; can 2 tables have same composite primary key ( clientid, roomid )? or should merge 2 tables become one: clientid[pk], roomid[pk], reserveid[fk], paymentid[fk] in case, tables reserve_details , payment_details ; can 2 tables have same composite primary key ( clientid, roomid ) ? yes, can , happens in relational databases. (you have not set tag, since (a) using sql server, , (b) have compound keys, indicates movement in direction of relational database, making assumption.) whether should or not, in particular instance, separate matter. , gets design; modelling; normalisation. or should merge 2 tables become one : clientid[pk], roomid[pk], reserveid[fk], paymentid[fk] ? ok, realise design not robust. that normalisation question. cannot answered on just pair of tables, because: normalisation overall issue, tables need taken account, together, in 1 exercise. that exercise determines

Java NullPointerException javax.xml.transform -

i wrote simple xmlphonebook program inputs such firstname, lastname , phone number user (from input console) , saves xml file called " phonebook.xml ". program checks existing xml file , updates file if exist or else creates new file. first version code wrote without error handling class successful. when tried update code error handling class thats when started getting nullpointerexception javax.xml.transform. have posted both versions of code below understanding. main class xmlphonebook without error handling. /** * * @author sanjayan ravi */ /** * * class xmlphonebook main class controls getcontactinfo function , storecontactinfo. */ public class xmlphonebook { getcontactinformation gci; storecontactinformation sci; xmlphonebook() { gci = new getcontactinformation(); } /** * * getcontactinfo function triggers functions getfirstname, getlastna

regex - Why and when to use optional perl parameters in R -

out of curiosity, have general question optional perl parameter in r funtions grep . title says in title, i'd know why , when 1 should use option. general thing if possible? in addition thought reason of such parameter. must have decided way go , wonder why. i positive of knows answer. regular expressions come in multiple flavors . different flavors have different features, supported syntax, or other obscure differences. perl considered 1 of feature-complete flavor, led develomment of pcre (perl-compatible regular expressions) library, allows use of perl flavor in other languages. there other regex libraries support perl syntax extent. contrast default regex flavor used in r: posix ere, 1 of least feature-complete. you can use this site compare flavors.

html - Navigation Bar - LI:HOVER Full Height -

so want navigation bar, with, when hover on li / element, different color full height of navigation bar. because when hover on it, background-color of text changes... quite ugly... i hope clear enough, system blocks me uploading image :o. thank you! edit: forgot html , css: <ul id="nav"> <li><a href="">home</a></li> <li><a href="">courses</a></li> <li><a href="">subjects</a></li> <li><a href="">sign up</a></li> <li><a href="">log in</a></li> </ul> #nav { height: 60px; font-size: 30px; line-height: 60px; vertical-align: middle; text-align: center; background-color: #0080ff; width: auto; border: 10px solid #16044e; border-radius: 20px; z-index: 1; } #nav ul { } #nav li {

java - How to add buttons to the JFace ErrorDialog -

i'm trying add "cancel" button popup dialog, dialog gives user info , allows them hit yes or view details. problem there no cancel button , add one. the dialog jface errordialog uses premade multistatus display error message. dialog opens , gives ok button or cancel button. there anyway directly manipulate how dialog creates buttons or other method use change how looks? appreciated! if (errordialog.openerror(shell, messages.consistencyaction_confirm_dialog_title, null, multistatus, istatus.warning) != window.ok) { return; } this dialog i'm trying change. checking make sure presses ok, if don't exit. can exit hitting red x in corner it'd less confusing have button. you can extend errordialog class can override createbuttonsforbuttonbar method. for example eclipse p2 install plugin: public class okcancelerrordialog extends errordialog { public okcancelerrordialog(shell parentshell, string dialogtitle, string message,

c# - 403 error from HttpWebResponse Instagram -

first of sorry bad english. task authenticate in instagram api. when try token after user clicked "ok" 403 error httpwebresponse , can't token:(. don't know do. me please. , when enter link in me browser - it's ok httpwebrequest request = (httpwebrequest)httpwebrequest.create("https://instagram.com" + url); request.useragent = "mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.90 safari/537.36"; request.method = "post"; request.cookiecontainer = cookies; request.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; request.headers.add("accept-encoding: gzip, deflate"); request.headers.add("accept-language: ru-ru,ru;q=0.8,en-us;q=0.6,en;q=0.4"); request.headers.add("cache-control:max-age=0"); request.contenttype = "application/x-www-form-urlencoded"; request.host = "instagram.com"; request.headers.add(

mysql - Variable changes in PHP -

i need keep variable in long form, don't understand these changes. my code: //db connection $sql = "select * `slevy` 1 "; $result = $conn->query($sql); while ($row = $result->fetch_assoc()) { $sleva = $row['sleva']; echo $sleva; } echo "------------".$sleva; output is: 99381585659209563465667261720583722336659395405------------659395405 in body of cycle save $sleva , echo sales, after while cycle $sleva contains last 1 row database. while ($row = $result->fetch_assoc()) { $sleva = $row['sleva']; echo $sleva . '<br>'; } // output like: 993815856<br> 592095634<br> 656672617<br> 205837223<br> 659395405<br> you wrote to keep variable in long form . means, probably, save $sleva variable whole string, concatenate sales. $sleva = ''; while ($row = $result->fetch_assoc()) { $sleva .= $row['sleva']; } echo $sleva; // output: 993815

c# - Can't write class with params as property -

it seems can't write class params property. there way set params property class? for method, can this: public static void method(double x,params double[] k) { } i class takes unknown number of arguments. class: public class class { double x; params double[] k; } and create new object var obj = new class(1d, 1d, 1d, ...); // var obj = new class(1d, new double[] { 1d, 1d, ...}); //this not comfortable! is there way set params property class? no, , there no need. can make class constructor accept params double[] doubles , store them inside array: void main() { var = new a(1.0, 2.0, 3.0); } public class { private double[] doubles; public a(params double[] doubles) { this.doubles = doubles; } }

ember.js - MVC controller changes input field after submission -

i have amount field in form multiply 100 after submission in controller. problem view renders multiplication before moving on next page. how can avoid that? more generally, how prevent view display modified value once it's submitted? i'm using ember.js rails in backend, think it's more of mvc problem. this view: {{input value=model.amount mask="999[999].99" classnames="form-control" placeholder=(t 'transactions.amount')}} and controller: actions: { create: function() { var _this = this; var model = this.get('model'); model.set('amount', model.get('amount') * 100); model.save().then(function(transaction) { _this.get('target').transitiontoroute(_this.get('destination'), transaction.get('id')); }, function(response){ _this.set('errors', response.errors); }); } } this case use computed property, use in template: displayamount: function(k

ios - the behavior of the UICollectionViewFlowLayout is not defined -

i've been trying recreate, sample project given here . i've created , updated bridging-header file , working on viewcontroller.swift use libraries. code my viewcontroller.swift: import uikit class continueviewcontroller: uiviewcontroller, uicollectionviewdatasource, uicollectionviewdelegate { override func viewdidload() { } func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return 1; } func numberofsectionsincollectionview(collectionview: uicollectionview) -> int { return 4; } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { //var cell = rgcollectionviewcell() let cell = collectionview.dequeuereusablecellwithreuseidentifier("reuse", forindexpath: indexpath) as! rgcollectionviewcell self.configurecell(cell, withindexpath: indexpath) return cell; } func configurecell(cell: rgcollectionvie

c - _Generic: multiple types to a single value? -

using c11 _generic there way map multiple types single value? eg: _generic(e, \ *: foo_expression, \ b **: foo_expression, \ c: foo_expression, \ enum d: bar_expression, \ void *: bar_expression) is there way group types? (this isn't valid syntax express intent) _generic(e, \ *: b **: c: foo_expression, \ enum d: void *: bar_expression) the reason ask args foo , baz can end being large expressions (which can't refactored functions) , way avoid lot of duplication good. note: if there no supported way using _generic , _could_ make varargs macro glue multiple args single value... #define generic_type_glue3(answer, arg0, arg1) \ arg0: answer, arg1: answer #define generic_type_glue4(answer, arg0, arg1, arg2) \ arg0: answer, arg1: answer, arg2: answer .... ... have many of these macros, use varargs wrapper automatically use right one, see: https://stackoverflow.com/a/24837037/432509 _generic(e,

ember.js - Is it possible to include custom args in an Ember partial? -

there's piece of code in template that's repeated multiple times through it... want dry it. it's simple piece of code no logic on it. first, though creating array title , values loop, remembered handlebars not allow me it. second, though on partials. they're part of template, afterall. noticed apparently ignores additional arguments. thus, there's no way alter it's contents besides what's in model. in , in prior case, didn't want mess route/controller template-only variables. third, current solution component, seems so dirty . however, it's quite troublesome have js file empty object; furthermore, components have no file structure, , wanted piece of code live along it's original template. this simplification of wanted achieve: project/index.hbs {{partial "counter_block" value=model.count_success title="yeah!"}} {{partial "counter_block" value=model.count_failures title="boo :("}} project/

How to use MySQL Workbench to set up connection and connect Google cloud sql -

enter image description herei follow tutorial https://cloud.google.com/sql/docs/admin-tools but abstract. i unable set new connection in mysql workbench correctly. pops "failed connect mysql @ 2001:4860:4864:1:c88e:be5b:bd5:6cf7:3306 user root,10060" my google cloud sql ip address 2001:4860:4864:1:c88e:be5b:bd5:6cf7,port 3306 username :root. (i set root ) password : admin, each time. i have put computer's ipv4 address cloud sql allowed network (authorization). question guessed: 1. not sure how fill 'port', in local , know 3306 in general. not sure if port 3306 when instance address ipv6 format. is possible made mistake when set ip address in cloud sql authorization? used laptop in home internet. first searched ip address using google 'my ip address', 108.15.38.144', fill in "allowed network" in cloud sql. is possible made mistake when set user 'root'? type user name , password in user setting of access control in cl

sql - How can I more efficiently perform a query that returns how many times an ID appears in two other tables? -

i have found solutions other sources none of them seem executing efficiently me. using derby , current solution taking on minute execute! i trying find number of songs , albums belong given artist , display numbers in 2 separate columns next artist's name , id. ex: id name songs albums 425 j. smith 0 0 314 a. payne 32 3 412 k. thomas 423 35 the artist table has artist_id, song table has song_id , album_id, , album table has album_id , artist_id. tables aren't tiny. artist has 1,100 records, song has 73,000, , album has 7,000. here current solution: select ar.artist_id, ar.artist_name, count(s.song_id), count(distinct(al.album_id)) artist ar left outer join (album al inner join song s on al.album_id = s.album_id) on ar.artist_id = al.artist_id group ar.artist_id, ar.artist_name is there way make query perform better? id columns primary keys in respective tables, should indexed in derby if understand correctl

hadoop - UIMA DUCC vs UIMA on Haoop -

i trying design distributed-scalable pipeline based on uima. how should decide on using uima ducc or uima on hadoop? missing out, if build on uima ducc rather hadoop or vice-versa? one dimension application characteristics. hadoop have big advantage i/o intensive applications. ducc should have big advantage large memory applications need run multiple pipeline copies in different threads achieve high cpu utilization. another dimension taking advantage of uima vs taking advantage of hadoop. ducc builds on base uima capabilities, providing many scale out options, built in performance metrics, , debugging support, based on core uima components. more complex uima pipeline bigger advantage ducc; example, complex processing flows can implemented directly in ducc have transformed map-reduce. for sufficient hadoop expertise, relatively simple uima analytic can integrated existing hadoop shop without having learn uima.

swift - Why CFloat and CDouble?? func addNewValue(newVal: CFloat, atTime time: CDouble) -> CFloat {} -

i converted -(float) addnewvalue:(float) newval attime:(double) time { to func addnewvalue(newval: cfloat, attime time: cdouble) -> cfloat {} there no errors don't know why works. why float , double become cfloat , cdouble ? there no errors with: func addnewvalue(newval: float, attime time: double) -> float {} so supposed use? full code let maxperiod:double = 1.5 let minperiod:double = 0.1 let invalidentry = -100 let maxperiodstostore = 20 let averagesize:int = 20 class detector { let session = avcapturesession() var camera : avcapturedevice? var upvals = [averagesize] var downvals = [averagesize] var upvalindex: int? var downvalindex: int? var lastval: float? var periodstart: float? var periods = [maxperiodstostore] var periodtimes = [maxperiodstostore] var periodindex: int? var started: bool? var freq: float? var average: float? var wasdown: bool? func reset() { var

ios - Unbalanced calls to begin/end appearance transitions with custom segue -

in implementing following cross-dissolve custom segue on button press (learned @ https://www.youtube.com/watch?v=xq9zvslncww ): override func perform() { var src:uiviewcontroller = self.sourceviewcontroller as! uiviewcontroller var dstn:uiviewcontroller = self.destinationviewcontroller as! uiviewcontroller src.view.addsubview(dstn.view) dstn.view.alpha = 0 uiview.animatewithduration(0.75 , delay: 0.1, options: uiviewanimationoptions.transitioncrossdissolve, animations: { () -> void in dstn.view.alpha = 1 }) { (finished) -> void in dstn.view.removefromsuperview() src.presentviewcontroller(dstn, animated: false, completion: nil) } } i getting "unbalanced calls begin/end appearance transitions" warning/error. i have thoroughly searched many stackoverflow questions: unbalanced calls begin/end appearance transitions <uitabbarcontroller: 0x197870> my response: using segue button press not withi

hadoop - Java MapReduce - How to Output Top 10 from an IntWritable Sum in Reducer Class -

i'm having difficulty writing reducer code top 10 (key,value) pair output. my current output formatted ((year, market), total amount). i'm looking top 10 total amounts each year. current code outputting every amount every market each year. any recommendations appreciated! mapper: public class fundingmapper extends mapper<longwritable, text, text, intwritable> { private text year = new text(); private text market = new text(); public void map(longwritable key, text value, context context) throws ioexception, interruptedexception { string line = value.tostring(); csvreader reader = new csvreader(new stringreader(line)); string[] array = reader.readnext(); reader.close(); year.set(array[14]); market.set(array[3]); string amountstring = array[15].replaceall("[^0-9]",""); int amount = 0; try { amount = integer.parseint(amountstring); } catch(numberformatexception nfe) { return;

python - Tkinter: widgets not highlighting on <Tab> event -

i'm running python 2.7.9 on mac. i've been unable figure out why when run programs entry widgets highlight each time hit tab key move next widget. following test code. when run script , hit tab key, first entry field highlighted. next time hit tab key, second entry field highlighted. however, when hit tab key move button widget, button receiving focus there not highlight visually indicate user focus. the optionmenu widget skipped altogether, mystery. both radiobutton , checkbox receives focus, button widget, , again no highlight present. i've tried variety of .config() arrangements no avail. missing? from tkinter import * class app: def __init__(self, master): frame = frame(master) frame.grid() #tests make sure button receives focus. def yup(self): print "yup" entry1 = entry(frame) entry1.pack() entry2 = entry(frame) entry2.pack() button1 = button(frame,

javascript - How to display content in horizontal? -

i'm using session php. , i'm not getting display horizontally. how do that? php: if(isset($_get['nome']) && $_get!=['nome']){ $lista_tarefa = array(); $lista_tarefa['nome'] = $_get['nome']; } if(isset($_get['descricao'])){ $lista_tarefa['descricao'] = $_get['descricao']; } else { $lista_tarefa['descricao'] = ''; } php+html: <table> <?php foreach ($lista_tarefa $tarefa) : ?> <tr> <td> <?php echo $tarefa; ?> </td> </tr> <?php endforeach; ?> </table> i guess... $a=0; while($a<=3){ foreach ($lista_tarefas $tarefa): echo $tarefa[a]; if($a<=3){ ???? } $a++; } but not work. me? your display vertical because each $tarefa in different row of table due <tr&

Calling up html text box using javascript and converting it to an integer -

so want understand how this, simple example: my html <div id = "pie"> eee </div> <input type="text" name="item1" size="5"> and javascript is var q = parsefloat("10"); document.getelementbyid("pie").innerhtml = q ; and want call whatever text in text box (named item1) , convert integer, display number. i'm sure there's easy way cant figure out try this: +(document.getelementsbyname('item1')[0].value); that shortest way display it, example in element #pie document.getelementbyid('pie').innerhtml = +(document.getelementsbyname('item1')[0].value) putting + before convert number. if text box isn't number can detect by: var value = document.getelementsbyname('item1')[0].value; document.getelementbyid('pie').innerhtml = !isnan(value)?+value:"not number"; demo

ember.js - Heyoffline in Ember CLI -

i building ember cli app , want use heyoffline.js. have installed using bower: bower.js: "heyoffline": "~1.1.1" brocfile: app.import('bower_components/heyoffline/heyoffline.js'); i trying load using initialiser, below. not seem work - nothing happens when go offline. there no errors in console. loading incorrectly? thanks. export default { name: 'heyoffline', initialize: function() { document.addeventlistener('deviceready', function () { new heyoffline(); }, false); } }; i managed working setting "service" instance of heyoffline in application, follows: export default { name: 'heyoffline', initialize: function(registry, application) { ... var heyoffline = heyoffline.create(); application.set('service', heyoffline); } }; i had create ember object heyoffline: var heyoffline = ember.object.e

python - Inverse Matrix (Numpy) int too large to convert to float -

i trying take inverse of 365x365 matrix. of values large 365**365 , converted long numbers. don't know if linalg.matrix_power() function can handle long numbers. know problem comes (because of error message , because program works fine smaller matrices) not sure if there way around this. code needs work nxn matrix. here's code: item=0 in xlist: xtotal.append(arrayit.arrayit(xlist[item],len(xlist))) item=item+1 print xtotal xinverted=numpy.linalg.matrix_power(xtotal,-1) coeff=numpy.dot(xinverted,ylist) arrayit.arrayit : def arrayit(number, length): newarray=[] import decimal i=0 while i!=(length): newarray.insert(0,decimal.decimal(number**i)) i=i+1 return newarray; the program taking x,y coordinates list (list of x's , list of y's) , makes function. thanks! one thing might try library mpmath , can simple matrix algebra , other such problems on arbitrary precision numbers. a couple of caveats: slower

ruby on rails - How to stop outputing my own html source? -

Image
this may werdeist bug i've ever met. i'm building app personal use on ruby on rails, , it's still long way done. main layout follows: !!! %html.uk-height-1-1 %head = render 'layouts/head' %body.uk-height-1-1.uk-width-1-1 = if user_signed_in? .alerts = render 'layouts/alerts' .navbar = render 'layouts/navbar' .uk-container.uk-height-1-1 = yield = if user_signed_in? .footer = render 'layouts/footer' the alerts , footer partials still empty, head partial default code rails generates (minus turbolinks) , navbar partial is, well, navbar. change made on application controller adding before_action :authenticate_user! , users logged in can see main site. but run server, following showed up: it outputs it's own html source code plain text! , twice: first, right after navbar partial, , last after footer partial. i've never met close this, , a

java - Getting indexOutOfBOundException 0 -

why keep getting indexoutofboundexception 0 on following line?: rotatedshape[r][c] = shape[c][height-1-r]; the method rotatecw() turns char[][] 90 degrees clockwise im keep getting error. smb please take look? thank you! public static void main(string[] args) { createshape temp = new createshape(10,10, 'a', new char[][]{{'x','.','.'}, {'.','.','x'}, {'x','.','x'}}, "x . .\n" + ". . x\n" + "x . x"); temp.rotatecw(); system.out.println(temp); } public class createshape implements shape { private string templayout = ""; private string layout; private int height; private int width; private char dc; private rotation initialpos; private rotation nextpos; private char[][] shape; private char[][] rotatedshape = new char[height][wid

java - HashMap not matching the value -

i have hashmap of buttons corresponding points in matrix. example in 3x3 matrix, btn0 @ (0,0) , on. point class 2 int variables coordinates. hashmap below: public final static hashmap<button, point> buttonpoint = new hashmap<button, point>(); buttonpoint.put(btn0, new point(0,0)); buttonpoint.put(btn1, new point(0,1)); buttonpoint.put(btn2, new point(0,2)); buttonpoint.put(btn3, new point(1,0)); ... i perform few calculations , come point (1,0). want button coordinates. following: button selectedbutton = null; for(java.util.map.entry<button, point> entry : buttonpoint.entryset()){ if(objects.equals(selectedpoint, entry.getvalue())){ selectedbutton=entry.getkey(); } } but selectedbutton still null. debugged code , see values equal @ point in iteration, still if condition never becomes true. there missing hashmaps ? or there other way of doing ? link or direction towards solution helpful. in advance. if want button coordinate

php - Doctrine 2 Migrations Workflow -

i developing web application using zend framework 2 , doctrine 2. i'm new doctrine 2 in general , migrations in particular. wondering if there recommended best practices in using this. specific things i'm looking for: a recommended workflow development deployment? do include pre-populating data in migrations? how handle reverting previous version if migration fails. many thanks! doctrine has own library migrations , includes symfony bundle. for zend there some bundle well (maybe seek on github bit more) as specific questions: nothing special. basic workflow nicely described in symfony bundle documentation . use in pretty same way in different framework. yes, every developer has operational system. tests use data-fixtures minimal required data only. it's managed package itself.

java - Android SQL Database ERROR (Code 1) -

i'm trying display data database 1 one changing if next button clicked. , wanted check if program select first data database error message. caused by: android.database.sqlite.sqliteexception: no such column: color (code 1): , while compiling: select distinct _id, brand, model, price, color, img car _id=1 dbadapter.java import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; import android.util.log; /** * created asus on 24.04.2015. */ public class dbadapter {private databasehelper dbhelper; private sqlitedatabase db; private final context context; public static final string key_rowid = "_id"; public static final string key_brand = "brand"; public static final string key_model = "model"; public static final string key_price = "price&q