Posts

Showing posts from March, 2015

php - ion_auth fails when get another database instance -

in project, work 2 databases, in parts when need use secondary database, use: $newdb = $this->load->database("otherdb", true); or $ci =& get_instance(); $newdb = $ci->load->database("otherdb",true); to de instance. but when this, ion_auth fails keep connection original database , throw 2 errors: call member function result() in get_users_groups function, and: trying property of non-object in link_menu_acl function. i tried forcing reload default databse, "fixed" first problem. my guess when load secondary database, ion_auth lose connection default database, don't know how keep or reconnect use both databases. ok, problem main , secondary databases, had set "true" in persistent connect configuration, seems ion_auth "found" secondary connection , tried query on and, possible because "unknown error" returned false instead object. changing secondary database "pconnect&

What does the following assignment mean in the coffeescript snippet? -

i saw class a, after class definition class constructor: (@x=0, @y=0) -> @a = what @a = here? it helps @ generated output. // generated coffeescript 1.9.3 (function() { var a; = (function() { function a(x, y) { this.x = x != null ? x : 0; this.y = y != null ? y : 0; } return a; })(); this.a = a; }).call(this); so @a translates this.a . when this used @ top level, refers window . @a = a exports class onto window object. this done export library. example, window.$ = jquery or window._ = lodash .

list - How to enable/disable specific item in selectManyCheckbox on ajax keyUp -

i need in enabling/disabling specific item in selectmanycheckbox component based on ajax call keyup. when page loads, firing below method populate selectmanycheckbox items in form: @postconstruct public void init() throws sqlexception { this.hrcertificateslist.add(new hrcertificate(("employment"), "ce", false)); this.hrcertificateslist.add(new hrcertificate(("loan"), "lc", false)); } and here jsf code: <p:inputtext id="selectedemployee" value="#{hrrequest.selectedemployeecode}"> <p:ajax event="keyup" update="employeename" listener="#{hrrequest.getemployeename}" /> </p:inputtext> <h:outputtext id="employeename" value="#{hrrequest.selectedemployeename}" /> <p:selectmanycheckbox id="hrcertificates" value="#{hrrequest.selectedhrcertificates}"> <f:selectitems value="#{hrrequest.hr

python - Raise to 1/3 gives complex number -

i cannot understand following output. expect numpy return -10 (or approximation). why complex number? print((-1000)**(1/3.)) numpy answer (5+8.660254037844384j) numpy official tutorial says answer nan . can find in middle of this tutorial . you exponentiating regular python scalar rather numpy array. try this: import numpy np print(np.array(-1000) ** (1. / 3)) # nan the difference numpy not automatically promote result complex type, whereas python 3 scalar gets promoted complex value (in python 2.7 valueerror ). as explained in link @jonrsharpe gave above, negative numbers have multiple cube roots. root looking for, this: x = -1000 print(np.copysign(np.abs(x) ** (1. / 3), x)) # -10.0 update 1 mark dickinson absolutely right underlying cause of problem - 1. / 3 not same third because of rounding error, x ** (1. / 3) not quite same thing cube root of x . a better solution use scipy.special.cbrt , computes 'exact' cube root rather x ** (1

json - SoapUI: Extract Response Value from an Array and Pass Along to Next Request -

i'm hoping can me once again! i figured out how extract value rest response in simple scenario , pass value along preceding test step, however, i'm stumped on how extract value array within rest response (shown below) use in preceding test step. more specifically, i'm attempting extract 1 of "id" values within answerchoices. response payload: (get) localhost/ws/portal/survey/question/${create ux survey question#responseasxml#//*:id} { "id": 589, "isenabled": true, "type": "radio", "wording": "soapui test ux survey question", "answerchoices": [ { "id": 1546, "order": 4, "text": "choice4" }, { "id": 1543, "order": 2, "text": "choice2" },

c# - Most effective way to lookup a substring C of string B in string A in LINQ -

having 2 strings like: string = "attagacctgccggaa"; string b = "gccggaatac"; i delete part common in both strings , rest concatenate it. have tell need delete left matched part get input attagacctgccggaa gccggaatac output attagacctgccggaatac firstly thought use pattern , seacrh it, not possible not know pattern in advance (the length of matched chars variable) then thought on search whole string b in a if had no succes, delete char in string a (last 1 since want preserve left unmatched string) , loop until have no more chars in b like string = "attagacctgccggaa"; string b = "gccggaatac"; int times = b.length; string wantedstring = string.empty; string auxstring = b; while (times > 0) { if (!a.contains(auxstring)) { //save last char , delete auxstring wantedstring += auxstring[auxstring.length - 1]; auxstring = auxstring.trimend(auxstring[auxstring.length - 1]); } els

Groovy parameter "String..." -

i'm in midst of implementing unit tests web application , i've come across piece of code (and others) have parameter "string..." i'm not sure "..." means, if @ all, can't find explanation anywhere. public static list<user> getusersforgroups(string... dns) { set<string> members = getmembers(dns) return members.collect{ getuser(it) }.findall{ }.sort{ user u -> "$u.lastname $u.firstname"} } this java feature called varargs , groovy supports it . lets method accept multiple parameters without making caller package them data structure first. arguments bundled array before being passed method: groovy:000> def foo(string... stuff) { groovy:001> println(stuff.class) groovy:002> (s in stuff) { groovy:003> println(s) groovy:004> }} ===> true groovy:000> foo('a','b','c','d') class [ljava.lang.string; b c d ===> null groovy:000> foo('q'

php - Laravel - display a PDF file in storage without forcing download? -

i have pdf file stored in app/storage/, , want authenticated users able view file. know can make them download using return response::download($path, $filename, $headers); but wondering if there way make them view file directly in browser, example when using google chrome built-in pdf viewer. appreciated! update 2017 as of laravel 5.2 documented under other response types can use file helper display file in user's browser. return response()->file($pathtofile); return response()->file($pathtofile, $headers); source/thanks below answer outdated answer 2014 you need send contents of file browser , tell content type rather tell browser download it. $filename = 'test.pdf'; $path = storage_path($filename); return response::make(file_get_contents($path), 200, [ 'content-type' => 'application/pdf', 'content-disposition' => 'inline; filename="'.$filename.'"' ]); if use response::d

c++ - C2665: 'QObject::connect' : none of the 3 overloads could convert all the arguments types -

i have following code in main qprocess process; qobject::connect(&process, &qprocess::error, [](qprocess::processerror error) { qdebug() << error; }, qt::queuedconnection); bool launched = process.startdetached("d:\temp.exe"); and generating error while compiling d:\main.cpp:5: error: c2665: 'qobject::connect' : none of 3 overloads convert argument types c:\qt\5.3\msvc2013_64\include\qtcore\qobject.h(205): 'qmetaobject::connection qobject::connect(const qobject *,const char *,const char *,qt::connectiontype) const' c:\qt\5.3\msvc2013_64\include\qtcore\qobject.h(201): or 'qmetaobject::connection qobject::connect(const qobject *,const qmetamethod &,const qobject *,const qmetamethod &,qt::connectiontype)' c:\qt\5.3\msvc2013_64\include\qtcore\qobject.h(198): or 'qmetaobject::connection qobject::connect(const qobject *,const char *,const qobje

java - I want to Print multiple lines of Text using a JTextPane to a window -

i've search question in different wording past day or 2 , can not solve :/, i have window pops on screen looks command prompt there 2 buttons run , stop. anyways have on screen once press start starts "scanning files" says "scanning 1-1900 something" counts 1900 , says scan completed, after want text go under existing text , write multiple lines of text mess friend example. { scan completed "wait time inbetween each line of text" hack initialized "wait time inbetween each line of text" hack installing... "wait time inbetween each line of text" hack installed ect } hopefully can me, every 1 looked @ did not work code :/ i'm new code so... thanks in advance anyways here code not long :p. public static void main(string[] args) throws ioexception { jframe frame = new jframe("happy monday v0.05"); container contentpane = frame.getcontentpane(); jtextpane jta = new jtextpane();

github - How to push only specific folders from Master branch to gh-pages branch? -

i'm new github , web development in general. have of project files on master branch , want push files needed make page run on gh-pages. how tell push files new gh-pages branch? example, when use gulp or grunt makes folder rendered site previewing site. how push contents site folder gh-pages without adding of other unecessary on master branch? i've been using jekyll because can still push of files onto gh-pages , still works. have 2 repositories lot of projects. 1 repository has of source files , other repository has files need push working site onto gh-pages. want clean github page more organized. thank you. if using nodejs , npm can use gh-pages package command line publish gh-pages branch specific directory. gh-pages package has command line utility . installing package creates gh-pages command line utility. run gh-pages --help see list of supported options. note: mentioned using gulp , there npm package called gulp-gh-pages use create gu

java - Can't write in inflate layout -

i'm using broadcastreceiver in draweractivity in can receive notification service , set text of notification in layout in fragment (the first fragment of navigation drawer). draweractivity start broadcastreceiver (i tried start directly fragment doesn't work!) broadcastreceiver: public broadcastreceiver onnotice= new broadcastreceiver() { linearlayout notificationlayout; drawable icon; @override public void onreceive(context context, intent intent) { final string pack = intent.getstringextra("package"); string title = intent.getstringextra("title"); string text = intent.getstringextra("text"); view myview = getlayoutinflater().inflate(r.layout.activity_main, null); notificationlayout = (linearlayout)myview.findviewbyid(r.id.notificationlayout); textview notificationdescription = (textview) myview.findviewbyid(r.id.notificationdesc);

javascript - Resize image on client side before uploading to the server -

there plenty of information on web resizing uploaded image on server. can't find information resizing on client instead. i using this php code handle upload. works, web server accepts uploads of 2 mb or smaller. therefore, want client side code resize uploaded image no larger this. no. php server side language. cannot resize images on client side php.

angularjs - Testing angular modal's opened promise -

there's lot of questions on testing angular modals, seem mocking modal instance. want call through implementation, , in particular opened promise callback. here's module: angular.module('myapp') .directive('widgetcontainer', function() { return { templateurl: '/static/templates/container.html', controller: 'containerctrl' }; }) .controller('containerctrl', ['$scope', '$modal', function($scope, $modal) { function editwidget(widget) { var modalinstance = $modal.open({ templateurl: '/static/templates//modal.html', controller: 'modalinstancectrl', scope: $scope, size: 'lg', backdrop: 'static' }); modalinstance.opened.then(function() { $scope.widgetcopy = editwidgetinit(widget); }); modalinstance.result .then(function() { // result }); return modalinstance; } function editwidgetinit(widget) {

javascript - Change form style/appearance to Node.js applications -

i know how change window form style app built node.js . mean, once finish our app , packaged node.js, when launch we'll have windows 7 ( if use windows 7) form style, windows 8 form style if use windows 8, etc.. how can change form style? how can change appearance of application without traditional form style of os we're using?

django - Proper site project structure when project under development -

i trying @ first time develop site on own, , don't have real experience, have bit of frameworks , technologies in use. @ current moment using django runs under local apache server. , front-end part using bootstrap sources less . , have use git . project folder contain lot of releases site mustn't. the apache root directory, default 1 offered, var/www/html/bestsite . not convenient in use, because requires root user, every editor have run under root user. well next logical step reconfig apache use other path, let's home/user/projects/bestsite , again here have lot of unnecessary releases site mustn't. can write script or use grunt copy bestsite's content var/www/html/bestsite , have doubts rationality of solution. finally question how should be? how organize projects? for development don't use apache. use built-in development server. can run python manage.py runserver . when comes less or sass recommend use django-compressor . integrates dja

java - TarsosDSP Pitch Analysis for Dummies -

i woking on progarm analyze pitch of sound file. came across api called "tarsosdsp" offers various pitch analysis. experiencing lot of trouble setting up. can show me quick pointers on how use api (espically pitchprocessor class) please? snippets of code extremely appreciated because new @ sound analysis. thanks edit: found document @ http://husk.eecs.berkeley.edu/courses/cs160-sp14/index.php/sound_programming there example code shows how setup pitchprocessor, … int bufferreadresult = mrecorder.read(mbuffer, 0, mbuffersize); // (note: not android.media.audioformat) be.hogent.tarsos.dsp.audioformat mtarsosformat = new be.hogent.tarsos.dsp.audioformat(sample_rate, 16, 1, true, false); audioevent audioevent = new audioevent(mtarsosformat, bufferreadresult); audioevent.setfloatbufferwithbytebuffer(mbuffer); pitchprocessor.process(audioevent); …i quite lost, mbuffer , mbuffersize? how find these values? , input audio files? the basic flow of audio in tarsosds

ntp - How to synchronise clocks in a local network? -

let assume have number of systems connected in local network , not connected internet. can best way ensure each of these clocks in sync? not necessary in sync utc time enough in sync amongst themselves. i had thought of using ntp, setting ntp server in 1 of systems. need advise if more cumbersome compared requirement. advisable try manually compute round trip time , server time using tcp sockets? solution small local network synchronized each other using undisciplined local clock of 1 of machines can done in simple ntp peer network 1 setup local clock backup if real time sources fail. one example of multi-server/peer ntp network. notice how each ntp not have same servers listed. better use of peer sync. peer sync can match against different time results. 1a 1b 1c 1d 1e 1f outside . \ / ...... \ / ...... \ / .............. 2a ---p--- 2b ---p--- 2c inside /|\ /|\ /|\ / | \ / | \ / | \ 3a 3b 3c 3e 3f 3g 3h 3i 3j

css position - How can I use a CSS transform to vertically-center two overlapping elements? -

i have relatively-positioned div wrapper, , want vertically-align div inside of it. various other stack answers seem suggest right way this: .vcenter {position: relative; top: 50%; transform: translatey(-50%); } that works great, single child element. want have 2 overlapping child divs, picture , text, both vertically-centered within wrapper div: <div class="wrap"> <div class="foo vcenter"></div> <div class="bar vcenter"></div> </div> this doesn't work - transform applies both children, second child offset vertically height of first child. i made simple jsfiddle may make clearer. is there way both elements each center if child? (ps - don't tell me replace them single div containing text , image background, need move independent of each other) you should use position absolute instead of relative: .vcenter { position: absolute; top: 50%; left: 50%; transform:

api - Birt Chart: How do I access an aggregation values from a bound dataSet via script -

could me following: i have chart element in .rptdesign file. uses dataset has 3 column bindings. 2 columns ( x , y ) came dataset , used make plot. have column binding aggregation (count) on x . trying count how many points in dataset. far good.... now depending on how many points dataset, need dynamically adjust properties of chart, through beforegeneration() event handler. question: how access aggregation values within beforegeneration() event handler shown below: function beforegeneration( chart, icsc ) { importpackage( packages.org.eclipse.birt.chart.model.data.impl ); count = ????? //get_value_from_aggregatoin } thanks!!

gruntjs - Yeoman - webapp with grunt-php, how to configure gruntfile.js? -

i have been using yeoman webapp generator. , think it's great! want persuade company work use it, too. work php files. so trying grunt-php working yo webapp generator. after spending lots of hours adjusting gruntfile.js , give up. does know how webapp generator working yeoman webapp generator?

visual c++ - error MSB8020: The build tools for WindowsKernelModeDriver8.1 -

i have problem whit windows driver kit 8.1 i reinstall windows 8.1 solve problem , although update windows driver kit 8.1 can't solve problem . actually in visual studio 2013 in platformtoolset , windows driver kit 8.1 (not installed). this full of error. error msb8020: build tools windowskernelmodedriver8.1 (platform toolset = 'windowskernelmodedriver8.1') cannot found. build using windowskernelmodedriver8.1 build tools, please install windowskernelmodedriver8.1 build tools. alternatively, may upgrade current visual studio tools selecting project menu or right-click solution, , selecting "upgrade solution...".

swift2 - Swift array.map - cannot invoke 'map' -

i using following code in xcode 6.4 split strings inside array arrays: func getdata() -> [string] { let data = navdata // navdata like: // a|xxx|xxx|xxx // r|ccc|ccc|ccc // n|ccc|ccc|ccc // n|ccc|ccc|ccc return split(data) { $0 == "\n" } } let data:[string] = getdata() func search(query:(string, int)) -> [string] { let recs:[string] = data.filter { $0.hasprefix(query.0) } var cols: [string] = recs.map { split( recs ) { $0 == "|" } } } func searchqueries() -> [(string, int)] { return [("n", 1)] //key, column index } q:(string, int) in searchqueries() { var results:[string] = search(q) x in results { result = results[0] } } it used work before, guess swift changed in 1.2 , gives following error now: cannot invoke 'map' argument list of type '(() -> _)' any suggestions? thank you! after discovering in swift 2 have split strings using char

linux - How could I remove all directories except 10 recent with bash? -

i have following folders in base /var/www/.versions directory: 1435773881 jul 1 21:04 1435774663 jul 2 21:17 1435774856 jul 3 21:20 1435775432 jul 4 21:56 how remove directories except 10 recent bash script? this should trick, believe? rm -r $(ls -td /var/www/.versions/*/ | tac | head -n-10) the idea: list (with ls ) directories ( that's -d /var/www/.versions/*/ ) sorted time -t (oldest shown last). then, reverse output using tac oldest directories on top. and show them except last 10 lines head , negative argument -n please, test non-vital directories first ;-) can change rm -r echo see removed.

COUNT function in SQL Server with WHERE clause -

i want know count function in sql server where clause something like... select sum(sales) <-- sales , count(ranking) <-- under 100 ranking a_chart so think... select sum(sales) , count(select * a_chart ranking <= 100) a_chart. a_chart data example ranking sales 1 100 2 50 3 30 4 5 then, want know sales sum, ranking under 2. so, right? select sum(all sales), count(ranking < 2) a_chart. please teach me. thanks. this looking for select sum(sales) <-- sales ,count(case when ranking < 100 1 end) <-- under 100 ranking a_chart

c++ - Camera media source with media foundation - MS Sample code doesn't compile with Visual Studio 2013 -

i tried compiling this sample code visual studio 2013 win64 (on windows 8.1). included mfapi.h , mfidl.h. gets compilation errors identifiers not found example: mf_devsource_attribute_source_type mfenumdevicesources i googled, , saw mention of these features being windows 7+ specific , of vs "platform toolset" property required enable them - property doesn't seem exist in vs 2013. any suggestions? you have make c++ project win32 project, not store app project type. if @ mfidl.h there compile flag disables media foundation devsource attributes when not desktop application, i.e., winapi_family_partition(winapi_partition_desktop) true when project type win32, not windows 8.1.

ruby - Selenium chromedriver not playing nice with at_exit -

is bug in code, or bug in selenium, rspec, etc.? the cucumber tests i'm writing need shut down , re-launch chrome driver. however, can't second driver shut down properly. stripped-down example below shows problem: (the code below rspec because demonstrates issue without adding complexity of cucumber.) require 'selenium-webdriver' rspec.configure |config| config.before(:suite) $driver = selenium::webdriver.for :chrome end end describe "a potential rspec/selenium/chrome driver bug" "doesn't play nice at_exit" # quit initial driver , start new one. $driver.quit $driver = selenium::webdriver.for :chrome end # end # end describe at_exit $driver.quit end when run code following error: /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:878:in `initialize': connection refused - connect(2) (errno::econnrefused) /system/library/frameworks

android - Navigation drawer: How do I set the selected item at startup? -

my code works perfectly: every time item in navigation drawer clicked item selected. of course want start app default fragment (home), navigation drawer doesn't have item selected. how can select item programmatically? public class baseapp extends appcompatactivity { //defining variables protected string logtag = "logdebug"; protected toolbar toolbar; protected navigationview navigationview; protected drawerlayout drawerlayout; private datemanager db = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.base_layout); navigationview = (navigationview) findviewbyid(r.id.navigation_view); // set home/dashboard @ startup fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(r.id.frame, new dashboardfragment()); fragmenttransaction.commi

qt - QNetworkAccessManager PUT request example needed -

i have been using qnetworkaccessmanager , post requests. but need use put request update , external api. put requests needs json string part body sent update record. i not find working example of put request using qnetworkaccessmanager. please share sample code. finally found way send json data in qnetworkaccessmanager put request. i formed required json data , stored in qjsondocument variable. , passed variable(after converting utf-8 encoded json document using tojson() ) in put request. here working test code use believe helpful attempting this. qvariantmap testmapdata["age"] = 35; qjsondocument testjsondata = qjsondocument::fromvariant(testmapdata); qnetworkaccessmanager manager; qnetworkrequest request(qurl("http://example/member/14")); request.setheader(qnetworkrequest::contenttypeheader, qstring("application/json")); qnetworkreply* reply = manager.put(request, testjsondata.tojson());

html - Center an object tag in a div -

how can center object content within div? .parent{ background-color:yellow; } .ob{ margin: 0 auto; } </style> <div class="parent"> <object width="400" height="400" class="ob" data="helloworld.swf"> </object> </div> thanks in advance! an object element has inline style default, , margin: auto applies block-level elements only. add style: .ob { display: block; } fiddle

jquery - I am getting this $(...).dataTable(...).columnFilter is not a function -

i want start looked @ this question , using correct constructor. i error when running code: $(...).datatable(...).columnfilter not function html: <table class="table table-striped" id="activeprojects"> <thead> <tr> <th>project name</th> <th>project number</th> <th>manager</th> <th>architect</th> </tr> </thead> <tbody> </tbody> <tfoot> <tr> <th></th> <th></th> <th></th> <th></th> </tr> </tfoot> </table> <script> $(document).ready(function () { var table = $('#activeprojects').datatable({ "processing": true, "serverside": true, "ajax": {

.net - C# string replace "," with a linebreak (Enter) -

i have text string many ",". replace "," enter or linebreak. how can achieve this? thanks. yourstring = yourstring.replace(",", system.environment.newline); demo here https://dotnetfiddle.net/m2lbks

vb.net - TextBox writing on one line only -

when ever type in textbox, click button, have writeline. there way assign 1 text box first line, , second text box second line on notepad? when type new in it, delete had on first line, add new thing in text box? i using. dim file system.io.streamwriter file = my.computer.filesystem.opentextfilewriter("c:/users/nick/documents/dra.txt", true) file.writeline(namebasic) file.writeline(lastbasic) file.close() second argument in opentextfilewriter() method append . means strings appended end of file if true value. try use false instead: file = my.computer.filesystem.opentextfilewriter("c:/users/nick/documents/dra.txt", false) upd dim read string = console.readline() dim num integer integer.tryparse(read, num)

Why is `git push` to non-bare remote not the dual of `git fetch` from the remote -

first, understand how related pushing non-bare git remotes, including use of git config option receive.denycurrentbranch , other work arounds, i'm not looking answers such here: git push error '[remote rejected] master -> master (branch checked out)' push non-bare git repository git pushing non-bare repo, save current worktree git: making pushes non-bare repositories safe this more of git implementation/representation/philosophical question. why can't git push <remote> non-bare remote dual or same git fetch <source> remote? way, local working dir on remote may out of date (behind) new content, , might have local changes (commits ahead, or staged/unstaged/stashed/whatever), working dir untouched push operation? if did, once on remote, merge or rebase or whatevever necessary. in fact, that's claimed this kernel.org git faq entry . motiviation same else asks how questions: don't have way access "source" of push

javascript - Disable scrolling down breaks menu links in fullpage.js -

i'm using fullpage.js, especifically onleave function disable scrolling down in website. okay i'm having issues using menu because can scroll in 1 direction. this code: onleave: function(index, nextindex, direction){ if (direction == 'up') { return false; } else { return true; }; } so, if on number 3 section, , want go section number 4, page blocked. how handle exception menu? what using $.fn.fullpage.setallowscrolling(false, 'down'); ? from the docs : adds or remove possibility of scrolling through sections using mouse wheel/trackpad or touch gestures (which active default). note won't disable keyboard scrolling. need use setkeyboardscrolling it. that won't disable links. $('#fullpage').fullpage({ afterrender: fuction(){ $.fn.fullpage.setallowscrolling(false, 'down') } }); if want disable keyboard, need use setkeyboardscrolling well.

Reading csv file in Python and create a dictionary -

i trying read csv file in python 27 create dictionary. csv file looks like- si1440269,si1320943,si1321085 si1440270,si1320943,si1321085,si1320739 si1440271,si1320943 si1440273,si1321058,si1320943,si1320943 number of entries in each row not fixed. first column entries should keys. code - import csv reader = csv.reader(open('test.csv')) result = {} column in reader: key = column[0] if key in result: pass result[key] = column[1:] print result output: {'si1440273': ['si1321058', 'si1320943', 'si1320943'], '': ['', '', ''], 'si1440271': ['si1320943', '', ''], 'si1440270': ['si1320943', 'si1321085', 'si1320739'], 'si1440269': ['si1320943', 'si1321085', '']} how can rid of null values in output? also, how can have key values in output in same order in csv file? edit: want s

c# - Cannot implicitly convert type bool to string -

i'm trying create check name method see if user exist in database. created check() function/method in class called sqlfunctions2.but have error in code , can't seem fix. appreciate it. :) using system; using system.collections.generic; using system.linq; using system.text; using system.windows.forms; using system.data.sql; using system.data.sqlclient; namespace contact_form { public class sqlfunctions2 { static private sqlconnection conn = new sqlconnection("my string connection here"); public static string check(string name) { try { conn.open(); int exist; /*check see if username in database.*/ sqlcommand exist_cmd = new sqlcommand("select count(*) tbl_contact_form name=@name", conn); exist_cmd.parameters.addwithvalue("@name", name); exist = (int)exist_cmd.executescalar(); if (exist

Problematic transition from "left to right" to "right to left" in HTML -

i have following html code, in language written , readable left right, english language : <!doctype html> <html> <head> <title>title</title> <link rel="stylesheet" type="text/css" href="site.css"> <meta charset="utf-8"> <link rel="shortcut icon" href="favicon.ico" /> </head> <body> <div id="page"> <div id="banner"></div> <div id="tagline">blah blah blah</div> <div id="menu"> <div id="innermenu"> <div class="menuitem activeitem"><a href="somepage1.html">blah</a></div> <div class="menuitem"><a href="somepage2.html">blah</a></div> <div class="menuitem"><a href="somepage3.html">blah</a></div> <di

php - SQLSTATE[42S02]: Base table or view not found: 1146 Table X doesn't exist -

i getting error in laravel 5: sqlstate[42s02]: base table or view not found: 1146 table 'intern.users' doesn't exist (sql: select * users username = admin limit 1) config/database.php 'mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'intern', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], the function admin called admin page, , database table mentioned in admin because there many tables in it. public function admin(request $request){ if($request->ismethod('get')){ return \view::make('student.admin'); } else { $check=0; $check=\db::table('a

go - Why does gorm db.First() panic with "invalid memory address or nil pointer dereference"? -

i can't figure out if i've done silly or if i've found bug in gorm. while i'm aware of "invalid memory address or nil pointer dereference" means, mystified why appears here. in short, call db.first() , receive panic no obvious reason. the relevant bits of code: package main import ( "fmt" "github.com/gorilla/mux" "github.com/jinzhu/gorm" "net/http" "os" ) type message struct { gorm.model title string body string `sql:"size:0"` // blob } var db = gorm.db{} // garbage func messagehandler(w http.responsewriter, r *http.request) { vars := mux.vars(r) m := message{} query := db.first(&m, vars["id"]) if query.error != nil { if query.error == gorm.recordnotfound { notfoundhandler(w, r) return } else { fmt.fprintf(os.stderr, "database query failed: %v", query.error)

algorithm - Random point within oval with higher probability for a point closer to the centre? -

i feel question quite descriptive illustrate in words. picture radial gradient (black in centre, white on edge) want generate random point more fall in black, less fall in grey, , less fall in white. could point me in right direction? i'm quite stumped :/ if b matrix such y = c + bx affine transformation maps unit circle ellipse (which assume mean "oval"), probability distribution looks seem want given y ~ n(c, bb^t) b^t transpose of b . you can sample distribution generating column vector x of 2 distributed variables , applying transformation y = c + bx . there many libraries generating pair of distributed variables; in java, x0=rand.nextgaussian(); x1=rand.nextgaussian() work. this generate points outside ellipse. can avoid rejecting such points. test whether x0*x0 + x1*x1 > 1 , reject if true. one more thing: if want "more white" near edge of ellipse, can change standard deviation of gaussians generate number less 1: sd = 0.

angularjs - how to set path to popovertemplate in my solution? -

i using bootstrap popovertemplate (ui.bootstrap.popover) solution not see template: <span popover-template="./mytemplate.html" popover-trigger="mouseenter" ng-bind-html="somevalue"> </span> what right way of specifying template? you need specify path in single quote popover-template="'./mytemplate.html'"

ajax - Kango Extension Cross Domain Request -

i'm new working kango , have setup basic extension already. conversion existing extension , far. however, docs feel little light when comes doing ajax call cross-domain. this existing code worked 100% in other extension framework: $.ajax({ url:url, success:function(data){ alert("success!") } }); i'm seeing 200 ok response, response empty , never see alert. i'm guessing comes down need use kango api? i've tried of documentation samples , nothing seems working. above inside content script, if matters. i'm trying pull file , read contents, seems more difficult should be. if wan't perform cross domain request content script, should use kango.xhr.send : kango.xhr.send({url: 'http://example.com/'}, function(data) { if (data.status == 200 && data.response) { kango.console.log(data.response); } else { kango.console.log('something went wrong'); } })

php - International Domain Names -

when navigate aртем.example.com , web browser convert url xn--a-jtbvok.example.com . there way convert xn--a-jtbvok aртем using php? currently using $_server['http_host'] fetch requested url. live examples here: aртем.lekintepls.se , åäö.lekintepls.se . i have no idea phenomena called, i'm sorry if duplicate. this notation called punycode or idna (internationalizing domain names in applications). you can use idn_to_utf8 , idn_to_ascii convert between 2 notations.

ruby - Iterating through nested hashes named using strings -

i'm having trouble iterating through series of nested hashes, , think because inner hashes named strings. unfortunately, cannot change these names. here generic hash of kind working with: hash = "name" => { "stuff" => "value", "key" => "value", }, "name" => { "stuff" => "value", "key" => "value", }, i'm trying write program print fields labelled "name" values, within, when called names of keys. right now, stuck hash.each |key, value| puts key key.each |stuff, info| puts info if category == "stuff" end end but gives error each not recognized method key, is, think, because computer treating string due naming. have ideas how can proceed here (without changing names of keys)? as @meager says - sub-hash in value. try this hash.each |key, sub_hash| puts key sub_hash.each |category, info|

javascript - Need help Converting a jQuery event to a Drupal Behavior -

i have drupal 7 web site using jquery animations fadein div tags. need event capture fadein when completed. have found sample jquery example need to, have not been able convert drupal 7 behavior , i'm not quite sure might missing. fiddle example below drupal js file, fadeinevent.js . drupal.behaviors.fadeinevent= { attach: function (context, settings) { var _old = jquery.fn.fadein; jquery.fn.fadein = function() { var self = this; _old.apply(this.arguments).promise().done(function(){ self.trigger('fadein'); }); }; jquery('.tab-pane').bind('fadein', function() { alert('fadein done.'); }); } }; in above js code, never alert fadein has finished on item have selected. firs of all, while using jquery in noconflict mode, may use closure access $ (function($) { // jquery code using $ object. }(jquery)); regardin

php - Magento: how to use removeItem for js files added by extension programatically -

i have 3rd party extension adding js in via observer: <?php class anowave_owl_model_observer extends mage_core_model_abstract { public function dispatch(varien_event_observer $observer) { if (mage::app()->getlayout()->getblock('owl') && mage::app()->getlayout()->getblock('owl')->getslider()) { $format = mage::app()->getlayout()->getblock('owl')->getformat(); if ($format instanceof anowave_owl_block_format) { $format->addcss()->addjs(); } } return $this; } } where addjs defined in block class as: public function addjs() { $script = 'js/jquery-1.11.0.min.js'; mage::app()->getlayout()->getblock('head')->additem('skin_js', $script); } rather hack module, i'm trying remove loaded jquery via removeitem i.e. <default> <reference name="head&

"Unable to activate" ruby gem: dependencyissue -

i'm noob run gem dependencies. error when trying run ruby program .rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/specification.rb:2064:in `raise_if_conflicts': unable activate familysearch-0.4.2, because faraday-0.9.1 conflicts faraday (~> 0.8.4), multi_json-1.11.2 conflicts multi_json (~> 1.5.0) (gem::loaderror) in trouble shooting, installed bundler. here lock file looks like: gem remote: https://rubygems.org/ specs: mini_portile (0.6.2) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) rack (1.6.4) platforms ruby dependencies faraday (~> 0.9.1) nokogiri rack (~> 1.1) bundled 1.10.5 i found similar stuff on webs , solutions. unfortunately, none of these worked me. thank looking :) the gem you're having issues with, familysearch-0.4.2, hasn't been updated since march of 2014. hence, it's dependent on old gem versions. i'd recommend submitting issue gem created, jimmyz, on github via https://githu

php - Silex framework: using both OAuth and Basic authentication -

in current silex project realize login via oauth , basic login both. oauth, using silex extension ( https://github.com/gigablah/silex-oauth ). unfortunately, have problems integrating basic login. thoughts have create custom user provider provides both oauth , password via db, don't know how realize really. at point, have ugly mixture of 2 user providers. me, logic, not work. think off track, nice, if can give me tips - trying few days now... my user provider: <?php namespace core; use symfony\component\security\core\user\userproviderinterface; use symfony\component\security\core\user\userinterface; use symfony\component\security\core\user\user; use symfony\component\security\core\exception\usernamenotfoundexception; use symfony\component\security\core\exception\unsupporteduserexception; use doctrine\dbal\connection; class userprovider implements userproviderinterface { private $conn; private $oauth; public function __construct($oauth = null) { global $app;