Posts

Showing posts from February, 2010

java - this is my whole code, what i want is , i want to return my return createPane(checkButtons,showItButton); -

package cuison_final_lab2; import java.awt.*; import java.awt.borderlayout; import java.awt.dimension; import java.awt.font; import java.awt.frame; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.componentadapter; import java.awt.event.componentevent; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.beans.propertychangeevent; import java.beans.propertychangelistener; import javax.swing.*; import javax.swing.borderfactory; import javax.swing.box; import javax.swing.boxlayout; import javax.swing.buttongroup; import javax.swing.imageicon; import javax.swing.jbutton; import javax.swing.jcheckbox; import javax.swing.jdialog; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.joptionpane; import javax.swing.jpanel; import javax.swing.jradiobutton; import javax.swing.jtabbedpane; import javax.swing.jtextfield; import javax.swing.border.border; public class c...

c# - How to make DataGridColumn ReadOnly but with CaretVisible? -

is there way have datagrid column in readonly mode caret visible? similar textbox when using isreadonlycaretvisible property? if set isreadonly property column gets disabled , not possible click on cell. <datagrid itemssource="{binding customers}" autogeneratecolumns="false"> <datagrid.columns> <datagridtextcolumn binding="{binding name}"></datagridtextcolumn> <datagridtextcolumn binding="{binding income}" isreadonly="true"></datagridtextcolumn> </datagrid.columns> </datagrid> you can create datagridtemplatecolumn textbox. refer below code. <datagridtemplatecolumn header="name"> <datagridtemplatecolumn.celltemplate> <datatemplate> <textbox text="{binding name}" isreadonly="true" isreadonlycaretvisible="true"/...

node.js - npm throws error without sudo -

i installed node , npm through package on nodejs.org , whenever try search or install npm throws following error, unless sudo command. have feeling permissions issue? admin. npm err! error: eacces, open '/users/chietala/.npm/-/all/.cache.json' npm err! { [error: eacces, open '/users/chietala/.npm/-/all/.cache.json'] npm err! errno: 3, npm err! code: 'eacces', npm err! path: '/users/chietala/.npm/-/all/.cache.json' } npm err! npm err! please try running command again root/administrator. npm err! system darwin 12.2.0 npm err! command "node" "/usr/local/bin/npm" "search" "bower" npm err! cwd /users/chietala npm err! node -v v0.10.4 npm err! npm -v 1.2.18 npm err! path /users/chietala/.npm/-/all/.cache.json npm err! code eacces npm err! errno 3 npm err! stack error: eacces, open '/users/chietala/.npm/-/all/.cache.json' npm err! npm err! additional logging details can found in: npm err! /us...

qt - point in rectangle test dilemma -

if check qt's docs on point-in-rectangle test say: bool qrectf::contains(const qpointf & point) const returns true if given point inside or on edge of rectangle; otherwise returns false. this inevitably means point may belong 4 rectangles, bordering each other, @ once. there exist argument in favor of arrangement, or better rectangle contain points on edges (say, top-left)? documentation says "edges" , not "corners". edge means line, while corner or vertex means point. if want exclude edges, qrect version of contains() can that. you can write own contains() , check whether point in top left corner using qrectf::topleft() . rectangles may intersect, point can contained in number of rectangles @ same time.

javascript - Sticky Header Logo Hover -

i found website today http://www.mcdonalds.de/ . know how make sticky header this? logo scroll down navigation hide , logo hover show navigation. if on can can me out coding or resource helps me create same. reply of great me. this ridiculous implementation think might idea. $(window).scroll(function() { var $container = $(".container"); var container_offset = $container.offset().top - $(window).scrolltop(); console.log(container_offset); if(container_offset){ $container.addclass('fixed'); }else{ $container.removeclass('fixed'); } }); @import url(http://fonts.googleapis.com/css?family=open+sans); body { font-family: 'open sans', sans-serif; font-size: 16px; background-color: #bdc3c7; padding:0; margin:0; } .header { background-color: #3498db; float: left; width: 100%; height: 70px; transition: width .3s; } .container.fixed .header { width: 100px; max-wi...

Javascript image width and height undefined values -

i try width , heigh previewframe , set values 100% both when try alert undefined values. here html file: <html> <head> <link rel="stylesheet" href="frame.css"> </head> <body> <div id="previewwrapper"> <div id="previewframe"> <img id="previewimage" src="http://i.forbesimg.com/media/lists/companies/google_416x416.jpg"> </img> </div> </div> <script src="frame.js"></script> </body> and here css: html, body{ margin:0; background:#ccc; } #previewwrapper{ margin:44px 0px; width:100%; height:calc(100% - 88px); } #previewframe{ width:100%; height:100%; margin-top:44px; background:#000; } #previewframe img{ max-width:100%; max-height:100%; } and js: function imageinfo() { var pframe = document.getelementbyid("previewframe"); ...

Integer error C -

this question has answer here: how check if input numeric in c++ 7 answers this have now: int main() { int number; printf("type number: "); scanf("%i",&number); char code[4]; printf("type code: "); scanf("%s",&code); when type numbers in first 1 script goes crazy, shows type number: notanumber type code: therestofthescript -- command line what want is type number: notanumber you didn't enter number -- command line how can this? this different said duplicate. i'm talking c here, not c++. c doesn't know cin , answer said duplicate. however, answer found below for input string use scanf("%s",code); or better scanf("%3s",code); to check correct input number use value returned scanf: char ch; if( 1 == scanf("%i",...

java - check the compatibility of an XML document against a DTD using JDOM? -

i working java , want check if xml file valid against dtd. assuming have dtd file, want check if xml file valid against same definitions proposed in dtd file. is there way using jdom? yes, can, in jdom. it's easiest in jdom 2.x (as opposed 1.x). see the saxbuilder constructor takes xmlreaderjdomfactory. example usage is: saxbuilder sb = new saxbuilder(xmlreaders.dtdvalidating); document doc = sb.build("http://www.w3schools.com/dtd/note_ex_dtd.xml"); xmloutputter xout = new xmloutputter(format.getprettyformat()); xout.output(doc, system.out); note above code validated xml against dtd specified in doctype declaration ("note.dtd") @ location relative note-ex_dtd.xml document.

qt - Change color of purple tab text in Konsole CSS -

when input comes in on tab not active, text tab changes purple color. css selectors need use change this? i using custom stylesheet in konsole change how tabs look, can't figure out how change 1 value. this page makes no mention of it. i'm using konsole 2.13.2(kde 4.13.3) on xubuntu 14.04(xfce). as of today, tab-activity color appears set by void tabbedviewcontainer::settabactivity(int index , bool activity) { const qpalette& palette = _tabbar->palette(); kcolorscheme colorscheme(palette.currentcolorgroup()); const qcolor colorschemeactive = colorscheme.foreground(kcolorscheme::activetext).color(); const qcolor normalcolor = palette.text().color(); const qcolor activitycolor = kcolorutils::mix(normalcolor, colorschemeactive); qcolor color = activity ? activitycolor : qcolor(); if (color != _tabbar->tabtextcolor(index)) _tabbar->settabtextcolor(index, color); } in konsole's src/viewcontainer.cpp , the...

jquery - How to assign enter key the same function as click? -

this question has answer here: jquery - keydown / keypress /keyup enterkey detection? 3 answers i'm trying have enter key perform same task when user clicks button (see jquery). however, when tried "keyup" , other event handlers, couldn't working correctly. ideas on simpliest way this? thanks patience, , help. see fiddle: https://jsfiddle.net/lightyearsaway/qg8f3q37/3/ html <h3>needs</h3> <input type="text" id="need-input" placeholder="enter text"> <button id="btn1">need it!</button> <ul id="need-list"> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> </ul> js $(document).ready(function(){ // click button, add list $("#btn1").click(function(){ ...

html - How to find the first <body .....> tag in a text using PHP? -

i not when using preg_match function but trying use find first body tag. the tag in of following formats <body class="blah"> <body style="blah: blahblah;"> <body> i able use preg_match() first , second example. but, not working on last example. simple <body> not found. here have done. $message string trying parse $foundbody = preg_match('/<body(.*)>/i',$message, $bodyf); if($foundbody != false){ $strpos = strpos($message, $bodyf[0]); echo $strpos .'<br><br>'; echo $bodyf[0] . '<br><br>'; echo strlen($bodyf[0]) . '<br><br>'; if($strpos !== false){ $message = substr($message, $strpos + strlen($bodyf[0]) ); } } note: not prying parse html code. trying go here parse email. want return text begins after <body....> tag end of str...

http - concept for c# web server for browser game client -

as student, have recieved task of making connect 4 game. task code simple c# web server listens http requests 2 players can play against eachother, 1 in c#c form, 1 in website. but i'm confused on how such thing work. have web client design of game , it's behaviour , data out of c# code. c# server should use httplistener, httplistenerrequest , httplistenercontext classes. i'm unsure on how such thing. appreciated on how start task, i'm unclear see accomplish it. greetings, durneztj you need 6 projects 1: winforms - connect 4 client 2: web application - connect 4 client 3: winforms - connect 4 server (for points make windows service or web api project) 4: class library - connect 4 game logic , models 5: test project 4 6: class lib - client code connecting 3 do class lib first. put models , game logic in here expose single class methods starting game, making move , working out if won. make interface class. write tests in test project mak...

ios - How to restructure array of objects -

this question has answer here: how restructure object of nsdictionaries 2 answers i'm querying object of type nsarray called messages backend on parse.com looks this: self.messages = ( "<lean: 0x7fcf98665140, objectid: vgle1uj5ki, localid: (null)> {\n messagebody = jj;\n recipientid = xvvxetqjph;\n senderid = xvvxetqjph;\n timestamp = \"1424991590106.210938\";\n}", "<lean: 0x7fcf98667940, objectid: rgbfybmklu, localid: (null)> {\n messagebody = \"test 3 ian\";\n recipientid = xvvxetqjph;\n senderid = hoy7ujlzoh;\n timestamp = \"1424631667110.638184\";\n}", "<lean: 0x7fcf98667f30, objectid: hb5uhwsysu, localid: (null)> {\n messagebody = \"test 2 user1\";\n recipientid = xvvxetqjph;\n senderid = vqzxwbdnal;\n timestamp = \"1424630904935.162...

Sorting Array Perl (part two) -

right, i've gotten need more, have pretty understanding on how sort array alphabetically. need sort numerically. it's syntax error near " my @test = (sort {items{$a}} <=> {items{$b}} @menu)" had been hash 2 keys have solution, since array contains 3 categories becomes difficult me. looking along explanation possible i'm eager learn. thank you! my @test = (sort {price{$a} <=> {price{$b}} @menu) the issue item{$a} . looks trying value hash item not hash, of course. my @test = sort { $a->{price} <=> $b->{price} } @menu; you can sort according more 1 field well my @test = sort { $a->{price} <=> $b->{price} or $a->{color} cmp $b->{color} or $b->{items} cmp $a->{items} # note reverse order } @menu;

php - overwrititng the login admin page sonatauser -

i want change page admin login in sonatauser wich in sonataproject/userbundle/admin/resources/views/admin/security/login.html.twig can't find solution because file extends base templete. can give solution such problem. {% extends base_template %} {% block content %} <div class="connection"> <form action="{{ path("sonata_user_admin_security_check") }}" method="post"> {% if error %} <div class="alert alert-error">{{ error|trans({}, 'sonatauserbundle') }}</div> {% endif %} <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" /> <div class="control-group"> <label for="username">{{ 'security.login.username'|trans({}, 'fosuserbundle') }}</label> <div class="controls"> ...

jquery - Play specific html5 audio file if element is visible on screen -

i have set of animated elements move across div. example here <div class="static-parent"> <div class="animated-child animated-one"></div> <div class="animated-child animated-two"></div> </div> .static-parent{ height:10em; width:20em; background-color:red; position:relative; overflow:hidden; } .animated-child{ height:5em; width:5em; position:absolute; } .animated-one{ -webkit-animation: 5s moving linear infinite; background-color:green; } @-webkit-keyframes moving{ 0% { left:-5em; } 100% { left: -webkit-calc(100% + 5em); } } .animated-two{ -webkit-animation: 5s moving-two linear infinite; -webkit-animation-delay:2s; background-color:blue; left:-5em; } @-webkit-keyframes moving-two{ 0% { left:-5em; } 100% { left: -webkit-calc(100% + 5em); } } when each of these elements enter...

javascript - Different bootstrap CSS files? -

i downloaded web template based on bootstrap version 3. inside template found css files named bootstrap-cerulean.css, bootstrap-journal.css, bootstrap-classis.css . although, can not find file named bootstrap.css . bootstrap-cerulean.css, bootstrap-journal & bootstrap-classis define or do? themes bootstrap? still need reference bootstrap.css if reference 1 of themes such bootstrap-cerulean.css ? all bootstrap.css styles modified , integrated 3 mentioned custom css files got template no, don't need link default bootstrap.css anymore unless you're planning override elements on page default style (which recommend using new css file few changes kept there overriding template's style rather linking whole bootstrap.css template.

java add image to canvas -

i'm trying add image java canvas. i'm using "imageio.read" image source. problem i'm facing don't know how display on canvas after reading image location. later need load different image(e.g. after button pressed) how can this. update (canvas.update) method needs "graphics" parameter instead of image. below you'll find code simplified (i left out code that's not relevant canvas issue.) public class mainwindow { public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { window = new mainwindow(); window.frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } /** * create application. */ public mainwindow() { initialize(); } /** * initialize contents of frame. */ ...

ruby - Store Global Variables for different environments in Rails -

in rails application try test calls redis. example in user model have: def self.add_to_visibles user #to show in menu $redis.lpush("user_visibles", user.to_json(only: [:vorname, :nachname, :id, :created_at])) end now when run test, test data inserted redis store "user_visibles" . means when on development see data. thats why change method to: def self.add_to_visibles user #to show in menu $redis.lpush($user_visibles, user.to_json(only: [:vorname, :nachname, :id, :created_at])) end and store in $user_visibles : for test: $user_visibles = "user_visibles_test" and production $user_visibles = "user_visibles" where best store variable? , how different environments? i'd this: config/user_variables.rb rails.configuration.user_variable = yaml::load_file("#{rails.root}/config/user_variables.yml")[rails.env] and create config/user_variables.yml this production: 'user_visibles' test: 'u...

java - JSP output plain text in Web Browser -

i using eclipse, spring mvc, maven , tomcat. index.jsp displays show below in web browser. not rendering properly. any idea wrong? index.jsp <%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body> <h1>index</h1> </body> </html> @controller public class hellocontroller { @requestmapping("/greeting") public string sayhello() { system.out.println("greeting"); return "hello"; } @requestmapping("/") public string index() { system.out.println("index page"); ...

Ruby x,y = gets.split.map &:to_i -

i confused line of ruby code. why assignment given x, y , not single variable? x,y = gets.split.map &:to_i this assigns first entry array x , , second entry y in contrast assigning single variable in case array assigned variable. putting multiple variables on left hand side of assignment way of unpacking array separate variables. can try in irb: irb(main):001:0> numbers = [1, 2, 3] => [1, 2, 3] irb(main):002:0> first, second = numbers => [1, 2, 3] irb(main):003:0> first => 1 irb(main):004:0> second => 2 check out this answer older question wrote gives more details , example of can useful.

android - Loopback + AndroidSDK: Retrieving Date fields -

i have working loopback api running backend android app. i'm using mysql save data. tables have @ least 1 datetime field. of course, need retrieve them. using api explorer correctly these datetime fields: { "id": 1, ... "dtdateadded": "2014-06-10t16:42:36.000z", "dtlastmodified": "2014-10-01t00:00:00.000z" } so date fields correctly retrieved db. but when retrieve data android app, date fields null. this model definition: public class mymodel extends model { private int id; private date dtlastmodified; public int getid() { return id; } public void setid(int id) { this.id = id; } public date getdtlastmodified() { return dtlastmodified; } public void setdtlastmodified(date dtlastmodified) { this.dtlastmodified = dtlastmodified; } } the code retrieve data: repository.findall(new listcallback<mymode...

angularjs - ng-if Function Gets Called on Click -

Image
i have code on plnkr: http://plnkr.co/edit/6wz4zub2seofhrqps0c8 the html code quite simple: <div ng-app="myapp" ng-controller="mainctrl"> <div ng-dropdown-multiselect="" options="mydata" selected-model="mymodel" extra-settings="mysettings" events="myevents"></div> <div ng-repeat="item in items"> <item-input></item-input> </div> </div> </div> basically, problem function in ng-if gets called every time click anywhere on page. think has multi-select control i'm not sure should fix it. appreciated. thanks. updated what don't understand why behavior stops when comment out multi-select dropdown ( <div ng-dropdown-multiselect="" options="mydata" selected-model="mymodel" extra-settings="mysettings" events="myevents"></div> )? ...

php - FPDF MakeFont does not generate any file -

i add font local signs fpdf doesn't work. acording tutorial have written: require('../makefont/makefont.php'); makefont('c:\\windows\\fonts\\verdana.ttf','cp1252', true); it produces message: font file compressed: verdana.z font definition file generated: verdana.php in fpdf tut read "then copy generated files font directory." have not files on disc. wrong it? they? thanks help. from memory, haven't used fpdf font generator long time, believe need copy ttf font file out of c:\windows\fonts. i think has permissions on c:\windows\fonts, , generated fonts should on folder running php script, if running fontgenerator.php say: c:\www\font_generator.php, fonts definitions files should on c:\www\verdana.z

Android Menu: How to dynamically change menu with condition in code -

i'm trying change item in optionmenu, depending on if selected name (from spinner) in activity, tried use invalidateoptionsmenu() inside spinner.setonitemselectedlistener , in onprepareoptionsmenu set condition, error: "java.lang.classcastexception: com.android.internal.view.menu.actionmenuitemview cannot cast android.view.menuitem" my code: public class mainactivity extends activity { private long projectid; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); datasource = new statementdatasource(this); datasource.open(); setcontentview(r.layout.activity_main); //setting spinner simplecursoradapter ... public void onitemselected(adapterview<?> parent, view view, int position, long id){ projectid = id; //trigger optionsmenu recreate invalidateoptionsmenu(); } } @override public boolean onprepareoptionsmenu(menu menu) { ...

java - Display stars based on array values using showOptionDialog -

what best way display each value in array n times star in case (using showoptiondialog)? considering using loop, i'm not sure i'd fit in code. code far: int[] stars = {2,4,6}; string[] options = {"yes","no"} int choice = joptionpane.showoptiondialog(null, "stars1: " + stars[0]... + "\n stars2:" + stars[1]... + "\n stars3:" + stars[2]..., "stars", 0, 3, null, options, null); expected output: ** **** ****** hope makes sense, thanks! you can try this: int[] stars = {2,4,6}; string[] starsstr = new string[stars.length]; for(int = 0;i < stars.length;i++){ string temp = ""; for(int j = 0; j < stars[i];j++){ temp+="*"; } starsstr[i] = temp; } string[] options = {"yes","no"}; int choice = joptionpane.showoptiondialog(null, starsstr, "stars", 0, 3, null, options, n...

symfony - Can I implement my own Symfony2 annotations easily? -

is there in symfony annotations modules allow me use them other uses? know @route , @method need extend existing libraries, not easy im guessing. currently, im working history api, , love put popstate data javascript files in annotations, available when routing generates url, makes sense have html5 annotated title here doesn't it? it great put next existing route name , stuff. there has tweaked annotations before? edit im going clarify intentions here left out crucial details understanding motive, thought more clear. ok, use alot of ajax on symfony2 app. use fosjsrouter handle routing. instead of urls triggering routes , actions, spa have click events triggering run route using ajax, passing param data php methods directly way. so given this, have nice js object method runs ajax call, , passes json around , backend. inside method im focusing on being best place add historyapi functionality it, button. im thinking ajax method perfect place if history flag ca...

Windows batch script to determine last folder in list of paths -

i read list of paths file , determine each time last folder. have found something start with , failed, read various threads dealing nested loops , variable expansions without success. not "last folder:" response. seeing problem here? appreciated! external file (paths.txt): c:\firstfolder\nextfolder\lastfolder c:\somewhere\deeper\finallythere c:\temp windows batch script: @echo off setlocal enabledelayedexpansion /f "tokens=* eol=#" %%f in (%cd%\paths.txt) ( echo new path file: %%f set mydir=%%f set m=%mydir:\=;% call :get_symlink %%m ) setlocal disabledelayedexpansion goto :eof :get_symlink /f "tokens=* delims=;" %%i in (%1) call :last_folder %%i goto :eof :last_folder if "%1"=="" ( echo last folder: %last% goto :eof ) set last=%1 shift goto :last_folder i afraid not clear result want, if this: lastfolder finallythere temp ... batch file got it: @echo off /f %%a in (paths.txt) ech...

jquery - using jscript to create greyscale to colour effect on images -

i using following technique make images go greyscale colour on hover: http://solemone.de/code/code-examples/demos-grayscale-hover-effect-with-html5-canvas-and-jquery/ the issue i'm having when hover image goes original size instead of fitting in the sytle width has been set to. jscript code: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> <script> $(window).load(function() { $('.imglist img').each(function() { $(this).wrap('<div style="display:inline-block;width:' + this.width + 'px;height:' + this.height + 'px;">').clone().addclass('gotcolors').css('position', 'absolute').insertbefore(this); this.src = grayscale(this.src); }).animate({opacity: 1}, 500); }); $(document).ready(function() { $("#imglist1 a").hover( function() { $(this).fin...

python - re.search becomes unresponsive -

Image
when run code doesn't print neither 'checked' nor 'not matching' . stops responding completely. url='http://hoswifi.bblink.cn/v3/2-fd1cc0657845832e5e1248e6539a50fa/topic/55-13950.html?from=home' m=re.search(r'/\d-(b|(\w+){10,64})/index.html',url) if m: print('checked') else: print('not matching') suppose have following script: s = '1234567890' m = re.search(r'(\w+)*z', s) our string contains 10 digits, , not contain 'z' . intentional forces re.search check all possible combinations, otherwise stop on first match. i can't calculate number of possible combinations, since math involved rather tricky, here small demonstration on happens when s gets more digits: time goes 1μs single digit s 100 seconds 30 digit s , is, 10 8 more time. my guess similar happens when use (\w+){10,64} . instead should use \w{10,64} . code used demo: import timeit import matplotli...

broadcast - How to make my service run? -

i want start service when power connected device , show notification app doing nothing or not happenig, please me, new in android world, maybe miss something, mi code following: my manifest: <receiver android:name="com.tlm.grhs_client.wifimonitor"> <intent-filter> <action android:name="android.intent.action.action_power_connected"/> </intent-filter> </receiver> my broadcast reciever: public class wifimonitor extends broadcastreceiver { @override public void onreceive(context context, intent intent) { connectivitymanager cm = (connectivitymanager) context.getsystemservice(context.connectivity_service); networkinfo info = cm.getactivenetworkinfo(); if (info != null && info.gettype() == connectivitymanager.type_wifi) { if (info.isconnected()) { //iniciar servicio intent serviceintent = new intent(conte...

Excel VBA RegEx Using * (asterik) + End-Points to Match Entire String -

why following return " data " , not "_data_5252014_"? dim regex new regexp regex.global = true regex.pattern = "_data_*_" name = "ecmosso_data_12312013_results_tbl" msgbox regex.execute(name)(0).value i guess documentation indicates matches preceeds *, under impression regular expression yield "_data_12312013_" , not " data ". there way accomplish want? you're matching underscore, preceding — "zero or more" times. instead, use token .* ( any single character "except newline" ). greedy * operator shoot end of string, backtrack last underscore want use *? non-greedy match meaning "zero or more — preferably few possible". _data_.*?_ live demo

objective c - Notifications in Multiple Thread iOS -

i have found when want deliver notifications particular threads, there sample apple. https://developer.apple.com/library/mac/documentation/cocoa/conceptual/notifications/articles/threading.html#//apple_ref/doc/uid/20001289-cegjfdfg in article, apple suggests using machport monitor thread want process notification. - (void)processnotification:(nsnotification *)notification { if ([nsthread currentthread] != notificationthread) { // forward notification correct thread. [self.notificationlock lock]; [self.notifications addobject:notification]; [self.notificationlock unlock]; [self.notificationport sendbeforedate:[nsdate date] components:nil from:nil reserved:0]; } else { // process notification here; } } my question is: if notification , use dispatch_async process notification, has different appearance? dispatch_async(dispatch_get_main_queue(), ^{ // process n...

javascript - Properly centering div based on child element -

Image
this repost stackexchange's gamedev section, yet, find problem seems more applicable stackoverflow because pertains more css, js, , positioning techniques rather javascript topics (mostly unityscript , phaser) discussed on former. i've been making roguelike-style game in html5 without using canvas (only divs) pure js ( fiddle! ). i've been trying enlarge tile size (font size) while keeping player centered within camera. reason, when tile size isn't equal map size, camera off. note 3d effect on purpose; believe adds needed depth, , looks super cool. :d when tilescale (line 4 in fiddle) 9 (very undesirable; dots on player's y axis should aligned, not @ slight angle): when tilescale 25 (on point!): here's relevant (trimmed) code: window.onresize = function(){ game.viewportwidth = math.max(document.documentelement.clientwidth, window.innerwidth || 0); game.viewportheight = math.max(document.documentelement.clientheight, window.inn...

node.js - Getting type error with Sequelizejs -

im getting following error , can't figure out through stack trace it's erroring. /users/rahulsharma/desktop/jobletics/node_modules/sequelize/lib/sequelize.js:298 this.importcache[path] = definecall(this, datatypes) ^ typeerror: object not function @ module.exports.sequelize.import (/users/ra/desktop/js/node_modules/sequelize/lib/sequelize.js:298:32) @ db.sequelize (/users/ra/desktop/js/models/index.js:14:33) @ array.foreach (native) @ object.<anonymous> (/users/ra/desktop/js/models/index.js:13:4) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ module.require (module.js:364:17) @ require (module.js:380:17) here git: https://github.com/rahul1346/jb any idea? business_model.js empty file.

angularjs - angularfire & ui.sortable : passing ng-repeat value into sortableOptions -

i have basic ng-repeat task sortable <div ng-sortable="sortableoptions"> <div ng-repeat="task in todo"> {{task}} ... when task draged , droped, calls $scope.sortableoptions in controller. i'm wondering if knows how pass task object that? set function or.. basically, want pass task in , update 1 of properties inherent todo. $scope.sortableoptions2 = { stop: function(event, ui) { // specific todo here }); } thank u if using ng-sortable yeah can , <ul data-as-sortable="sortableoptions" data-ng-model="todo"> <li data-ng-repeat="item in todo" data-as-sortable-item> <div data-as-sortable-item-handle></div> </li> </ul> and in controller , $scope.sortableoptions = { accept: function (sourceitemhandlescope, destsortablescope) {return boolean}//override determine drag allowed or not. default true. itemmoved: function (event) {/...

Is there special way declaration class in VB.NET -

i newbie in vb.net. when read document on msdn ( https://msdn.microsoft.com/en-us/library/vstudio/bb534304%28v=vs.100%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 ) see following code (excerpt): dim pets new list(of pet)(new pet() _ {new pet {.name = "barley", .age = 8}, _ new pet {.name = "boots", .age = 4}, _ new pet {.name = "whiskers", .age = 1}, _ new pet {.name = "daisy", .age = 4}}) i don't see definition of class pet before. can explain me? this confusing, because vb.net re-uses tokens in case mean different things. i'll spread code on several lines , explain happens @ each point. dim pets new list(of pet) that creates list object hold pet objects. ( we calling constructor list(of pet) type. there several overloads list(of t) constructor, code here uses this one . new pet() ...

javascript - Hover over image effects -

i developing web site , , have problem , need write javascript code enable images once hovered become larger others , display additionally several lines of text regarding product on image. have looked on article https://css-tricks.com/a-really-nice-way-to-handle-popup-information/ not solving problem. can please advise? what want fancybox though works on click, not on hover you'll have add bit of code make work on hover have below note: while possible (as shown here) make work on hover, not recommended. put bunch of these on page , pretty annoying real quick! here simple example , or see snippet below $(document).ready(function() { $("a#inline").fancybox({ 'hideoncontentclick': true }); // add bit below make work on hover $(".hoverclick").hover(function(){ $(this).click(); }); }); <link rel="stylesheet" href="http://dodsoftware.com/sotests/fancy/jquery.fancybox-1.3.4.css...

c++ - why std::max_element over std::map within some lower_bound not working? -

i not sure why following snippet not working: lower_bound call return key 7, expected. std::max_element between begin() , lower_bound() iterator should return 6, should search between key 4 , key 7 , max value 6 key 7. it's returning last pair(15, 12) reason can't figure out. bool cmp(const std::pair<t, t>& p1, const std::pair<t, t>& p2) { return p1.second < p2.second; } int main() { std::map< t, t, std::greater<t> > store; std::map< t, t, std::greater<t> >::iterator found_max, lower; store[ 4 ] = 2; store[ 7 ] = 6; store[ 10 ] = 2; store[ 15 ] = 12; lower = store.lower_bound( 8 ); printf("%ld %ld\n", lower->first,lower->second); found_max = std::max_element(store.begin(), lower, cmp); printf("%ld %ld\n", found_max->first,found_max->second); return 0; } std::map< t, t, std::greater<t> > store; store has key sorte...

java - Else If Syntax Error in Calculator -

this question has answer here: how compare strings in java? 23 answers i've been trying make basic calculator, thing every time use if else , either says have remove due syntax error or green underline thing shows , says dead code. me? import java.util.scanner; public class additioncalculator { public static void main(string[] args) { int addresult; int subtractresult; int divideresult; int multiplyresult; string addition = null; string subtraction = null; string division = null; string multiplication = null; scanner reader = new scanner(system.in); system.out.println("do want subtraction, division, multiplication, or addition?"); string = reader.next(); if(i == addition) { scanner additioncalc = new scanner (system.in); system.out.println("enter number"); int add...

Python csv file determine data type -

new student here please excuse ignorance, have searched lot , not found solution problem. needing import csv file mixed data types [ int, float, , string], determine data type, maths on ints , floats. the problem csv reader converts strings ( or strings?). can try , convert float, , if throws error message know string, how tell if float, program needs determine between two? i allowed import csv , no others. second first-year python subject, , not sure how this. edit, found 1 answer seems similar problem, still returns wrong answers, ints usually, not always, still returned string type: import csv tests = [ # (type, test) (int, int), (float, float), ] def gettype(value): typ, test in tests: try: test(value) return typ except valueerror: print 'value error' continue # no match return str file = open('adult.csv') reader = csv.reader(file) filename = 'output.xml' ...

javascript - How to check if device is Windows Surface Tablet and browser is chrome or IE -

how check if device windows surface tablet , browser chrome or ie using javascript. have tried following code function is_touch_device() { try { document.createevent("touchevent"); return true; } catch (e) { return false; } } if(is_touch_device() ) { if(navigator.useragent.tolowercase().indexof('chrome')>-1) { //some stuff } } i have searched useragent not getting exact surface. how check if device surface , browser chrome or ie using navigator object can access these data fields navigator.appname <- gets app name may misleading appcodename navigator.appcodename; <-- alternate name navigator.platform; <-- platform user on http://www.w3schools.com/js/js_window_navigator.asp

JAVASCRIPT: Getting values inside an array -

i'm having problem in calling values entered in numberbox (i don't know should call it... if there's textbox, there should numberbox. lol). if enter "123456", value of sum should "21", happens value of sum "0123456". <input type="number" name="user" id="input" maxlength="6" size="6" required> <input type="button" onclick="calculate()" value="calculate"> <script type="text/javascript"> function calculate(){ var user = []; user=document.getelementbyid("input").value; if(user.length==6){ var sum=0; (i=0;i<user.length;i++){ sum=sum+user[i]; } var ave=sum/6; window.alert("sum is: "+sum); window.alert("average is: "+ave); ...

linux - Starting a service as userA from userB by using shell script -

is there way start service usera userb using shell script, usera , userb doesn't have root access. both users password protected. the usuasual approach make use of 'sudo': sudo -u userb service whatever start sudo available out of box on linux systems. can configure it, usera doesn't need enter password use above command.

Freemarker XPath expression to find a node with a child id -

i'm using freemarker xml processing build menu. want find if current element, or of it's children have id matching activenode. but i'm having lot of trouble working out freemarker syntax xpath. seems match nodes children links (note item node reference customers node) <#assign anode="search-customers" /> <#assign xpath>link["@id=${anode}"]</#assign> <#if item[xpath][0]?has_content> <#assign cssclass> class="active"</#assign> </#if> this relevant section of xml i'm trying match. example, search-customers node, should highlight customers node. <menu> <top title="title.home" url="/admin" icon="fa fa-home" /> <top title="title.customers" id="customers" url="javascript:;" icon="fa fa-group"> <link title="title.search.customers" id="search-customers" url=...

c++ - animating a model without redrawing the whole background drawing --OPENGL -

using opengl , making simple animation small triangle move through path have created mouse (glutmotionfunc). so problem how can animate small triangle without redrawing whole path using glutswapbuffers(); and ,how can rotate triangle only. i don't want use overlay switching between these 2 layers takes time. if redrawing whole path expensive, can rendering off-screen framebuffer. mechanism opengl called frame buffer object (fbo) explaining how use fbos in detail beyond scope of answer here, should able find tutorials. using functions like: glgenframebuffers() glbindframebuffer() glframebufferrenderbuffer() or glframebuffertexture() this way, can draw additional triangle fbo whenever new triangle added. show rendering on screen, can copy current content of fbo primary framebuffer using glblitframebuffer() .

java - Spring JMS Listener Container not stopping fully -

i have weird problem jms listener container. in case stop listener container, half of messages still delivered app , processed listener. here deployment descriptor: <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvc-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <context-param> <param-name>contextconfiglocation</param-name> <param-value>web-inf/jms-config.xml,web-inf/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> </web-app> here ...