Posts

Showing posts from July, 2013

sql server - SSIS Issue with date conversion -

i'm working on importing csv db. data should work, it's data application used through dblink have csv upgrade. dates this: 4/30/2001 tried simple import numbers , strings, , got error, did derived column. derived column works on dates not null (formula (dt_date)dte) derived column failed on dates can contain nulls. tried update formula (isnull(edte) ? null(dt_date) : (dt_date)edte) . no success, still error: [flat file source - o1 [6743]] error: data conversion failed. data conversion column "edte" returned status value 2 , status text "the value not converted because of potential loss of data.". originally, in flat file source, dates set type date, , got error before got derived column. i've changed string, , makes derived column, both boxes red. here's error: [derived column 1 [17270]] error: ssis error code dts_e_inducedtransformfailureonerror. "component "derived column 1" (17270)" failed because error code

sql server - java.sql.SQLException: No suitable driver found for jdbc:sqlserver: -

problem dear all, connected java desktop application mssql using jdbc. when try connect java dynamic web application (mssql using jdbc) using same method show exception. sql exception java.sql.sqlexception: no suitable driver found jdbc:sqlserver://localhost;databasename=reamsdb;user=sa;password=xxx; i try many solutions internet none helped me. kindly me rid of problem. below files attached. thanks. ## dbtesting.java ## import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.sql.*; public class dbtesting { public void establishconnection() throws sqlexception { string user = "sa"; string pass = "ansari12345"; string connectionurl = "jdbc:sqlserver://localhost;" + "databasename=reamsdb;user="+user+";password="+pass+";"; conne

Two commands in one script ubuntu terminal -

i have 2 commands: #!/bin/bash python /srv/django/manage.py shell; execfile('/home/usr/myscript.py') i want use them in 1 script scr.sh. is, errors. commanderror: command doesn't accept arguments /home/usr/project.sh: line 7: syntax error near unexpected token `'/home/usr/myscript.py'' where myscript.py code want running when python shell appears. how go achieving this? thanks! what happening here ';' symbol wait until performed/run in shell. correct syntax #!/bin/bash python /srv/django/manage.py shell <<eof\ execfile('myscript.py') eof

python - Downloading google doc with Selenium -

i trying download google doc pdf using selenium in python. unfortunately, html knowledge quite minimal , result don't know html need have click file , download pdf. realize can use web developer tool html isn't working me well. here have tried far: from selenium import webdriver url = ' https://docs.google.com/document/d/1y1n-rr5j_fq9wfmg8e_ajo0opwlnanru4lqcxtw9t5g/edit?pli=1' browser = webdriver.firefox() browser.get(url) any appreciated; thanks! as mention in comment, google drive doesn't being scraped. the drive command looks right tool sort of job. - it'll you're trying do, not way want it. according docs (i.e. haven't tested it), command looks download file: drive pull --export docx --id 1y1n-rr5j_fq9wfmg8e_ajo0opwlnanru4lqcxtw9t5g (also, in general, find easiest way use selenium use selenium ide tell selenium want do, export resulting test case going file > export test case as... > python 2 / unittest / web driv

multithreading - python timer thread shutdown -

i trying create timer working thread, can exit @ time. python has build in timer, callback function called once?! have no idea why called timer. then have put sleep in working thread, bad idea. timerthread.cancel() cannot shutdown working thread. if use event exit working thread, working thread can exit after wake up. i expecting timer working thread, can exit @ time. , don't want working thread blocked. are there ways realize it? def show(): while 1: time.sleep(10) print("nice!") if __name__ == '__main__': timerthread = threading.timer(1,show) timerthread.start() while 1: input = str(sys.stdin.readline()) if input == 'exit\n': timerthread.cancel() break; to point, timer object [1] in python runs once , after period of time executes function. function, though, can start new timer object. example of implementation below. timerthread = none def timesup(): gl

Prolog list concat -

i learning prolog , have stumbled upon piece of code , cannot make sense of it: code: append([],ys,ys). append([x|xs],ys,[x|zs]):- append(xs, ys, zs). in example, instruction given is: code: append([1,2],[3,4],ys). and output ys = [1,2,3,4] and don't understand how happens. i understand values on xs removed 1 one until equals [], don't understand 1. why zs being changed; if fact append([],ys,ys) , zs should equal [3,4] why changing in way if obeys fact? 2. how [1,2] in beginning of zs ?? i used trace , result of more confuse, because zs values _g5166 , _g5112 , etc... values? memory addresses? and why that, if don't use write(), console displays ys = ... ? , why ys , not xs or zs ? regarding first pair of questions: it's not same zs . initially, when try append([1,2],[3,4],ys). , prolog says "hmm, if original ys in form [x|zs] , , need match append(xs, ys, zs). " next time says "hmm, if origina

html - change width of number clickpick component of Mobiscroll -

good day, there seems bug in mobiscroll's "number" component because no matter try can't make width size specify. must use version 2.14.0 or greater because custom theme builder doesn't work older versions. can resize width on older versions cannot use theme builder on older versions. using mobiscroll version 2.14.3 custom theme. below how use default ios7 theme , width settings still don't work: showpassengerpicker('#numadults_rt', '#numchildren_rt', '#numinfants_rt'); function showpassengerpicker(var1, var2, var3) { $(var1).mobiscroll().number({ theme: 'ios7', display: 'inline', language: 'en', mode: 'clickpick', showlabel: false, maxwidth: 40, minwidth: 40, fixedwidth: 40, height: 20, rows: 3, wheels: [ [ { label: '&

ios - Asssigning tint color for navigation bar in storyboard assigns wrong color -

Image
i'm trying set navigation bar color color. i in storyboard. i set color want, so: and happens: the color off, both in app , in storyboard. how fix that? there different rgb mode in xcode,check if both rgb mode match.

android - How to know a user as moved to a new Card in a Google Glass app? -

is there way cardscrollview or cardscrolladapter let me know when user moves 1 card another ? initially using gesturedetector detect swipes left or right, in glass applications users can use, e.g., two-finger swipes pan , move distant card (or voice controls). there must better way know when new card displayed track these directional events. i know cardscrollview.getselecteditemposition() gives me current card in view, not when new card displayed. i thought cardscrolladapter.getview() run every time new card displayed, in glass applications runs once in beginning of activity execution. any great. my glass somewhere in storage can't test can try ondetachedtowindow , onattachedtowindow. this: private view buildview() { cardbuilder card = new cardbuilder(this, cardbuilder.layout.text); card.settext(r.string.whatever); view view = card.getview(); view.addonattachstatechangelistener(new view.onattachstatechangelistener() { @overrid

Django 1.6 Admin Page Overriding Not Working -

we're trying override admin page django 1.6, continues django/contrib/templates/...: settings.py: base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) templates = [ { 'backend': 'django.template.backends.django.djangotemplates', 'dirs': [ [os.path.join(base_dir, 'templates')], ], 'options': { 'context_processors': [ # insert template_context_processors here or use # list if haven't customized them: 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', &

objective c - Unable to add string into an mutable array -

i trying upload assignments table in different view controller. first when click on upload button code runs. - (ibaction)uploadassignment:(id)sender { nameofassignmentasstring = self.nameofassignment.text; nslog(@"%@", nameofassignmentasstring); nsinteger row; row = [self.subjectpicker selectedrowincomponent:0]; subjectofassignmentasstring = [subjectarray objectatindex:row]; nslog(@"%@", subjectofassignmentasstring); nsdate *deadline = [self.deadlinepicker date]; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"dd/mm/yyyy"]; deadlineofassignmentasstring = [dateformat stringfromdate:deadline]; nslog(@"%@",deadlineofassignmentasstring); homeworkviewcontroller *hvc; [hvc.nameofassignmentinanarray addobject:nameofassignmentasstring]; [hvc.subjectofassignmentinanarray addobject:subjectofassignmentasstring]; [hvc.deadlineofassignmentinanarray add

node.js - Can i use and is secure to use AJAX in my Server Node? -

i use native ajax make calls inside node.js server. is secure ?? can without problems ??? here's , example: .... node app.post('/postreceptor', function(req, res, next) { var data1 = req.body['input1']; var data2 = req.body['input2']; var xhr; if (window.xmlhttprequest) { // mozilla, safari, ... xhr = new xmlhttprequest(); } else if (window.activexobject) { // ie try { xhr = new activexobject('msxml2.xmlhttp'); } catch (e) { try { xhr = new activexobject('microsoft.xmlhttp'); } catch (e) {} } } xhr.open('get', encodeuri('http://www.website.com'), true); xhr.send(null); xhr.onreadystatechange = function() { if(xhr.readystate === 4) { // done if(xhr.status === 200) { // complete res.render('renderpage', { sendingdata: xhr.responsetext }); }

string - strsplit by integers in R -

suppose have strings such like: "0cgy-gcsf6hr-f-m5" "100cgy-lps12hr-m-m2" "300cgy-notrt24hr-f-m2" "0cgy-6h-m1" it's sort of complicated, want retrieve them to: "gcsf", "lsp", "notrt", "notrt" which means if there none of "gcsf", "lsp", "notrt", return "notrt". , integers before h/hr 6, 12, 24, 6 i have tried while frustrated. have ideas? do mean this? library(stringi) library(magrittr) s <- c("0cgy-gcsf6hr-f-m5", "100cgy-lps12hr-m-m2", "300cgy-notrt24hr-f-m2", "0cgy-6h-m1") stri_extract_all_regex(s, "[a-z]+(?=[0-9]+hr?-)") %>% unlist() %>% ifelse(is.na(.), "notrt", .) stri_extract_all_regex(s, "[0-9]+(?=hr?-)") %>% unlist()

javascript - Displaying returned json data from controller with AJAX -

i trying send post submission controller, , want receive json string can append information table. here's have far: my ajax call: $('#addticketbutton').click(function(){ $.ajax({ type:'post', url:'<?php echo site_url();?>ticket_system/add_ticket', data:{ 'headline': $("#headline").val(), 'description': $('#description').val(), 'category': $('#category').val(), 'priority': $('#priority').val(), 'assigned': $('#assign').val() }, datatype: 'json', success: function(data){ $("#created_table > tbody:last-child").append("<tr><td>" + data[0].ticketid + "</td><td>" + $("#headline").val() + "</td><td>" + data[0].lastupdated + "

CKEditor not shown when i download js file from server -

below script reference getting cke js server <script src="//cdn.ckeditor.com/4.5.0/standard-all/ckeditor.js"></script> when download server , add manually project ckeditor not shown. difference 2 situation? you've downloaded 1 file "ckeditor.js" tries load many other files (images, css, language files, dialogs, ...) can't work way. you should download instead full package can deploy server: http://ckeditor.com/download

PHP array to javascript array UTF-8 -

i've tried move php array javascript array. did: $cities = "בני ברק, גבעתיים, חוות שלם, רמת גן"; $php_array = explode(',', $cities); $js_array = json_encode($php_array,json_hex_apos|json_hex_quot); echo "<script type='text/javascript'> var cities = ". $js_array . ";</script>"; for reason, when open google chrome debuger, , check cities is, get: <script type='text/javascript'> var cities = ["&#1488;&#1494;&#1506;&#1511;&#1492; &#1489;&#1489;&#1504;&#1497; &#1489;&#1512;&#1511;"," &#1490;&#1489;&#1506;&#1514;&#1497;&#1497;&#1501;"," &#1495;&#1493;&#1493;&#1514; &#1513;&#1500;&#1501;"," &#1512;&#1502;&#1514; &#1490;&#1503;"];</script> i don't know why it's decoding. have php 5.6. later tried moving normal variable , when m

php - set_exception_handler not working -

i'm working on small site has custom error handling (or, rather error visualization ) , i'm having issue function involves both error , exception catching. so, have code: <? $query = sql::query("select * sitevars"); if ( !$query ) { kernel::log('could not retrieve sitevars.', 3, true); return false; } as can see, supposed use kernel::log method if query false kernel::log block takes care of launching exception if third argument equal true written follows: <? if ( $kill ) { $backtrace = debug_backtrace(); $caller = array_shift($backtrace); echo "test"; throw new exception($message." near line ".$caller['line']." on file ".$caller['file']); } now, issue that, though test printed, exception handler not called. set exception handler on __construct method of kernel class <? public function __construct() { global $config; self::$modlist = array('ke

elixir - Process.register Not Applying to Atom -

i trying make atom database connection redis. use name option in start of genserver , not available. in getting started (elixir 1.0.5), example seems show process.register(pid, :kv) option. maybe there better option make process accessible? following showing how doesn't match guard in query connection client. iex(2)> redis_client = exredis.start #pid<0.367.0> iex(3)> process.register(redis_client, :redis_client) true iex(4)> :redis_client |> exredis.query ["get", "test"] ** (functionclauseerror) no function clause matching in exredis.query/2 (exredis) lib/exredis.ex:95: exredis.query(:redis_client, ["get", "test"]) iex(4)> redis_client |> exredis.query ["get", "test"] :undefined iex(5)> redis_client |> exredis.query ["set", "test", "value"] "ok" iex(6)> redis_client |> exredis.query ["get", "test"] "

Pointers C Linkedlist Adding Always NULL -

i've written function adding end of singly linked list in c. don't why if head element null, why continues remaining null after successive adds. the struct defined this: typedef struct node* node; struct node { int data; node next; } in main have this: node test = null; add(test,1); add(test,2); add(test,3); function add defined such: void add(node head, int newdata) { node n = createnode(newdata); if (head==null) { head = n; return; } else { node tmp = head; while (tmp->next != null) { tmp = tmp->next; } tmp = n; } } createnode defined thus: node createnode(int data) { node n = (node) malloc(sizeof(struct node)); n->next = null; n->data = data; return n; } what confused that, add function works fine if first initialize head (node test = createnode(1)) , proceeds add rest of values alright. if leave test node null, doesn't add values?

apache - htaccess - htpasswd: different AuthUserFile depending on subdomain -

it's been couple of days looking @ how manage have different authuserfile paths depending on subdomain. why have problem: admin access of site protected htaccess - htpasswd. i'm managing repo bitbucket , configuring automatic deployments. because of deployment system, need use same files every site instance: let's have: local.mysite.com staging.mysite.com www.mysite.com the problem authuserfile absolute path different each "site", need define based on subdomains. what attempted do: thinking using if statement that: <if "host == 'local.mysite.com'"> authuserfile </if> but i'm running apache 2.2 not available. i thought using like: setenvif host ^local\.mysite\.com$ env_local <ifdefine env_local> authtype basic authname "password required" authuserfile /my/local/path/.htpasswd require valid-user </ifdefine> but apparently, ifdefine cannot read setenvif variables. and i&

Ordering a hash in descending order in Ruby doesn't work -

i have hash contains commit id (key) , number (value). in following how added value hash: @allcommits[commit] = count the following example commit ids , values: key: 42ac06787b8db8a6a299aa65482072f238dffc21 value: 3 key: a2658427039df49687d5ea590d8a0053631a2571 value: 1 key: 4ab0aab2e5fe9d650ce1fb96c48587783c7e296c value: 1 key: 469a15d2ecea8671a3f3c77813011163e2605d9e value: 4 key: 66558be4e7ddd5e9d9db3d512c859410d275c97a value: 1 key: ee9b9bac044c8306c81c7b3a3aa0632a7835e913 value: 2 then, before printing want order hash in descending order based on value. so, did @allcommits.sort_by {|k,v| v}.reverse but did't work, gave me order insert them in hash. i also, tried hash[@allcommits.sort_by{|k, v| v}.reverse] but nothing. i can't see problem here, help? it seems working me: input: @all_commits = { '42ac06787b8db8a6a299aa65482072f238dffc21' => 3, 'a2658427039df49687d5ea590d8a0053631a2571' => 1, '4ab0aab2e5fe9d

multithreading - Means for performing background operations in Scala -

i'd time consuming task in background. need start computation in different thread, able check if completed (maybe failed) , able abort computation when becomes unnecessary. after computation ended should call synchronized callback function store computed value. it may programmed wrapper on thread class. suppose basic functionality implemented in scala library already. i've tried search find akka simple task. scala.concurrent.executioncontext has useful execute method return no object check status of computation , abort on demand. what library contains described functionality? i've checked scala.concurrent.future . lacks ability abort computation, crucial. use following strategy: compute consuming function in background , provide reasonable default. if arguments function changed, drop original computation , start new. not imagine how rewrite strategy in terms of future.flatmap. i'll give demonstration of how use futures twitter's implementation

javascript get / set for property/ values -

why dose log 3 twice ? , how should done? so can set property car.set('property', 'value') and return value car.get('property') for value / property function model() {} model.prototype = { get: function(property) { return this._value; }, set: function(property, value) { this.property = value; this._value = value; } }; var car = new model(); car.set('name', 'ford'); car.set('age', 3); console.log( car.get('name'), car.get('age') ); since use dot syntax set properties, property names "property" , "_value" . if set multiple values, last 1 overwrite previous one. instead, think wanted set property name value in property variable. can use bracket syntax achieve that. model.prototype = { get: function(property){ return this[property]; }, set: function (property, value){ this[property] = value; } };

html - Images in centered Masonry grid do not scale with browser resize -

i'm using masonry displaying images in grid view on webpage. in order center grid container, i've followed masonry documentation , set following: isfitwidth: true and /* center container css */ .grid { margin: 0 auto; } this works perfectly. however, i'm finding when isfitwidth set true, images in grid stay fixed @ 380px (the actual size of images), , not scale down below size browser re-sizes. can have grid container centered , allow images scale down in size browser does? as can see below, using bootstrap's img-responsive class images. html: <div id="container"> <div class="grid"> <div class="grid-item"><img class="img-responsive" src="images/small/8.jpg" alt="image"></div> <div class="grid-item"><img class="img-responsive" src="images/small/17.jpg" alt="image"></div>

awk - Using an array of strings in gawk command in Linux -

i'm having problems applying gawk command array of strings. the gawk command in works fine: $ gawk '$1 == "name" {print $0}' data1.txt >> data2.txt with able find resembles word 'name' in column 1 of first data file, , copypaste whole line second data file. however, have procedure couple of times, , when trying following, doesn't seem retrieve anything: $ array=("name1" "name2") $ in "${array[$@]}"; gawk '$1 == $i {print $0}' data1.txt >> data2.txt; done the array seems fine, works when replace gawk command echo command. i've tried replace $i "$i", ${i}, "${i}", etc, didn't help. any idea i'm doing wrong?? i'm kinda new linux, sorry in advance noob question! the correct way this: for in "${array[@]}" awk '$1 == i' i="$i" data1.txt done > data2.txt if want avoid creating awk variable can this, not advise

multithreading - Possible / Recommended to write event driven app in Go? -

i designing app manage rabbitmq workers given rules. example: maintain minimum number of workers spawn n max number of workers if queue grows beyond m tasks kill workers older x minutes i thought of writing in go because compiled & compile app target os & daemonize it. however, concept design involves having loop gathers data every y seconds & passes through decision engine. engine raise events listened other goroutines either spawn or kill workers. i've found emission library acommodate this, read comment somewhere might not thread safe. honestly, knowledge of go & threaded programming not sufficient evaluate if library accomplish need or if possible in go. i write in nodejs , compiled using nexe . however, wanted learn new language, liked targeted compilation in go, , can multi-threaded beyond goroutines themselves. is possible or trying shoehorn go wasn't designed do? better accomplish same goals differently or use different language togeth

reporting services - Go to report action not working in SSRS web but works inside Report Builder 2.0 -

first , foremost, i've been saddled project because our sql , reporting guy quit. i've never had exposure ssrs or report builder (and limited sql experience) seem muddling through ok far. i've gotten point of publishing new reports on ssrs server , have run following problem. i use field in primary report "go report" action open report (also published) more details. works within reportbuilder (2.0) using report server , can go , secondary report expect. passing correct parameters second report , runs. but when reports ssrs web, go link no longer works. mouse hover shows still link clicking goes no where. can run both reports independently ssrs , still work. i've tried in ie , chrome no luck in either. poked around @ compatability view , popup blocker nothing made difference. thanks jw you must pay special attention absolute , relative paths used in "specify report" field. please see msdn article details on absolute , re

Php type hinting to object properties existance -

how can hint, argument receive must have several public properties? like: interface iperson { public $surname; public $name; } class { public function foo(iperson $p) { return $p->surname . ' ' . $p->name; } } but since interfaces can't point variables (why?), behavior above possible in php? may there in new php releases( 5.5-7.0 )? i think main issue php type system, no has property concept? define getters in interface: interface iperson { public function getsurname(); public function getname(); } class { public function foo(iperson $p) { return $p->getsurname() . ' ' . $p->getname(); } }

swift2 - compare two generic objects on swift 2.0 -

i have establish whether current value equal given comparing value. public static func is<tbasevalue, tcomparingvalue>(basevalue: tbasevalue, comparingvalue: tcomparingvalue) -> bool { return basevalue == comparingvalue } i try public static func is<tbasevalue: comparable, tcomparingvalue: comparable>(basevalue: tbasevalue, comparingvalue: tcomparingvalue) -> bool { return basevalue==comparingvalue } and this public static func is<tbasevalue: equatable, tcomparingvalue: equatable>(basevalue: tbasevalue, comparingvalue: tcomparingvalue) -> bool { return basevalue == comparingvalue } but have same result binary operator cannot applied.... equatable doesn't mean that. think things equatable - int , instance. 2 == 2 makes sense. 2 == 3 return false - still makes sense. now, think of else that's equatable - string , instance. "abc" == "abc" // true "acb" == "abc" // false

How can I automatically format a text file in Linux by a multi-occurring delimiter? -

i have string of unicode looks this: %ue8fc%u0089%u0000%u8960%u31e5%u64d2%u528b%u8b30%u0c52%u528b%u8b14%u2872%ub70f%u264 (but much longer)   i'd automatically format it, making new line every 7 "%"s the final formatting looks - able automatically format incredible - new line every 7 "%"s @ least enough "%u8b30%u0c52%u528b%u8b14%u2872%ub70f%u264a" + "%uff31%uc031%u3cac%u7c61%u2c02%uc120%u0dcf" + "%uc701%uf0e2%u5752%u528b%u8b10%u3c42%ud001" + is possible automate type of formatting command?

Android Eclipse to Android Studio -

i'm moving app minsdk 8 targetsdk 19 built in eclipse minsdk 14 targetsdk 22 built in android studio, since announcement of withdrawal of eclipse support. rather allowing android studio perform conversion, wanted create new project , manually port code over. i'm stuck. i have main activity extends appcompatactivity , uses navigation drawer , toolbar, works fine. fragment loads ok too, until try reference toolbar. my main activity code is: public class mainactivity extends appcompatactivity implements blanktestfragment.onfragmentinteractionlistener { private toolbar toolbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar = (toolbar) findviewbyid(r.id.tool_bar); setsupportactionbar(toolbar); ... ... my loaded fragment code is: public class blanktestfragment extends fragment { ... private toolbar toolbar; ... public static blanktestfragme

Fabric: rsync between two remote hosts -

i want rsync files remote production server remote backup server using fabric. server credentials stored in local ~/.ssh/config host backup hostname 1.1.1.1 port 33333 user swasher host production hostname 2.2.2.2 port 44444 user swasher now want run rsync on production machine, , need insert host/user/name of backup server in command, this @hosts('production') def backup(): run("rsync -avz -e 'ssh -p {port}' /from/ {user}@{host}:/to/'.format(backup.port, backup.user, backup.host)) how can credential of backup server run rsync? not w fabric job try copy dirs , nested subdirs local remote: cmd = "sshpass -p {} scp -r {}/* root@{}://{}".format( remote_root_pass, local_path, remote_ip, remote_path) os.system(cmd) don't forget import os, may check exitcode returned (0 success) also might need "yum install sshpass" and change /etc/ssh/ssh_config stricthostkey

How to construct the following JSONAPI url in Rails? -

im following http://jsonapi.org/format/#document-top-level i notice following end-point (route): /articles/1/relationships/author in rails, how route contstructed in routes.rb ? resources :articles # goes here? # should relationship namespace or other? # guess author can defined collection, or simple end relationships doesn't need have of 7 restful actions. the route should following code snippets: resources :articles resources :relationships, :only => [] collection :author end end end this how route file should like. please let me know if update needed.

Loop issue from Elegant javascript Chapter 2 Exercise 3 -

this question comes above source, in i'm asked make chess board. provided solution uses same method, except y < size , x < size. why doesn't way work? var size = 8; var chess = ""; (var y = 0; y == size; y++){ (var x = 0; x == size; x++){ if ((x + y) % 2 == 0) chess += " "; else chess += "#"; } chess += "\n"; } console.log(chess); -- you need understand how for loop works. read on @ https://developer.mozilla.org/en-us/docs/web/javascript/reference/statements/for . the second clause condition checked each time through loop, including @ beginning. if false , loop exited. loop continues while true . in case, want keep looping until x or y has reached size of board (actually, size of board less 1, since starting @ 0). therefore, following is correct: for (var y = 0; y < size; y++) { ^^^^^^^^ if did, , say for (var y = 0; y == s

javascript - Get initial state of ReactJs button from database -

im new reactjs , wonder how can set initial state of button component depending on sql database data? data via php & json , works fine can't how set state. every tip appreciated! thanks var outfitlist = react.createclass({ render: function() { var outfitnodes = this.props.data.map(function (data) { return ( <div classname="col-xs-12 col-sm-12 col-md-6 col-lg-6 singleoutfit" style={{background: '#e5e5e5'}}> <data author={data.author}> <img src={data.url}/> <div classname='row subimage'> <div classname='col-xs-4 col-sm-4 col-md-4 col-lg-4'> <div classname={data.fav == 1 ? 'isfav btn' : 'btn'}>click fav</div> </div> <div classname='col-xs-4 col-sm-4 col-md-4 col-lg-4 text-center'><h4>{data.title}</h4>

python - Order of operation in multiple applications of overloaded __le__ -

in python trying refunction __le__ operator in order chain variables "compared" list a > b > c should give [a,b,c] i have tried strange behavior depending on whether or not include brackets between values being compared. class opque: def __init__(self,opa,opb): self.ops = [opa,opb] def __gt__(self,b): #self > b #print("gt opque") if isinstance(b,operation): self.ops.append(b) return self elif isinstance(b,opque): self.ops.append(b.ops) return self else: raise valueerror class operation: def __gt__(self,b):#self > b if isinstance(b,operation): return opque(self,b) elif isinstance(b,opque): b.ops.insert(0,b) return b else: return valueerror = operation() b = operation() c = operation() if __name__ == "__main__": tmp1 = (a > b > c) print(

sql - Oralcle generate number column inline (single statement) -

i working on oracle , having difficulty on generating column of defined range (say, 2008 2011). know there sequences method see here . however, want have inline php can work smoothly. i know there rather ugly way of doing it; instance select 2008 yr dual union select 2009 yr dual union select 2010 yr dual union select 2011 yr dual is there more dynamic way? thanks kind assistance try this: select 2008 + level-1 yr dual connect level < 5 change constants needed.

c# - How do I make a method private and access it from another class? -

i curious how can make addoperands method private rather public coded now. have read examples of , set accessors , still don't understand concept. how made addoperands method private in calcengine class , still able use method class? using system; using system.collections.generic; using system.linq; using system.text; namespace project3_windowscalculator { class calcengine { private int operationresult; public int addoperands(int operand1, int operand2) { operationresult = operand1 + operand2; return operationresult; } public int subtractoperands(int operand1, int operand2) { operationresult = operand1 - operand2; return operationresult; } public int multiplyoperands(int operand1, int operand2) { operationresult = operand1 * operand2; return operationresult; } public int divideoperands(int operand1, int operand2) { operationresult = operand1 / operand2; re

java - roid.view.InflateException: Binary XML file line #12: Error inflating class RecyclerView -

anyone able me solve why not able run app past inital loading? if click on hourly or daily forecast both crash out. here 07-16 20:06:27.272 2191-2191/com.dredaydesigns.stormy e/androidruntime﹕ fatal exception: main process: com.dredaydesigns.stormy, pid: 2191 java.lang.runtimeexception: unable start activity componentinfo{com.dredaydesigns.stormy/com.dredaydesigns.stormy.ui.hourlyforecastactivity}: android.view.inflateexception: binary xml file line #12: error inflating class recyclerview @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2233) @ android.app.activitythread.access$800(activitythread.java:135) @ android.app.activitythread$h.handlemessage(activitythread.java:1196) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:

php - How to get the value from a dropdown list and use it as a form submit id -

i'm new yii may or may not make sense. want use on form submit dropdown list value id cat_id. model: public function getcategories(){ $user = yii::app()->db->createcommand() ->select() ->from('categories') ->queryall(); return $user; } this comes category model. controller: public function actioncreate() { $model=new posts; $categories = categories::model()->getcategories(); $model->cat = chtml::listdata($categories, 'id', 'name'); if(isset($_post['posts'])) { $model->attributes=$_post['posts']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'categories'=>$model->cat, 'model'=>$model, )); } view: <div class="row"> <?php echo $form->labelex($model,&#

debian wheezy to jessie apache start\cloudflare issue -

i apt-get dist-upgraded debian wheezy jessie , kept config files lamp stack , i'm getting following error when attempting start apache: (i'm totally stumped here. why apache\the cloudflare module not load?) root@county:~# /etc/init.d/apache2 restart [....] restarting apache2 (via systemctl): apache2.servicejob apache2.service failed. see 'systemctl status apache2.service' , 'journalctl -xn' details. failed! root@county:~# systemctl status apache2.service -l ● apache2.service - lsb: apache2 web server loaded: loaded (/etc/init.d/apache2) active: failed (result: exit-code) since thu 2015-07-16 20:58:34 edt; 21s ago process: 2166 execstart=/etc/init.d/apache2 start (code=exited, status=1/failure) jul 16 20:58:34 county systemd[1]: starting lsb: apache2 web server... jul 16 20:58:34 county apache2[2166]: starting web server: apache2 failed! jul 16 20:58:34 county apache2[2166]: apache2 configtest failed. ... (warning). jul 16 20:58:34 county apache2[2166]

c# - How to make a “asp:Button” work inside a “mmenu nav “ -

i’m trying integrate “jquery.mmenu” in visual studio project. seems “asp:button” not work inside “mmenu nav “. nor "asp:linkbutton" seems perform. take specific case of login: <%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="test._default" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="scripts/jquery-2.1.4.min.js"></script> <script src="scripts/jquery-ui-1.11.4.min.js"></script> <script src="scripts/jquery.mmenu.min.all.js"></script> <link href="content/themes/base/all.css" rel="stylesheet" /> <link href="content/themes/base/jquery.mmenu.all.css" rel="stylesheet" /> <title></title> <script> $(document).ready(function () {