Posts

Showing posts from August, 2012

angularjs - Unit test onEnter with ui-router -

i have state onenter block following. i'm trying redirect based on data.length . .state('home', { url: '/', data: { title: 'home', }, controller: 'homectrl home', templateprovider: function($templatecache) { return $templatecache.get('views/home.html'); }, onenter: function(data, $state) {); if (data.length === 2) { $state.go('profile'); } } }); how can unit-test piece of code?

javascript - Same code acts differently on website and jsfiddle -

i have code meant allow user scroll sideways clicking, works on jsfiddle, different on actual website. on website, can scroll right once no further, , when scroll back, apparently scrolls right past left-hand border. here's live link problem on website: rouvou.com/error and here's fiddle . i literally copied , pasted code. i'm using jquery 1.10.0 on website , closest jquery version jsfiddle has 1.10.1, can't imagine cause different behavior. html posted code on entire page. on both locations, i'm using chrome version 42.0.2311.152 (64-bit) on ubuntu. why might code have different results on jsfiddle , website? $(document).ready(function() { var $item = $('div.item'), //cache dom selector visible = 2, //set number of items visible index = 0, //starting index endindex = ($item.length / visible) - 1; //end index $('div#arrowr').click(funct

Wordpress+require.js jQuery(...).isotope is not a function -

i'm using require.js within wordpress, , i've accomplished load vendor , custom scripts page, except 1 file... if try load 'isotope.pkgd.min' through require js console shows error: jquery(...).isotope not function the error comes file i'm loading in require.js, called 'jquery.theme', executes code: jquery('.portfolio-isotope').isotope( 'layout' ); jquery('.ajax-isotope').isotope( 'layout' ); first of thought problem jquery duplicity(because plugins use own jquery version instead of wp default version), solved it, using in require.js config jquery default in wp, code: if (typeof jquery === 'function') { define('jquery', function () { return jquery; }); } but that, didn't solve anything. i've seen if leave wp isotope default call, , load 1 require.js,the default 1 inside body tag, , require 1 inside head. maybe putting require.js 1 inside body tag solve problem? no idea on how that.

sql - Non-transactional trigger -

as far know, if try perform writing operation table having trigger on operation , trigger fail write operation fail either. looks both operation being performing in same transaction. possible following: if trigger fail due reason (throwing exception or else): write log entry , allow write operation completed succfully if can. why don't split 2 procedures , write separate procedure? suggestion given info have posted, if want more need more info (db vendor , version, , post code)

How to group a list by name with a newline after each group in shell? -

i have list group name. should done newline after each group. here example file: $ cat file 2015-07-09 07:03:46 7.5 gib apple-foo.txt.gpg 2015-07-22 11:36:36 6.9 gib apple-bar.txt.gpg 2015-07-27 04:40:34 31.0 gib banana-here.txt.gpg 2015-07-07 20:28:17 30.6 gib banana-even.txt.gpg 2015-07-19 15:02:20 30.8 gib banana-more.txt.gpg 2015-07-26 00:05:11 1.9 gib coconut-something.txt.gpg 2015-07-23 03:34:41 2.1 gib coconut-else.txt.gpg 2015-07-24 03:34:40 12.1 gib date-yougetit.txt.gpg and output trying get: 2015-07-09 07:03:46 7.5 gib apple-foo.txt.gpg 2015-07-22 11:36:36 6.9 gib apple-bar.txt.gpg 2015-07-27 04:40:34 31.0 gib banana-here.txt.gpg 2015-07-07 20:28:17 30.6 gib banana-even.txt.gpg 2015-07-19 15:02:20 30.8 gib banana-more.txt.gpg 2015-07-26 00:05:11 1.9 gib coconut-something.txt.gpg 2015-07-23 03:34:41 2.1 gib coconut-else.txt.gpg 2015-07-24 03:34:40 12.1 gib date-yougetit.txt.gpg i manage extract unique names (apple, banana

shell - Bash script does not output any data in tempfile -

this code use, want collect data 4 logfile(s) in 1 file, sort , print temp filename. #!/bin/bash tempfile=$(mktemp) user=$1 # check input #if [ -z $1 ]; echo "give me 1 username or mail address please..." # fill file user history cat /var/log/messages | grep $user >> $tempfile cat /var/log/maillog | grep $user >> $tempfile zcat /var/log/messages*gz | grep $user >> $tempfile zcat /var/log/maillog*gz | grep $user >> $tempfile # sort date cat $tempfile | sort -k1m -k2n -k3n > $tempfile echo $tempfile cat , zcat everywhere useless , cannot redirect same file you're reading, 0 byte file. try this: #!/bin/bash tempfile=$(mktemp) user="$1" # check input #if [ -z $1 ]; echo "give me 1 username or mail address please..." # fill file user history grep "$user" /var/log/messages >> $tempfile grep "$user" /var/log/maillog >> $tempfile zgrep "$user" /var/log/messages*gz

c# - ASP.NET MVC4 Entity Framework db.SaveChanges() Condition not working -

i working on project in asp.net mvc4 entity framework. here problem, code send different json object depending on if db.savechanges worked or not ! ive been doing debug console , seems false else part of if , never goes in actual condition if condition ok. hard explain easy understand code here goes. code controller sending true or false json object javascript [httppost] public actionresult enregistrer_inscription(inscriptionpost inscpost) { noiretorentities db = new noiretorentities(); inscription insc = new inscription() { inscriptionnom = inscpost.nomj, inscriptionprenom = inscpost.prenomj, inscriptiondatenaissance = inscpost.datenaissance, inscriptiondate = datetime.now, inscriptioncategory = inscpost.category, inscriptiondivision = inscpost.division, inscriptionstatut = inscpost.statut, inscription

php - "End of script output before headers" on CentOS, but working on other LAMP stacks -

i've set centos 6 + cpanel 11 vps, , out of box. i've installed phorum 5.2.20 in public_html directory, phorum causing error 500. error log reports: [mon jul 27 11:21:57.770447 2015] [core:error] [pid 14342] [client x.x.x.x:42531] end of script output before headers: admin.php the code works fine on debian lamp server (and several other non-centos/cpanel lamp stacks i've used test this), , wordpress , other stuff runs fine on centos machine. i've tried other code too, , works on other servers, doesn't work on centos. phorum code matters, made question focuses on that. i'm reluctant edit core files of phorum. any ideas? i think there issues php handler. can please try change php handler through whm >>service configuration >> configure php , suexec , check url again.

python - How to verify whether a certain word is present in the loaded page through WebDriver? -

how can verify if user sees on screen word, instance “book” or “book” ( on webpage https://www.amazon.com/gp/gw/ajax/s.html?ie=utf8&ref_=nav_logo ? script should check user sees including images (“title” , “alt”). script should return true or false. how can check whole page using assert true, assert false ? has written in python ? get complete text of page . webdriver driver = new firefoxdriver(); string bodytext = driver.findelement(by.tagname("body")).gettext(); //if word check "book" boolean iswordpresent = bodytext.contains("book"); maintain list of words wish verify on page , loop through list.

WPF MVVM using LINQ to SQL -

i have binded customer name textbox customer model , set mode 2 way want update edited name database. how can achieve ? your question vague doesn't whether wanted on propertychanged or when have button either click event handling or icommand binding on it. the decision when update totally down business model applying. speaking, it's never idea update directly propertychanged event because might temporary edit , may wish update against. for example, if have updatesourcetrigger=propertychanged, character type, property updated new value , if implmented inotifypropertychanged events, instantly fire update database. because database connection transient, on network, may or may not available, , may or may not timeout during partial update. thus, end locking code or if multi-threading, causing race conditions. therefore, it's better implement changes via save button or when screen closed/navigated away (such ios/android do).

c# - Failed to access embedded resources -

Image
i failed access embedded resources. i'm using document reference https://msdn.microsoft.com/en-us/library/vstudio/aa970069(v=vs.100).aspx the code res = new uri($"pack://application:,,,/{assembly.getexecutingassembly().getname().name};component/language_default"); gives system.io.ioexception: can't find "language_default" resource , exists in resources:

osx - Enable command shortcuts for Intellij for mac -

Image
i using intellij on mac. when installing it, asked whether wanted use traditional shortcuts, based around control modifier key, or use command key. chose latter when when tried using it, doesn't seem work. instead, control shortcuts can used. can't find way change in settings; online documentations i've consulted point area in settings called keymap can't seem find. searching using intellij search function, under help, doesn't yield returns. how enable command shortcuts? keymap in preferences, can found in intellij idea menu.

sql - TSQL- How to count number of instances -

Image
i'm using sql server 2014 , need know set of students have action code used once, , students have action code used more once. i'm trying see if student has more 1 of 5 action codes. e.g. select studentid #t actioncode in (51201,51206,51207,51208,51209) how code please? thank help. select studentid, actioncode, actioncodecount = count(*) dbo.studentactioncodes actioncode in (51201, 51206, 51207, 51208, 51209) group studentid, actioncode order studentid desc, actioncode ; see working in live demo @ sqlfiddle given set of values (including unwanted actioncodes): studentid actioncode ----------- ----------- 987654 51201 987654 51206 987654 51207 987654 51208 987654 51209 987654 51210 987653 51201 987653 51208 987653 51208 987653 51211 987652 51201 987652 51206 987652 51206 987652 51207 987652 51208 987652 51209 987652 51212 987652

javascript - AngularJS ngClick to fire a service but doesn't -

i have following inside directive scope.actions = { getsearch: searchresultpageservice.getsearch(scope.keywords, scope.settings) }; the template follows <button class="btn btn-primary" type="button" data-ng-click="actions.getsearch()">send</button> in service i'm checking see if scope.keywords , scope.settings passed through using console.log there no output. what doing wrong ngclick usage (function () { 'use strict'; angular .module('app.search') .factory('searchresultpageservice', [ '$timeout', function ($timeout) { var $module = { getsearch: function(keywords, settings){ console.log(keywords); console.log(settings); scope.actions.getsearch result returned calling searchresultpageservice.getsearch , rather function itself. you either need pa

computer vision - Create OpenGL matrices from affine camera matrix -

i have set of 2d 3d point correspondences, , estimate affine camera matrix these correspondences (basically, assuming orthographic projection)[1]. output of camera estimation 3x4 matrix third row [0, 0, 0, 1] (the "affine constraint"). now camera matrix, i'd render model using opengl. in essence, create modelview , (orthographic) projection matrix camera matrix have. i've read hours of material on camera matrix dissection/decomposition, of perspective cameras, , "z" information missing in matrix, not apply these techniques. i've tried numerous attempts, of failed @ stage. 1 thing tried taking dot product of first , second row of matrix (without last column of course) create new row transforms z , it's [0, 0, 1] , of course makes sense. thing tried converting 2d points clip coordinate space (i.e. "reversing" window transform) before estimating camera matrix, can take window transform , flipping y (in screen space, origin on up

freepascal - Is there a delphi ScrollInView equivalent in Free Pascal? -

i have scrollbox , i'm adding controls @ runtime. however, when controls exceed scrollbox height, want scrollbox scroll way bottom newly added controls visible. doing research, i've found called "scrollinview" delphi. seeing how many (quite lot) of delphi methods/functions available in free pascal, know of equivalent particular one? if not, can me achieve goal (auto-scrolling scrollbox bottom) different solution? thanks in advance, oscar something this? procedure tform1.button1click(sender: tobject); begin tedit.create(self) begin parent := scrollbox1; left := 10; top := scrollbox1.controlcount * 40; scrollbox1.vertscrollbar.position := top; end; end; and here hte simple implementation of scrollinview method: tscrollboxhelper = class helper tscrollbox procedure scrollinview(acontrol: tcontrol); end; implementation procedure tscrollboxhelper.scrollinview(acontrol: tcontrol); begin if acontr

swift - UIPanGestureRecognizer not working if the the UIImageView is Scaled too much in iOS -

i have uiimageview , in different gestures uipangesturerecognizer,uipinchgesturerecognizer,uirotationgesturerecognizer etc added. normally works fine, when view scaled cgaffinetransformscale , uiimageview stops responding pan gesture after limit. still pinch , rotation work on. if uiimageview in scaled backed smaller, uipangesture starts working again. please if 1 has noticed such behaviour in ios.

javascript - add multiple custom attributes to datatables row -

i have table created in datatables 1.10: var table = $('#table').datatable( { "data" : dataset, "binfo": false, "bfilter" : false, paging: false, "createdrow" : function (row,data,index) { $('td',row).eq(0).attr('id', 'cost-' + index); $('td',row).eq(1).attr('id', 'resale-' + index); deleteimage = $('<img />').attr('src', '../../img/details_close.png'); $('td',row).eq(0).append(deleteimage); $('td',row).eq(0).addclass( 'icons' ); }, "columns" : [ { title : 'cost' }, { title : 'resale' }, ], "columndefs": [ { classname: "details-control", "targets": [ 0 ] } ] }); this works fine. trying add image first <

d3.js - Can't fill circle background with color threshold -

i try display circles on map particular dataset. dataset provides center circle. dataset contains identifier (attribute name ), year (attribute year ) , value (attribute value ) i display 2 things @ level: the radius of circle according value the background color (fill) of circle according year , using threshold a tooltip when circle clicked. here code use: var circle = d3.geo.circle(); var color = d3.scale.threshold() .domain([ 1800, 1850, 1900, 1950, 2000, 2050 ]) .range("#f2f0f7", "#dadaeb", "#bcbddc", "#9e9ac8", "#756bb1", "#54278f"); var elements = layerelement.selectall('circle') .data(data) .enter() .append('path') .attr('id', function(d) { return d.name; }); elements .datum(function(d) { return circle .origin(origin({d: d})) .angle(radius({d: d}))(); }) .attr('class', 'point

cocos2d x - AppWarp multiplayer with one host -

i had question using appwarp hoping me with. possible have 1 host of game both users in appwarp room can view , send messages in realtime? rather having each user have own hosted game while sending messages each other , altering gameplay through sent , received messages. reason ask because there random factors in game , if add in latency sending messages, both users don't see same gameplay... hope makes sense. if can't done through appwarp can recommend alternatives? appreciate it. if understood requirement correctly want make game 2 or more clients should communicate each other using appwarp server. if case appwarp does. appwarp server side product clients can connect communicate each other. appwarp has 2 flavours called appwarp cloud , appwarps2 explained in blog . you can go ahead , check out tutorials , samples of appwarp , if face problem can write on forum sorted quickly.

c# - Set edit mode as default behavior when adding a new item in a tree -

i have treeview can simple operations expand, add new item, edit, delete, copy , paste, rename, etc. what want that, when click "add item", creates , shows in edit mode, can set new name it. right now, assign generic name "new item x". i hope there easy solution i'm missing here. im working wpf way (i don't think it's necessary put code samples here, if i'm wrong, , i'll edit post). got it! i used refresh() function called every second, refreshing tree. handles addcommand, when try add new item, receives request, set editname property true , that's it! obs: couldn't see other way, couldn't set focus new created item.

Not able to run "find" query in remote mongodb collection using MongoClient in Node.js application -

var express = require("express"); var bodyparser = require('body-parser'); var path = require("path"); var objectid = require('mongodb').objectid; var mongoclient = require('mongodb').mongoclient, format = require('util').format; var uri = 'mongodb://ac-00072810.devapollogrp.edu:27017/devdb'; mongoclient.connect(uri,function(err,db){ db.collection('transactionstatus',function(err,collection){ if(err){ throw err; } else{ collection.find({}).foreach(function(err,doc){ console.log(doc); }); } }); }); getting error: [apol@ac-00067394 nodejs-testapp]$ node server.js body-parser deprecated bodyparser: use individual json/urlencoded middlewares server.js:15:9 body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29 running @ port 3001 undefined (note: mongodb versio

select - SQL count number of users hava a value > 1 -

i need select brings 2 lines, 1 number of people " number of hits " > 0 , other line number of people " number of hits " = 0 select u.name 'usuário',u.full_name 'nome usuário',count(l.referer) 'número de acessos' mmp_user u left join mmp_mmpublish_log l on u.id=l.user_id , l.event_date between '2015-08-01' , '2015-08-08' group u.name,u.full_name order count(l.referer) desc i have, 151 users 9 accessed , 142 not accessed. but don't return values in select, me please. table mmp_user fields ( id , created_by , avatar_id , creation_date , email , full_name , last_edited_by , last_edition_date , name , observation , user_password , password_reminder , signature , status , administrator , designer , security_office , publisher , branch_id , department_id , extension , phone , company_id , position , admission_date , password_last_edition_date , dismissed_date , newsletter , expire_

javascript - Showing trailing region inside bordercontainer when some event occurrs -

i have 3 content pane inside border container , have region specified left,right , center.now want keep left , center region content pane displayed default when occurs want open right content pane well. here have tried using able keep right region hidden default not getting displayed when event occurs. div id="applayout" data-dojo-attach-point="_bordercontainer" data-dojo-type="idx/layout/bordercontainer" class="contentpane dblayout-left" data-dojo-props="design: 'headline'" > <div id="leftcol" class="edgepanel" data-dojo-type="dijit/layout/contentpane" style="width:23%" data-dojo-props="region: 'left',splitter: true"> left pane </div> <div data-dojo-type="dijit/layout/contentpane" data-dojo-attach-point="customitemproparea" data-dojo-props="region: 'right', splitter: true, open:false" style="width:25%;&q

svn error on merge where one branch must be ancestrally related to the other -

i have 2 branches both created trunk. for branch 2.1, branch copied trunk for branch 2.2: first branch folder v2.2 created , added. second copy form trunk performed v2.2/code. in fact actual branch folder "code". subsequently, "code" svn moved root folder v2.2. end effect @ point, both branches (v2.1 & v2.2) appear identical. here issue, when merge branch v2.1 branch v2.2 message: https://svn.mycorp.com/svn/star/branches/v2.1@49058 must ancestrally related https://svn.mycorp.com/svn/star/branches/v2.2@49040 any idea how merge code back? tried create "code" folder under v2.2 branch , svn move code back, same result when attempt merge v2.1 v2.2/code folder. any appreciated try --ignore-ancestry option svn merge . this option ignores merge info history, need manually select revisions merge. svn not figure out changes merge automatically.

angularfire - Firebase read are returning permission_denied when I'm logged with password -

i'm getting permission_denied when tried read user-mappings data "authentication password", i'm able read if i'm logged linkedin. whould know i'm doing wrong? this structure of data , rules: //firebase data user-mappings: { linkedin: { mylikedinid: { user: { uid: "simplelogin:1" } } } } //firebase rules "user-mappings": { "linkedin": { "$linkedin_uid": { ".read": "auth !== null && ( (auth.provider === 'linkedin' && auth.id === $linkedin_uid) || (auth.uid === data.child('user/uid').val()) )", ".write": "true" } } } basically, i'm trying access "user-mappings/linkedin/$linkedin_uid" data when i'm logged email , password. my code is: //login auth.$authwithpassword(user).then(function(authdataresult) { //some code here }).catch(function(error

javascript - Ember JS set request header -

i trying set auth token recieved response after user registration ember data request header. here application.js code import ds 'ember-data'; export default ds.restadapter.extend({ namespace: 'merchant', host: 'http://192.168.1.173:3000', headers: function() { return { "token":localstorage.token, }; }.property("localstorage.token","token") }); i trying set header after receiving success response register user api call. var register=this.store.createrecord('registermerchant',data); register.save().then(function(response){ console.log(response.success); if(response.get('success')){ self.set('token',response.get('token')); self.transitiontoroute('merchanthome') } and tokenchanged: function() { localstorage.token=this.get('token'); console.log(localstorage.token); }.observes('token'), i able s

python - Search Text and replace with lxml -

i need search text in multi-line xml file have multiple tags. xml file looks <?xml version="1.0" encoding="utf-8"?> <nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> <system xmlns="http://www.abc.xyz"> <context> <name>context_1</name> <host> <name>xyz</name> <tag1> <name>pqr</name> <role>s1</role> <tag2>test</tag2> </tag1> <tag2> <name>pqr</name> <role>s1</role> <tag2>test</tag2> </tag2> </host> </context> </system> </nc:data> i want search appearances of text "test" in xml file ,

spring - AuthenticationManager returns NullPointerException -

this question has answer here: spring jsf integration: how inject spring component/service in jsf managed bean? 3 answers i'd login page web application. on example project found on internet integrating spring security , ldap, got working. when tried integrate working example real app, i'm gettin nullpointerexception. you have both spring annotation , jsf annotations on same class, if refer them different names (like did seeing own 'answer'), different instances. not , cause of original problem. (and did not post xhtml) referred bean in xhtml loginviewbean . removed , (i suspect) started referring loginview , got spring managed instance authenticationmanager injected, instead of jsf managed 1 without authenticationmanger injected. resulted in npe. got spring 1 caused springel resolver configured having precedence on default jsf resolver. rem

Unable to find string using Regex in Word 2010 -

i trying find string in word, can see 3 of strings in document. however, remaining 600+ of them not visible. i'm trying search using (this regex in external tool used initially): (abc-\d+) using tool search in word searched (abc.*) and of results ended being form of following: abcnormal -13 i don't have clue how find out means in context. i tried searching in word following regex , doesn't find except 3 don't have "normal " thing. abc?@[0-9]@ that should mean abc number of characters , number of numbers. i have tried turning on hidden text/etc within display options, paragraph icon on ribbon, think of. any ideas how figure out how see is, , either fix it, or work around it? in external tool [(abc)[^0-9]+(\d+)] worked, still don't understand how remove normal text in string not visible. for example string visibly see abc-13 the text regex seeing abcnormal -13

font awesome - Some images/icons not working on 1st load -

not loading few icons when loads 1st time @ browser in opencart 2.0.3.1 , add cart button dose not works @ 1st time load. site url- http://www.allcardecor.com/ i tried clearing cache, reinstalling modules. you're having cross-domain issue request. when load page in console see error: font origin ' http://allcardecor.com ' has been blocked loading cross-origin resource sharing policy: no 'access-control-allow-origin' header present on requested resource. origin ' http://www.allcardecor.com ' therefore not allowed access. you'll note site http://www.allcardecor.com , calling on fontawesome files http://allcardecor.com . browser seeing 2 different domains. you'll want setup canonical name 1 of domains in dns it's recognized legitimate alias other. https://en.wikipedia.org/wiki/cname_record you should setup cors can call scripts approved sites without running cross domain errors: https://developer.mozilla.org/en-us/

c++ - Why does Hello world not print in vim but it works in tty? -

in vim enter command :w | make . makefile looks this: all: g++ -o main main.cpp ./main main.cpp looks this: #include <iostream> using namespace std; int main(){ cout << "hello world!"; } vim output says: "main.cpp" 6l, 88c written :!make 2>&1| tee /tmp/ve16mwu/0 g++ -o main maincpp ./main (1 of 3): g++ -o main main.cpp press enter or type command continue_ now after quit vim , run executable: $ ./main output shows fine in terminal. if put add newline \n line this: "hello world!\n" shows in vim's output fine. apparently, in vim, output won't show last line of text if doesn't have \n on end. there workaround this? endl cplusplus.com : insert newline , flush inserts new-line character , flushes stream. so code this: #include <iostream> using namespace std; int main(){ cout << "hello world!" << endl; return 0; }

c# - How to save radiobutton data in MVC controller edit method? -

in edit page, have 2 radio buttons gender, once user selected gender male or female, value should saved in database. i tried solutions proposed, none works. here view page: <div class="form-group"> @html.labelfor(model => model.ismale, htmlattributes: new { @class = "control-label col-md-2" }) <div class="radioleft col-sm-3"> @html.radiobuttonfor(model => model.ismale, "male", new { @checked = true })male @html.radiobuttonfor(model => model.ismale, "female", new { @checked = false })female @html.validationmessagefor(model => model.ismale, "", new { @class = "text-danger" }) </div> </div> here controller edit method: [httppost] [validateantiforgerytoken] public actionresult edit( webuser webuser) { if (modelstate.isvalid) { db.entry(webuser).state = enti

iphone - How to attach library to ios project? -

i'm developing command line tool app uses applist library. when trying run in on device, error occured: dyld: library not loaded: /usr/lib/libapplist.dylib referenced from: /usr/bin/testapp reason: image not found is possible attach libapplist.dylib project package? all dylibs have installation path inside mach-o header. path placed in application import section linker find dylib. when process launched dyld searches path dylib. you can check path this: otool -d libapplist.dylib that's dyld telling - couldn't find dylib. have 2 options: place dylib needs be change installation path. if it's dylib can change inside xcode project settings of dylib - search installation directory . when rebuild dylib , application linking contain new path. if can't recompile dylib need change manually. here how can it: install_name_tool -id @executable_path/libapplist.dylib libapplist.dylib @executable_path tells linker search dylib application

numpy - Unsupported operand type(s) for ** or pow(): 'generator' and 'int' -

what want: trying read list of 6,000 coordinates (ra, , dec) , each 1 of coordinates they're 78 points around them. applying angle (ang) , trying find new ra , dec. there seems problem z_sq=(x 2 + y 2) because got error unsupported operand type(s) ** or pow(): 'generator' , 'int'. import matplotlib.pyplot plt import numpy np import pylab py coords=np.genfromtxt('hetdex_reg.txt',dtype=none,usecols=(0,1,2),names= ('ra','dec','ang')) ra=coords['ra'] dec=coords['dec'] ang=coords['ang'] coords=np.genfromtxt('ifus_78_base.txt', dtype=none, usecols=(0,1), names=('xx', 'yy')) xx=coords['xx'] yy=coords['yy'] in range(len(ang)): ang_new=360-ang[i] x= (xx[j] j in range(len(xx))) y= (yy[j] j in range(len(yy))) z_sq=(x**2 + y**2) z=np.sqrt(z_sq) x_new=(np.deg2rad(x)) y_new=(np.deg2rad(y)) theta=py.arctan(x_new/y_new) tau=90-ang[

Which FPGA with audio input -

i searching fpga audio input. unfortunately cheapest can find 1 500$: https://digilentinc.com/products/detail.cfm?navpath=2,719,1476&prod=nexys-video does know cheaper 1 audio input? thank support.

SQL Server: Adding a column increases table size more than expected -

to migrate new schema, doing 2 things table: changing varchar column nvarchar adding bigint column to test how affects size, generated 180,000 rows. varchar column changing set null on every row. here results of sp_spaceused (all sizes in kb): rows reserved data index_size unused ---- -------- ---- ---------- ------ before 180000 110976 43168 67288 520 after 180000 120320 52536 67296 488 so data grew more 9mb. have expected grow 1.4 mb, because added 8-byte numeric column. if create table , generate data, size looks more expect: rows reserved data index_size unused ---- -------- ---- ---------- ------ 180000 117760 46184 71352 224 so there adding column causes sp_spaceused report more data in use added? no 1 explained why happened. dave gugg gave great hint. sql stores rows in pages. (that 8k, not

git log - Git log formatting just one author -

i'm trying log of commits, organized day log tracking. want this: commit message author date so actual log like: fixed spacing on homepage terry july 27, 2015 the closest i've found far this: git log --author="terry" --date=iso --pretty=format:'%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%an %s' but i'm not able interpret of 08% business able change want. any ideas? something this? git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --author="steve" even better, if need date without timestamp: git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --author="steve" --date=short if want authors remove --author option in above command. more info: http://git-scm.com/docs/pretty-formats

ruby - Rails gmaps4rails Map doesn't autoadjust -

Image
i followed gmaps4rails v2 tutorial youtube. this happens... explanation: randomly when access view, shows maps partially , if move maps mouse (as first 2 pictures) never fills field... after n tries (just pressing f5...) displays correctly (third picture) later page reloading, it's first pictures. need know happening. view: <div style='width: 600px;'> <div id="map" style='width: 600px; height: 300px;'></div> </div> <script type="text/javascript"> handler = gmaps.build('google'); handler.buildmap({ provider: {}, internal: {id: 'map'}}, function(){ markers = handler.addmarkers(<%=raw @hash.to_json %>); handler.bounds.extendwith(markers); //handler.fitmaptobounds(); handler.getmap().setzoom(15); handler.map.centeron(marker); }); </script> controller: @hash = gmaps4rails.build_markers(@users) |user, marker| marker.lat user.la

javascript - Changing innerHTML to value from div's Id captured by it's ClassName -

Image
i have buttons 1-9 , want show numbers on div called "screen". wrote such code, not seem work. piece of html code buttons: <div id="screen"></div> <div><input type="submit" class="numkey" id="key7" value="7" onclick="enterpin();"></div> <div><input type="submit" class="numkey" id="key8" value="8" onclick="enterpin();"></div> <div><input type="submit" class="numkey" id="key9" value="9" onclick="enterpin();"></div> <div style="clear: both;"></div> <div><input type="submit" class="numkey" id="key4" value="4" onclick="enterpin();"></div> <div><input type="submit" class="numkey" id="key5" value="5&

SVG Text-anchor top left -

by default, anchor text element in svg @ bottom left, want @ top left, since creating rectangle act background text, displayed incorrectly since text higher rectangle (because rectangle anchor/offset @ top left). there way fix this, both text , rectangle can drawn @ same coordinates , displayed in same location. the coordinates ( x , y ) supply text elements used baseline of text. makes sense because if there text varying font sizes on same line, want baselines line up. there no "automatic" way want. svg elements absolutely positioned. you have move text down bit making y coordinate bit larger. alternatively, add dy attribute shift text down bit. or use transform attribute same. using either of methods wouldn't simplifying process you.

python - Using 'itemgetter' to sort on last, first name in a tuple from a dictionary? -

my programs reads input dictionary, formats have title formatting, , outputs read. assignment required don't use dictreader . i'd sort on last name, , first name using itemgetter . can see, have working version of code using lambda function, i'd same result aforementioned itemgetter function. import sys operator import itemgetter, attrgetter, methodcaller def data_2_dict(line): # constants name = 0 addr = 1 addr2 = 2 city = 3 state = 4 zip = 5 # split line , populate dictionary line = line.rstrip('\n') element = line.split(',') data_dict = { 'name' : tuple(element[name].split(' ')), 'address' : element[addr], 'address2' : element[addr2], 'city' : element[city], 'state' : element[state], 'zip' : element[zip], } return format_data(data_dict) def format_data(dict): key, value in d

Excel 2013: Show slicers based on a certan selection on a pivot table -

is possible display slicer based on selection on field in pivot table? i have large number of fields two-layer hierarchy, let's have level 1 hierarchy values a , b , c (yes/no option only) , second level fields a1 , a2 , a3 , b1 , b2 , b3 , etc. have built pivot table adding filters a, b , c . if add second level number of fields displayed on pivot large, i'd display slicers based on selection. example, if value in field a yee , display slicers a1 , a2 , a3 . is possible?

c# - Getting Results With Entity Framework -

i'm trying query db set, can't seem access data when results. here code i've tried. query #1: public list<customermain> testing() { var context = new customerentities(); var query = context.customermains .where(p=> p.firstname == "thor") .select(p => new customermain {firstname=p.firstname,lastname =p.lastname}).tolist(); return query; } query #2: public iqueryable<customermain> testing() { var context = new customerentities(); var query = context.customermains .where(p=> p.firstname == "thor") .select(p => new customermain {firstname=p.firstname,lastname =p.lastname}); return query; } customermain dbset , if run either of , assign method var variable, gives me no options grab firstname or lastname variable. found can if convert customermain , shouldn't return query in customermain type already? it

image - GOP Reassemble and display order -

how display following transition in mpeg bit code? i, p, b, b, p, b, b, b, i, p, b, b, b, p, b, p thank you usually displayed as i, b, b, p, b, b, b, p, i, b, b, b, p, b, p, p

Configure IIS Web Farm to prefer specific server -

i've setup web farm in iis 8 (windows 2012) arr 3.0. farm has 2 servers. possible configure requests directed specific server (if healthy) , if server not healthy, requests directed second server? i haven't found solution implemented workaround solves problem. used health test feature of server farm. on preferred server health test url responds ok. on secondary server health test url checks if preferred server functional , responds http status code outside acceptable status codes if is, or ok if isn't. implementation asp the health test url http://serverfarm/healthtest.asp 'serverfarm' server farm name given when farm created. preferred server's healttest.asp <%@ language=jscript codepage=65001%> <% response.write('ok'); %> secondary server's healthtest.asp <% var xmlhttp = server.createobject("msxml2.serverxmlhttp"); var requrl = 'http://preferred.server.ip/healthtest.asp';

cuda - Thrust vector with custom data type -

i using thrust library project , ran following problem: i have struct called box defined as typedef struct { int coord[4]; float h; } box; and trying copy data device_vector of boxes host_vector of boxes: thrust::device_vector<box> d_boxes(100); thrust::host_vector<box> h_boxes; thrust::copy(d_boxes.begin(), d_boxes.end(), h_boxes.begin()); but throws error terminate called after throwing instance of 'thrust::system::system_error' what(): invalid argument if same int instead of box, works fine. unfortunately, documentation not seem have example of vectors of custom data types. what did miss? thrust::copy doesn't automatically resize vectors (actually no thrust algorithms do.) so empty vector, not large enough hold 100 objects: thrust::host_vector<box> h_boxes; try instead: thrust::host_vector<box> h_boxes(100); as pointed out @jaredhoberock, alternate realization be: thrust::device_vector<bo

c++ - sizeof packed bitfield returns 4 but I expect 1. How does it come and how I can fix? -

i have bitfield defined follows (where expect of size: 1): #pragma pack(push, 1) typedef struct { unsigned boolfoo : 1; unsigned placeholder : 7; } knownbitflags1_t; #pragma pack(pop) but after painfull debugging figgured out sizeof(knownbitflags1) returns 4 why? i tried: typedef struct { unsigned boolfoo : 1; unsigned placeholder : 7; } __attribute__((packed, aligned(1))) knownbitflags1_t; what keeps sizeof structure @ 4 anyway. so can stop padding array of structure? it depends on underlying type. change unsigned unsigned char : typedef struct { unsigned char boolfoo : 1; unsigned char placeholder : 7; } knownbitflags1_t;

ios - AVAudioSession Interruption notification fires only once -

in ios app i'm registering avaudiosession interruption notifications [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(handleaudiosessioninterruption:) name:avaudiosessioninterruptionnotification object:nil]; [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayandrecord withoptions:avaudiosessioncategoryoptionallowbluetooth error:nil]; [[avaudiosession sharedinstance] setactive:yes error:nil]; when test app playing random music youtube, handleaudiosessioninterruption method fires first time (interruptionbegan). when quit youtube app, method gets fired again (interruptionended). repeat same steps before , method not fired @ , need restart app make work again. can tell wrong or point sample implementation. note : neither see errors nor app crashes. it's possible observer getting removed nsnotificationcenter . make sure that not happening. calling removeobserver:self without specifying notification name remove self n

android - NoClassDefFoundError on RoboSpice -

recently migrated android project eclipse adt android studio, little tricky, project uses robospice (1.4.6) , runs on android api 22 when try run on real device (android api 14) throws noclassdeffounderror exception. here stack: 08-07 18:14:13.392 31254-31254/com.mypackage.myapp e/dalvikvm﹕ not find class 'com.octo.android.robospice.priority.priorityfuture', referenced method com.octo.android.robospice.priority.prioritythreadpoolexecutor.newtaskfor 08-07 18:14:13.393 31254-31254/com.mypackage.myapp e/dalvikvm﹕ not find class 'com.octo.android.robospice.priority.pausablepriorityblockingqueue', referenced method com.octo.android.robospice.priority.pausablethreadpoolexecutor.<init> 08-07 18:14:13.394 31254-31254/com.mypackage.myapp e/dalvikvm﹕ not find class 'com.octo.android.robospice.priority.pausablepriorityblockingqueue', referenced method com.octo.android.robospice.priority.pausablethreadpoolexecutor.<init> 08-07 18:14:13.394 31254-31254/

Django 1.8 - Intermediary Many-to-Many-Through Relationship - What is the consequence of where 'ManytoManyField' is used? -

an example many-to-many through relationship in django: class first(models.model): seconds = models.manytomanyfield(second, through='middle') class middle(models.model): first = models.foreignkey(first) second = models.foreignkey(second) class second(models.model): following documentation on intermediary models , 1 model of pair related contains manytomanyfield , model first in example above. correct? if so, model should contain manytomanyfield field? there differences in using relationship either end depending on manytomanyfield is? thanks edit (i should have been clearer): i'm interested in intermediary table because have additional data store on relationship. when usage, don't mean defining models, mean using relationship (otherwise i'd let django it's thing). if want seconds related first, same getting firsts related second, or manytomanyfield make 1 direction easier other introducing functionality? there shouldn

doctrine2 - Symfony, previous and next links -

i'm working symfony2. i have links previous , next articles of loaded article. for instance.: i have 3 post (1, 2 , 3). when i'm in article 2 need show links articles 1 , 3 (previous , next) any idea how efficiently? thanks in advance well best hint can give query date. so next article first 1 older , prev article first 1 newer