Posts

Showing posts from September, 2014

unity3d - How do I create an AR marker for Vuforia / Unity? -

this horribly basic question know (!) how create , import ar marker unity? know meant through vuforia marker manager page. have created target database , have downloaded database, how marker display in unity? also: target database? name 'marker'? to answer question specifically, yes marker target. so need is: go license manager . add license key choosing none license plan. now go target manager . create database , add license drop down. add target, , select computer image want marker, , upload it. once status of target changes active can click download database , make sure click unityeditor. downloads .unitypackage now inside unity, go assets > import new assets... , locate .unitypackage downloaded this how import database. if haven't imported vuforia package unity extension need download downloads section , import through assets > import package > custom package now ideally work ar, use ar camera , located in assets ba...

MySQL: get all users who haven't done any training in 2 years -

i need users haven't carried out training in last 2 years. we run 3 courses year: basic 1 in january, basic 2 in february , basic 3 in march. not needs training each year must have completed course in last 2 years in order keep registration. @ present through each user record , highlight user if none of training courses occurred in last 2 years but, number of users increases, need check users @ once i've been looking @ queries might provide data , display date of last training , name of course if haven't completed training in last 2 years. so, instance, given 2 tables here: users_temp: +----+-------+ | id | name | +----+-------+ | 1 | david | | 2 | john | | 3 | barry | | 4 | mary | +----+-------+ courses_temp: +---------+------------+---------+ | user_id | date | name | +---------+------------+---------+ | 1 | 2015-01-01 | basic 1 | | 1 | 2015-02-02 | basic 2 | | 1 | 2015-03-03 | basic 3 | | 2 | 2015-01-01 | basic 1 | | 2...

Can I mix MySQL APIs in PHP? -

i have searched net , far have seen can use mysql_ , mysqli_ meaning: <?php $con=mysqli_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed connect"; }else{ echo "connected"; } mysql_close($con); echo "done"; ?> or <?php $con=mysql_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed connect"; }else{ echo "connected"; } mysqli_close($con); echo "done"; ?> are valid when use code is: connected warning: mysql_close() expects parameter 1 resource, object given in d:\************.php on line 9 done for first , same except mysqli_close() . second one. what problem? can't use mysql_ , mysqli together? or normal? way can check if connections valid @ all? (the if(mysq...) ) no, can't use mysql , mysqli toget...

php - A non well formed numeric value encountered in - setcookie function -

$user_id = $row['userid']; $token = uniqid($user_id,true); $salt = md5(mt_rand()); $cookie_id = hash_hmac('sha512',$token,$salt); $nextweek = time() + (7 * 24 * 60 * 60); $expiry = date('y-m-d', $nextweek); //problem exists here $sql_store_cookie = "insert pcookies(cookie_id,user_id,expiry,salt) values('$cookie_id','$user_id','$expiry','$salt')"; mysqli_query($connection,$sql_store_cookie) or die(mysqli_error($connection));//die('{"l":"mysqli_error(`$connection`)"}'); setcookie($cookie_id,$token,$expiry); if run above program, getting non formed numeric value warning in setcookie line. hope using correct format of type. my timezone setting asia/kolkata , expiry data type timestamp. i trying set 7 days current time. please tell me doing wrong her...

Linux - delete some parts from video (mp4) -

how can remove several parts video in command line? or how can select intervals video , create file them? tried convert video mpg (mpg file ok) , use that: mpgtx -j input.mpg [0:10-0:20] [0:42-0:52] [1:23-1:33] -o output.mpg but result file incorrect. answers!

windows - how to delete commit entries in github? -

trying delete commit entries in remote github repo. how can keep last 5 commits , delete others? tried this: how remove selected commit log entries git repository while keeping changes? after 'git log' on local machine looks got result after 'git push origin' checked github , older commits still there? edit: tried : git rebase -i head~5 the editor comes , close it. when 'git log' did not reduce number of commits 5? you have force-push: git push -f origin

intellij idea - Android Drawable Importer Error - "You have to select the Android Icons asset folder in the settings" -

Image
i have download action bar icon pack , want import icons res directory. able simple copy , paste folders 1 image, works first time: now, have images in following structure , want put each 1 corresponding res sub-folder: 02_navigation_back drawable-hdpi ic_action_back.png drawable-mdpi ic_action_back.png drawable-xhdpi ic_action_back.png drawable-xxhdpi ic_action_back.png i have installed android draw-able importer in order not hand. when try use androidicons drawable import or material icons drawable import options getting following error: you have select android icons asset folder in settings! the scaled drawable option seems work, accepts 1 image , create rest automatically think. how import icons pack , put each image in correct folder automatically? i using android studio 1.2 beta 3 under ubuntu 15.04 . i suppose have understand wrong. need specify root folders icons androidicons drawable import , material ic...

Python one exception multiple handlers -

i want this: try: raise a() except a: print 'a' except (a, b): print 'a,b' which hoped print both a , a,b . that doesn't work (only first except executed). makes sense first except swallow error, in case want catch subclass before it's parent. but there elegant way work? i of course following, seemingly redundant code duplication, if more a , b involved: try: raise a() except a: print 'a' print 'a,b' except b: print 'a,b' (related multiple exception handlers same exception not duplicate. usage different , want know how best handle minimal code duplication.) it's rather common catch possible exceptions , exception type instance later: try: raise a() except (a, b) e: if isinstance(e, a): print('a') print('a', 'b') another option inherit 1 class e.g. class b(exception): def do(self): print('a', 'b') ...

image - Magento product weight - custom picture -

Image
i want have code in magento, following: gets product weight depending on weight displays custom png for example: if weight under 3 kg, displays shipping_1.png if weight between 3-5 kg, displays shipping_2.png, etc.. i think got use $product->getweight(); instance, since i'm not programmer, not know how go on it. can me snippet, start? thank you! i not know how want show weight images, doing show weight image on product page under price. it little hard no programming knowledge, need configure yourself, such image file path. firstly go folder: app/design/frontend/{package}/{theme}/template/catalog/product then find line : <?php echo $this->gettierpricehtml() ?> this code print out product price, should around line 60 insert following code below price code line: <?php /*add weight image on product page*/ $_weight = (float) $this->htmlescape( $_product->getweight() ); $weightimgpath =...

scala - play framework with mongodb -

i using mongo play framework "reactivemongo", makes async bridge between mongo connection , programm. standalone projects use casbah lib - has more native syntax (sometimes using of futures in each request not needed, , religion not allow me use async.await blocking each request ) me , no actors overhead, don't json bson conversion overhead. but using casbah in play framework direct way(just create mongo connection in controller ) produces connection leaks - means should create connection pool , control yourself, otherwords write reactivemongo. has used casbah mongo in production ? best , canonical way of creating , controlling connection in play ecosystem ? first should check connecting mongodb . go tutorial create scala project ( if used other editor follow scala project creation steps ). now check following steps : 1> projectname/conf/application.conf add application.conf mongo db name, collection name, port number, url etc. play reactive mong...

I am facing java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/ -

could 1 please assist me on below error facing while connecting ms access jdk1.8.0_45. appreciated. :) ide : eclipse luna ms access : 2010 as advised earlier in stack overflow have added below 5 jars in webcontent\web-inf\lib ucanaccess-2.0.9.4.jar jackcess-2.0.8.jar hsqldb.jar commons-logging-1.1.1.jar commons-lang-2.6.jar console log : **inside servlet inside connection catch exception : java.sql.sqlexception: no suitable driver found jdbc:ucanaccess://c:/chintandb/chintandb.accdb** apr 26, 2015 1:16:53 pm org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [myservlettest] in context path [/test] threw exception java.lang.nullpointerexception @ com.test.myservlettest.dopost(myservlettest.java:74) @ javax.servlet.http.httpservlet.service(httpservlet.java:646) @ javax.servlet.http.httpservlet.service(httpservlet.java:727) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) ...

What's the easiest way to add font-awesome in rails 4 -

i have followed instructions font awesome guide @ http://fortawesome.github.io/font-awesome/get-started/ font doesn't appear html.erb page, instead shows weird symbols. personally font-awesome-rails gem best. integrates fa asset pipeline , adds fa_icon helper can use in views.

javascript - How to add a docID from one NotesDocument to another using Java Script -

i have lotus script add organization docid contactdoc , work fine achieve in java script sub addcontactid(contact notesdocument, organisation notesdocument) contact.tmpidstring = organisation.docid(0) dim tmp variant tmp = |@setfield("contactorganisationids";@trim(@unique(contactorganisationids:tmpidstring)))| dim flag variant flag = evaluate(tmp,contact) dim item notesitem set item = contact.getfirstitem("tmpidstring") if not (item nothing) call item.remove end if end sub reverse function: sub removeorganisationidbyid(contactdocid string, organisation notesdocument) dim session new notessession dim currdb notesdatabase set currdb = session.currentdatabase dim contact notesdocument set contact = currdb.getdocumentbyunid(contactdocid) if contact nothing exit sub if organisation nothing exit sub dim contactorganisationids variant contactorganisationids = contact.contactorganisationids pos = arraygetindex(contactorganisationids, organisation.doci...

javascript - remove a row from dynamically created table using jquery -

in form im creating dynamic table of template below. <table id="newservice" style="display:none"> <tr> <td><input id="type-%" style="width:100px" class="act_type" type="text" name="provider_service_dtls[#].activity_type" readonly value /></td> <td><input id="code-%" class="act_code" style="width:150px" type="text" name="provider_service_dtls[#].activity_code" value /></td> <td><input id="start-%" class="datepicker" style="width:125px" type="text" name="provider_service_dtls[#].activity_start_date" value /></td> <td><input id="clinician-%" class="clini" style="width:200px" type="text" name="provider_service_dtls[#].clinician" value /></td> <td><input id="net-%"...

javascript - Cannot /Post - Login Authentication -

i creating app , need signin / signup functionality same. here signin html: <div style="padding-top:30px" class="panel-body" > <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div> <form action="verifysignin" method="post" id="verifysignin" class="form-horizontal" role="form"> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username" required="" autofocus="" > </div> <div style="margin-bottom: 25...

steam login using openID in android -

iam new android development. project make application using steam public api couldn't figure out how allow user login using steam account. steam's web api documentation states should use openid, searched alot find example implementing openid in andorid app, this example found , doesn't work, webview turns out blank. i want user click on login button fires webview user can login , steam id back. so question is is there way implement openid login in android? if not, there anyway allow user login steam? i think discovered sort of workaround guess. the steam openid can used url request this: https://steamcommunity.com/openid/login? openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select& openid.identity=http://specs.openid.net/auth/2.0/identifier_select& openid.mode=checkid_setup& openid.ns=http://specs.openid.net/auth/2.0& openid.realm=https://realm_param& openid.return_to=https://realm_param/signin/ where realm_p...

javascript - Workaround for a premature touchcancel event on Android Browser -

i'm trying modify jquery code website-based dropdown menu. working on workaround premature touchcancel event being fired on android browser build 4.4.2 samsung galaxy s4. here's code i'm trying work with: jquery(document).ready(function ($) { 'use strict'; $('.taptap-by-bonfire ul li ul').before($('<span><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 512 512" xml:space="preserve"><polygon id="arrow-24-icon" points="206.422,462 134.559,390.477 268.395,256 134.559,121.521 206.422,50 411.441,256 "/></svg></span>')); $(".menu > li > span, .sub-menu > li > span").on('touchstart click', function(e) { e.preventdefault(); if (false == $(this).next().is(':visible')) { $(this).parent().siblings().find(".sub-menu...

multithreading - Shared counter using combining tree deadlock issue -

i working on shared counter increment application using combining tree concept. goal make application work on 2^n number of cores such 4, 8, 16, 32, etc. algorithm might err on thread failure. assumption there no thread failure or slow threads. two threads compete @ leaf nodes , latter 1 arriving goes tree. the first 1 arrives waits until second 1 goes hierarchy , comes down correct return value. the second thread wakes first thread up each thread gets correct fetchandadd value but algorithm gets locked inside while (nodes[index].isactive == 1) or while(nodes[index].waiting == 1) loop. don't see possibility of deadlock because 2 threads competing @ each node. guys enlighten me on problem?? int increment(int threadid, int index, int value) { int lastvalue = __sync_fetch_and_add(&nodes[index].firstvalue, value); if (index == 0) return lastvalue; while (nodes[index].isactive == 1) { } if (lastvalue == 0) { while(nodes[index].waiting == 1)...

ios - How long is too long in cellForRowAtIndexPath to cause UITableView scrolling flicker? -

my tableview's cellforrowatindexpath taking ~20-25ms @ times, although typically closer ~15, , causing issues. 35% of coming dequeuing cell. 60% of coming calling [cell layoutifneeded] (which solution has worked me bug/glitch in ios8 self sizing table view cells [more here: http://useyourloaf.com/blog/2014/08/07/self-sizing-table-view-cells.html] ). is ton of time in terms of screen flicker? when scroll table view, can tad jumpy. i'm wondering if has amount of time data taking lay out, or if more auto layout issue need correct. any ideas out there if 20-25ms inordinate amount of time, or under radar?

node.js - serve-favicon npm package not working with express -

i have node.js server , running expected on openshift, cannot seem favicon show up. have tried exact code on serve-favicon npm package github page no success. piece of server.js code: #!/bin/env node var express = require('express'); var fs = require('fs'); var favicon = require('serve-favicon'); var sampleapp = function() { // scope. var self = this; self.initializeserver = function() { self.createroutes(); self.app = express(); self.app.configure(function () { //use define static pages in directory self.app.use('/css', express.static(__dirname + '/css')); self.app.use('/js', express.static(__dirname + '/js')); self.app.use('/images', express.static(__dirname + '/images')); self.app.use(favicon(__dirname + '/images/favicon.ico')); }); // add handlers app (from routes). (var r in self.routes) { self.app.get(r,...

java - How to print a sequence of Strings column wise? -

i trying write program in java game designing; wanted have part in game imitated led lighting. sequence wanted print has printed column wise (from left right). the sequence going ascii art: db db d888888b 88 88 `88' 88ooo88 88 88~~~88 88 88 88 .88. yp yp y888888p and printing should done this: d b 8 8 8 8 o o o 8 8 ~ ~ ~ 8 8 y p each of columns should printed 1 after other, in front of each other. make print method each character using following print statement , call required 1 when necessary. example public void printxxx(){ // xxx replace character system.out.println("d b"); . . . on.... }

Spring boot rest service, how to get it to marshal the links as properties? -

first question here gentle :) i've got jpa project want expose rest. i've done far: my entity: @entity public class signupsheet { @id @generatedvalue private long id; @column private string name; @column private string description; @column @temporal(temporaltype.timestamp) private date datetime; @manytoone private user parent; @onetomany private list<volunteer> volunteers; //getter , setters } all , good, call added spring-boot-starter-data-rest pom , service. here's json back. http://localhost:8080/api-0.1.0/signupsheets/1 { "name": "auction", "description": "my first sign sheet", "datetime": "2015-04-22t03:47:12.000+0000", "volunteers": [ { "role": "bringing stuff", "comments": "i have comments!" } ], "endpoint": "/signupsheets", ...

Python Unicode Error 'in' Statement -

so i'm trying use check see if string 'in' string. but, 1 of strings has '™' character isn't in default set of unicode characters python uses. code like: if string in item.name: '''do something''' where item.name has trademark symbol. how can still check see if string in item.name (string have trademark symbol , want check that). thanks! by using unicode s. >>> u'™' in u'©™®' true

java - Out of Memory when Switching Activities -

i'm making android app menu activity , game activity. switching menu game , menu works, try go game activity, out of memory error. game activity loads in few bitmaps, in onstop() method game activity tried recycling bitmaps, calling finish(),and calling gc(), none of worked, still out of memory error when try switch game activity. i've tried researching far haven't found helps. there way fix , ensure game activity released memory when closed? outofmemory error occurs when application did not enough memory proceed object allocation. check memory size given application since using bitmap memory consumption might more. please increase memory limit , check behavior.

php - Escaping URL for stylesheet & W3C validation -

i have dynamic stylesheet in need provide variables php page, , using .htaccess, rewritten .css. way referenced in <head> of page is: <link rel="stylesheet" href="assets/css/min.css?style=testing&layout=flat&ver=0.1"> the problem when run through w3c validator, says it's invalid code , url needs escaped. but, when escape this: <link rel="stylesheet" href="assets/css/min.css?style=testing&amp;layout=flat&amp;ver=0.1"> the stylesheet not read properly. what can make valid code , work @ same time? some solutions pop mind: 1) use 1 parameter in url. <link rel="stylesheet" href="assets/css/min.css?style=testing_flat_0.1"> 2) use minification library minify (it's in php), return url this http://www.example.com/?css=70385ee2be4c63d0932eeb51baa1e5af after feed desired css files want minfy - https://github.com/mrclay/minify . 3) use service grunt ( https:...

javascript - Why won't $http.put in AngularJS work? -

i have following angular script in page: var app = angular.module('doorman', []); app.controller('formctrl', function($scope, $http) { $scope.create = function() { var msg = '{' + '"id":"id",' + '"building":"' + $scope.building + '",' + '"unit":"' + $scope.unit + '",' + '"firstname":"' + $scope.firstname + '",' + '"name":"' + $scope.name + '",' + '"carrier":"' + $scope.carrier + '",' + '"tracker":"' + $scope.tracker + '"' + '"delivered":"0",' + '"added":"now()"' + '}'; $http.put("104.131.166.246:8080/doorman/rest/pilot", msg). success(function(data, sta...

ios - Why does SpriteKit crash when transitioning back and forth between scenes -

i checked answer here , on other sites didn't definitive solution. i have 2 scenes scene 1: class gamemenuscene: skscene { override func didmovetoview(view: skview) { // add background var background: skspritenode = skspritenode(imagenamed: "starfield") background.position = cgpointmake(-20, 0) background.size = cgsizemake(self.size.width + 40, self.size.height) background.anchorpoint = cgpointzero background.blendmode = skblendmode.replace self.addchild(background) // add game title gametitle = skspritenode(imagenamed: "title") gametitle.name = "game title" gametitle.xscale = scale gametitle.yscale = scale gametitle.position = cgpoint(x: cgrectgetmidx(self.frame), y: self.frame.height * 0.75) self.addchild(gametitle) // add scoreboard scoreboard = skspritenode(imagenamed: "scoreboard") scoreboard.name = "scoreboard" scoreboard.xscale = scale s...

JQuery Hide on page load with 'starts with', can't unhide later -

i want hide div when load page. dynamic div though gets assigned class name, , number added based on other criteria. so have this. $(function() { $("[class^='myclass']").hide(); }); problem is, later, when try show div, want show 1 of them. try this. $(document).ready(function() { $("[class^='showdiv']").click(function() { // use showdiv value (array index) specific // class need show $(".myclass2").show(); }); }); problem is, doesn't show class. think because 'hide' function hiding starting 'myclass'. , kind of overrides when try show specific '.myclass2' since being hidden earlier hide. i can't unset hide though. otherwise of elements show up. i'm lost here. thanks. edit i tried this, , works. instead of hiding @ beginning, this. $(function() { $("[class^='myclass']").each(function( index ) { $(".myclass" + in...

ios - UITableViewHeaderFooterView can't change background color to clearColor -

this tableheaderview class, extends uitableviewheaderfooterview . class not have nib file , done programmatically. i want background color transparent, cannot make work. i've tried setting [self.backgroundview setbackgroundcolor:[uicolor clearcolor]] , [self setbackgroundview:nil] , [self.contentview setbackgroundcolor:[uicolor clearcolor]] , final result black background. i've spent hours on this, , have no idea how fix this. need working? #import "tableheaderview.h" @interface tableheaderview () @property (strong, nonatomic) uiview *background; @property (strong, nonatomic) uilabel *text; @end @implementation tableheaderview - (instancetype)initwithreuseidentifier:(nsstring *)reuseidentifier { self = [super initwithreuseidentifier:reuseidentifier]; if (self.contentview) { self.background = [uiview new]; [self.background setbackgroundcolor:[uicolor colorwithwhite:0.0f alpha:0.5f]]; [self.background settranslatesautoresizingmaskintocon...

php - Search Functionality broken by the wp 4.2 update -

repost wordpress.stackexchange: i run blog site posts authors, , implemented search return results if search author's name or search term contained in story. functioning , returned authors matched search, search returns every user every single time. i suspect has wp_user_query since since function updated in 4.2, have no idea how change compatible. here search code: add_filter('user_search_columns', 'user_search_columns_bd' , 10, 3); function user_search_columns_bd($search_columns, $search, $this){ if(!in_array('display_name', $search_columns)){ $search_columns[] = 'display_name'; } return $search_columns; } add_filter( 'get_meta_sql', 'user_meta_filter', 10, 6 ); function user_meta_filter( $sql, $queries, $type, $primary_table, $primary_id_column, $context ){ if ( $type !== 'user' ){ return $sql; } if ( ! isset( $context->query_vars['meta_query']['replace...

Django model filter with field_set, keep as queryset -

i have filter list method works, , can used, when try make , order_by on list, in can't done. how can , keep queryset make order_by after filter applied, i don't know of there better way work field_set's ? models: class case(models.model): user = models.foreignkey(user) .... class share(models.model): case = models.foreignkey(case) .... class field(models.model): case = models.foreignkey(case) field = models.foreignkey(defaultfield) .... - object_list = field.objects.all() l = [f f in object_list if f.case.share_set.filter(user=request.user).count()] this inefficient thing in case. should try , filtering in database as possible. query means db has send field rows django, instantiate them, throw away ones don't match. instead should query ones want: object_list = field.objects.filter(case__share__user=request.user) now, being more efficient, have queryset on can call order_by .

video.js player video is black -

i have strange problem video-js-4.12.5. i'm using ffmpeg on fedora 20 machine send live stream vps webcasts out. following command on fedora machine works fine, stream plays in vlc fine, , web page on vps displays video fine: ffmpeg -i [input] blah-de-blah 'rtmp://vps-server' going fedora machine i'd record video mp4 file stream it. following command works fine produces black video image in web page. command runs fine on fedora machine, in vlc proper image on web page video black. audio no video. ffmpeg -i [input] blah-de-blah 'recording.mp4|[f=flv]rtmp://vps-server' does know why be? problem in video.js player or on vps somewhere. code on web page plays video: <video id="example_video_1" class="video-js vjs-default-skin" controls="controls" autoplay="autoplay" preload="auto" width="660" height="500" poster="video-poster.gif" data-setup="{}">...

c++ - create a BST of string . error -

inserting 1 node tree works fine, on inserting 2nd node onwards, program crashes. here code: #include <iostream> #include <cstring> using namespace std; struct node { char* key; node *left, *right; }; // utility function create new bst node node *newnode(const char* item) { node *temp =new node; strcpy(temp->key,item); temp->left = temp->right = null; return temp; } // utility function inorder traversal of bst void inorder(node *root) { if (root!= null) { inorder(root->left); cout<<root->key<<endl; inorder(root->right); } } /* utility function insert new node given key in bst */ node* insert(node* tnode,const char* key) { /* if tree empty, return new node */ if (tnode == null) return newnode(key); /* otherwise, recur down tree */ if (strcmp(key,tnode->key) < 0) tnode->left = insert(tnode->left, key); else if (strcmp(key,tnode...

php - $_POST not populated -

i'm having issues php rest api of app. i'm submitting parameters in correct url format: baseurl?param1=val1&param2=val2 however, parameters being filled $_get array instead. i've looked $_server array see if there wrong there, can't see obvious. $_server['content_type']="application/x-www-form-urlencoded" $_server['request_method']="post" i've checked php.ini post_max_size misconfig: post_max_size=32m i'm not able figure else cause parameters placed $_get if helps, i'm using xampp on windows. also, using "advanced rest client" chrome, i've noticed regardless of method, post parameters placed $_get if parameters in url, if move them rest client's payload field, show post parameters. you cannot parameters via $_post submitted in query-string. can them via $_get array. but if move them rest client's payload field, show post parameters. , seeing trouble, can them $...

java - Error while passing to the constructor -

why getting red underline error when try pass arguments constructor, i.e. create object? doing wrong? public static void main(string[] args) { createshape temp = new createshape(3,3, 'a', {{'x','.','.'} {'.','.','x'} {'x','.','x'}}, "x . .\n" + ". . x\n" + "x . x"); temp.rotatecw(); system.out.println(temp); public createshape(int height, int width, char dc, char[][] charlayout, string layout) { this.height = height; this.width = width; this.dc = dc; this.shape = charlayout; this.layout = layout; initialpos = rotation.cw0; } im doint somthing wrong writing arguments char[][] . i'm assuming method rotatecw , fields declared in class. when defining 2-d array, array read ...

mvvm - Binding Model to ViewModel (WPF) -

i'm making move mvp mvvm, , little confused how best bind viewmodel model . understand how can leverage wpf's data binding infrastructure route events between view , viewmodel using icommand , inotifypropertychanged interface, e.g., view : public class myview { public myview() { initializecomponent(); datacontext = new myviewmodel(); } } and viewmodel : public class myviewmodel : inotifypropertychanged { public myviewmodel(){} public event propertychangedeventhandler propertychanged; protected virtual void onpropertychanged([callermembername] string propertyname = null) { var handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); } public icommand mycommand ... } this works great! now, typically mvp i'd have presenter hold reference model via constructor injection, , raise events on model presenter update data in model . tried sa...

ruby on rails 4 - NoMethodError (undefined method `[]' for nil:NilClass) Post Attachments issue -

i getting error , not sure why. post still saved database, though throws , error. has post_attachments, not sure how fix it. appreciated! here postcontroller create method error: def create @trail = trail.find(params[:trail_id]) @post = current_user.posts.build(params.require(:post).permit(:body, post_attachments_attributes: [:id, :post_id, :gallery])) @post.trail = @trail @new_post = post.new authorize @post if @post.save params[:post_attachments]['gallery'].each |a| @post_attachment = @post.post_attachments.create!(:gallery => a, :post_id => @post.id) end flash[:notice] = "post saved!" redirect_to @post.trail else flash[:error] = "error creating post. please try again." render :new end end the error occurs on line params[:post_attachments]['gallery'].each |a|

android - Uploading an image from phone storage -

i trying make user upload image file his/her phone gallery app. have managed invoke gallery user selects image. following error: java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=1, result=-1, data=intent { dat=content://media/external/images/media/7963 (has extras) }} activity {com.progrmor.tombstone.android/com.progrmor.tombstone.android.androidlauncher}: java.lang.securityexception: permission denial: reading com.android.providers.media.mediaprovider uri content://media/external/images/media/7963 pid=16802, uid=10409 requires android.permission.read_external_storage, or granturipermission() @ android.app.activitythread.deliverresults(activitythread.java:4060) @ android.app.activitythread.handlesendresult(activitythread.java:4103) @ android.app.activitythread.access$1400(activitythread.java:177) @ android.app.activitythread$h.handlemessage(activitythread.java:1497) @ android.os.handler.dispatchmessage(hand...

python - Objects with the same var values seems to be the one object for index() method in List -

so have model card. in project create carddata wrapper of model: card = card.objects.get(id=someid) carddata = {} carddata.id = card.id carddata.title = card.title than put on 30 carddatas in deck list: deck = [carddata1, carddata2 ..., carddata17] finally somewhere in game have link example on cardcata17. contains in deck list. @ same time there carddata2 whith same params becouse created same model. , when try index of carddata17: index = deck.index(carddata17) it return index = 2, , not 17 because carddata 2 has same id , title. rather strange , spend lot of time understand problem. real or mistake in assumption. make objects of card data instead of dictionaries. objects identified memory location, unique, instead of content. class carddata(object): def __init__(self, id, title): self.id = id self.title = title card = card.objects.get(id=someid) carddata = carddata(card.id, card.title)

java - Adding data to mysql with servlet not working -

this database create table `animal` ( `name` varchar(128) not null, `breed` varchar(128) not null, `age` varchar(128) not null ) register.html fill in data <html> <body> <form action="servlet/register" method="post"> name <input type="text" name="name"/><br/><br/> breed <input type="password" name="breed"/><br/><br/> age <input type="password" name="age"/><br/><br/> <br/><br/> <input type="submit" value="register"/> </form> </body> </html> my servlet package animals; import java.io.*; import java.sql.*; import javax.servlet.servletexception; import javax.servlet.http.*; public class register extends httpservlet { public void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcon...

javascript - svg and angularjs - a simple ngClick example -

i have simple problem (i hope). bind svg element , angularjs. here how problem looks like: <svg> <g ...> <text ... ng-click="count=count+1" ng-init="count=0">click me!</text></g></svg> outside <svg> have following code: count: {{count}} i clik on "click me!" , see how many clicks did make. not work. see no result, question why? nothing more example angularjs webpage: ngclick example angularjs . when use example without/outside <svg> (let button - in official angularjs webpage): <button ng-click="count = count + 1" ng-init="count=0"> click me! </button> the angularjs work. there restrictions regarding <svg> , angularjs? or perhaps have use trick use it? great in advance tip or help! nykon angular directives work fine inside of svg. see below code, using ng-click function: count: {{count}} <svg width="100" height="...

awt - Java- Toolkit.getLockingState not updating -

i trying make simple robot program needs know if scroll lock on. read different question , pointed toolkit.getlockingkeystate(). however, method correctly tells whether scoll lock on when started program, refuses update when scroll lock changed. here code: import java.awt.toolkit; import java.awt.event.keyevent; /** * @author luke senseney * */ public class mouse { /** * @param args */ public static void main(string[] args) { toolkit t=toolkit.getdefaulttoolkit(); while(true) { t.sync(); system.out.println(t.getlockingkeystate(keyevent.vk_num_lock)); try { thread.sleep(1000); }catch(interruptedexception e) { e.printstacktrace(); } } } } this version works advertised. expect difference code requests state within event dispatch thread (though cannot explain why case). import java.awt.*; import...