Posts

Showing posts from January, 2012

eloquent - Can't access custom pivot element (Laravel framework) -

Image
i created relation between user , event. added pivot element 'part_sure' pivot table , updated models appropriately: now have problem accessing pivot element. if try this... ... doesn't display anything! no error no value. looking command... ... accessable in pivot element: as can see, part_sure element not there. my user model: my event model: i don't know why isn't working. tried google hour. happy if give me hint! you're calling events method user model, aren't showing user model. what user model like? did event model, need specify pivot column in user model. user model public function events() { return $this->belongstomany('radclub\event')->withpivot('part_sure'); } you may need edit radclub\event proper namespace.

r - Render images in datatables in shiny -

is there way render images in datatable in shiny ? if try adding tag paste(<img src="http://test.com/img/', x, '.jpg" height=52></img>', sep='') as part of column (in want show image) spits out html tag , not image. as @bunk mentioned, escape=false works embedding images in datatable.

scala - how to remove sub list -

how can remove occurrences of sublist list, eg list(1, 2, 3, 4, 5, 6, 7, 4, 8, 9, 10, 5).removesublist(4, 5) should remove occurrences of (4, 5) (in order!), returns list(1, 2, 3, 6, 7, 4, 8, 9, 10, 5) a recursive solution using indexofslice : def removesublist(l: list[int], sublist: list[int]): list[int] = l.indexofslice(sublist) match { case -1 => l case index => removesublist(l.patch(index, nil, sublist.length), sublist) } // of these print list(1 ,2 ,3): println(removesublist(list(1,2,3), list(4,5))) println(removesublist(list(1,2,3,4,5), list(4,5))) println(removesublist(list(4,5,1,2,3), list(4,5))) println(removesublist(list(4,5,1,2,4,5,3), list(4,5))) edited : (thanks @corvus_192) reverting using indexofslice version instead of using diff , ignores sublist order. (thanks @the archetypal paul) using patch cleaner removal of sublist

core data - How to tell why MagicalRecord update failed -

i trying figure out why failed: [defaultcontext mr_savetopersistentstorewithcompletion:^(bool success, nserror *error) { if(success) nslog(@"update successful"); else nslog(@"update failed: %@", error); }]; i "update failed" nil error... start looking? i suggest start looking @ repository of issues magicalrecord. don't use it, quick google search mr_savetopersistentstorewithcompletion turned this known issue , and one , hits number 3 , 4. relevant, didn't check versions or else. you wanted starting place, right ;-).

asp.net mvc - Google API Client Library freezing up in IIS when making request -

i have been using google api client library .net loading google analytics data application: recently though have found have started freezing completely. execute() command makes connection google server. it makes successful request : https://accounts.google.com/o/oauth2/token which returns : { "access_token" : "ya30.haklqsgzo2gnk5wxlxx9tltquyd9xkt7azxuqndy-khjucyrctn_xhip", "token_type" : "bearer", "expires_in" : 3600 } but never returns execute call. the same code in console app returns immediately, in iis never returning. in previous version worked fine (i'm not sure version changed). i have load user profile set true. what causing this? var service_account_pkcs12_file_path = @"c:\temp\googleanalytics-privatekey.p12"; x509certificate2 certificate = new x509certificate2(service_account_pkcs12_file_path, "notasecret", x509keystorageflags.machinekeyset | x509keystoragefla...

C++ Maze Solving algorithm segmentation fault -

the task create randomly generated maze , solve it, issue whenever recursively search maze exit, segmentation fault @ runtime. of cout debugging. the main file (where error persists) #include <string> #include <cmath> #include <cstdlib> #include "main.h" #include "maze.h" int main(int argc, char *argv[]) { // process command line arguments , seed random number // generator, if necessary unsigned int seed; if(argc == 4) { seed = static_cast<unsigned int>(atoi(argv[1])); cout << "initializing pseudorandom number generator seed " << seed << endl; srand(seed); } else if(argc > 4) { cout << "improper usage of main\n"; exit(0); } cout << "beginning execution\n"; // first couple of numbers don't seem quite random, // "prime pump" calling rand() twice ...

fiona - Installing geopandas on Python 2.6 -

this in continuation earlier question geospatial analytics in python i started new question keep 2 issues logically separate. i have trying install geopandas on python 2.6 surprisingly, geopandas installed geoseries doesn't work , needs package "fiona". followed instruction provided here i installed libraries required searching , following suggestions (including dev libraries thinking i'll .h files), stuck these 2 issues: https://github.com/toblerity/fiona after cloning git , python setup.py install on fiona, error: gcc -pthread -fno-strict-aliasing -o2 -g -pipe -wall -wp,-d_fortify_source=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -d_gnu_source -fpic -fwrapv -dndebug -o2 -g -pipe -wall -wp,-d_fortify_source=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -d_gnu_source -fpic -fwrapv -fpic -i/usr/include/python2.6 -c fiona/_geometry.c -o build/temp.linux-x86_64-2.6/fiona/_geometry.o gc...

java - QueryDSL to get any entities in a collection of another entity -

i'm using jpa hibernate , querydsl (v.4.0.5). have entity: package com.test.model.entity; @entity public class article { @id private long id; @manytomany(fetch = lazy, cascade = detach) private set<tag> tags; } how can find articles matching given set of tag s? think should start follows: public booleanexpression hastag(set<tag> tags){ final qarticle article = qarticle.article; return article.tags.any().eqany(ce); } where ce should collectionexpression . have no idea how set this. any solution? did try public booleanexpression hastag(set<tag> tags){ qarticle article = qarticle.article; return article.tags.any().in(tags); }

android - How to make whole screen scrollable in Viewpager Fragment -

i have grid view , listview(including pagination) in scrollview. this resulting individual scroll need whole screen scrollable pagination. tried use nestedlistview & expandableheightlistview not working properly. any suggestion grateful. enter codxml:: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.swiperefreshlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/swipecontainer" android:layout_width="match_parent" android:layout_height="match_parent"> <scrollview android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="wrap_content" android:cliptopadding="false" android:fillviewport="true" android:paddingbottom="75dp"> <relativelayout android:id="@+id/r...

javascript - Insert in loki js not working -

i'm working on ionic project need store data locally , i'm using loki js, created factory using loki js , initializing , i'm creating database , while inserting not working. according documentation https://rawgit.com/techfort/lokijs/master/jsdoc/collection.html can insert object or array. but either of them not passing values loki db created. how solve this? a sample code useful if can't insert object (and you're loading db existing file) sounds if you're trying access collection outside loaddatabase callback. lokijs supports bulk inserts passing array of objects.

javascript - Count No.of unique attribute occurances with respect to another attribute in Array of objects -

in below data set, want count number of akey respect each bkey. such every bkey how many unique akey there. if akey occurred bkey should not counted. var fdata2 = [ {sex: 'male', bkey: '121', userkey: '04', akey: '6e5fdb09-319f-4640-b241-2b12d350c027', date: 'fri jul 01 06:26:59 utc 2016', freq: 20, preferencelist: ['fashion','business','sports'], agegroup: 'less_than_15'}, {sex: 'male', bkey: '122', userkey: '01', akey: '6e5fdb09-319f-4640-b241-2b12d350c027', date: 'fri jul 01 11:59:28 utc 2016', freq: 22, preferencelist: ['business'], agegroup: 'between_25_35'}, {sex: 'female', bkey: '123', userkey: '01', akey: '6e5fdb09-319f-4640-b241-2b12d350c027', date: 'thu jun 30 11:59:28 utc 2016', freq: 26, preferencelist: ['housing'], agegroup: 'between_35_45'}, {sex: 'male', bkey: '121...

twitter bootstrap 4 - equal height to columns bootstrap4 -

i using bootstrap 4 , wanted know how leave columns of same height ? if possible without using flexbox compatible older browser ( bah !). thank you here if want use flexbox the css .row.is-flex { display: flex; flex-wrap: wrap; } .row.is-flex > [class*='col-'] { display: flex; flex-direction: column; } /* * , max cross-browser enabled. * nobody should ever write hand. * use preprocesser autoprefixing. */ .row.is-flex { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } .row.is-flex > [class*='col-'] { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } the html <div class="row is-flex...

spring - configure spring4 with hibernate5 -

i try configure spring version 4.3.1 hibernate 5 have got error when try create entity manager factory. my hibernate version 5.0.9.final" hibernate validator version "5.2.4.final" my dependencies hibernate-core 5.0.9.final hibernate-entitymanager 5.0.9.final hibernate-ehcache 5.0.9 hibernate-validator 5.2.4.final hibernate-jpa-2.1-api 1.0.0.final validation-api 1.0.0.ga this configuration : @configuration @enabletransactionmanagement public class jpaconfiguration { @value("classpath:hibernate.properties") private properties jpaproperties; @resource(name = "datasource") private datasource datasource; /** * enable exception translation beans annotated @repository */ @bean public persistenceexceptiontranslationpostprocessor exceptiontranslation() { return new persistenceexceptiontranslationpostprocessor(); } /** * @see read http://www.springframework.org/docs/reference/transaction.html */ @bean public jpatransactionmanage...

Android activity reopen after start a new activity -

i have activity called mainactivity calls new activity (tutorial): intent secondactivity = new intent(this, tutorial.class); startactivity(secondactivity); after calling startactivity, oncreate of mainactivity open again. why happens? migrated eclipse android studio, , issue did not happen on eclipse. @update1: the mainactivity first activity open on project. after call tutorialactivity. manifest.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.teste.animationxml" > <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.access_wifi_state"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:largeheap="true"...

Go http get crashes on retrieving high-latency resources -

i have panicking program intends illustrate issue of retrieving high-latency resources via golang's http client. does have clue why happening? go version go1.5.1 linux/amd64 package main import ("fmt" "net/http" "time" "net") func main() { i:=0; i<2000; i++ { start := time.now() client := &http.client{} // enough program crash /*client := &http.client{ transport: &http.transport{ dial: (&net.dialer{ timeout: 1 * time.second, keepalive: 0, }).dial, disablekeepalives: true, disablecompression: true, maxidleconnsperhost: 1, responseheadertimeout: 1*time.second, }, }*/ req, _ := http.newrequest("get", "http://mickle.com.au/wp-content/uploads/2015/03/11222.jpg", nil) req...

swift - Error: 'String' is not convertible to 'String!' -

mapview.rac_valuesforkeypath("usertrackingmode", observer: self).subscribenextas { // block handling i error 'string' not convertible 'string!' . suggestions may mean? i used think, string! same string , unwrapped string? ... xcode 7.3.1 swift 2.2 reactivecocoa 4.1.0 i think compiler reporting wrong error. you can simplify expression using let key: string! = "usertrackingmode" and use key instead of literal. that simplify expression , compiler print real error. type inferring complicated , when compiler doesn't find valid type combination, can show wrong error.

javascript - Redirect if session is not available node.js -

i trying write code route if session.user_id undefined redirect home page. reason redirect doesnt execute , mysql condition fired , crashes server because session.user_id undefined , cant load game without data. is there way use universal redirect on routes if session not available redirect login? router.get('/game', function(req,res) { console.log(req.session.user_id); if (req.session.user_id === "undefined") { res.redirect('/'); }else { var condition = 'userid = ' + req.session.user_id; projectx.allgamedata(condition, function(data){ var hbsobject = {heroes : data, logged_in: req.session.logged_in, isuser: req.session.isuser, isadmin: req.session.isadmin} res.render('game', hbsobject); }); }; }); you should ei...

bash - Pick files from folder, process, delete -

in linux shell, treat folder bag of files. there processes put files bag. there 1 process in either 1 of 2 following states: process document, delete it wait arbitrary document exist in folder, process it it not matter in order documents processed or name is. what unique process taking files folder likein bash? processing means calling program filename argument. note unique process not terminate until manually. you can use incrond , stands "inotify cron daemon". daemon runs in background , monitors directories specified in table. valid configuration can created with incrontab -e this open editor , type in directory , actions want watch, e.g., /path/to/observed/directory in_create,in_moved_to <command> $@/$# <command> command or script want execute if 1 of events ( in_create,in_moved_to ) triggered. $@/$# path file created or moved watched folder , passed <command> . need start watching folder. you have initialize incrond o...

d3.js - d3js update redraw stacked bar graph -

i trying make stacked bar graph through d3js , have update when new data passed through update function. call update function call graph , works fine. however, when change data , call again, erases "rect" elements graph (when console log data, appears passing through). how can make graph redrawn appropriately? have tried experimenting .remove() statement @ beginning, without data doesn't pass through when bars redrawn. function update(my_data) { svg.selectall(".year").remove(); var year = svg.selectall(".year") .data(my_data) .enter().append("g") .attr("class", "year") .attr("transform", function(d) { return "translate(" + x0(d.year) + ",0)"; }); var bar = year.selectall(".bar") .data( function(d){ return d.locations; }); bar .enter().append("rect") .attr("class", "bar...

vim-r tmux scrolling not working properly -

a few months ago set combination of vim-r-plugin+tmux on macbook air scrolling (using mouseterm inside simbl ). works fine; in particular, scrolling works both in vim editor , in adjacent r session. i trying same setup on macbook pro, scrolling seems work partially: it woks in vim editor, not inside r session. the 'scrolling' works inside r session typing leader+[ followed arrow key tedious cursor goes 1 row @ time (note: scrolling mouse doesn't work @ all) i using same .rprofile, .vimrc , .tmux.comf on both machines. puzzled difference coming from. any idea causing this?

javascript - How to concatenate an array of number into one total number? -

i'm trying take array of length of ints, , concatenate single number total added up. instance, if have array goes follows: [2, 2] want becomes [4]. i'm using loop generate array using .push() on checkboxes , require total add equation. i'm trying price array: for(var i=0; < toppings.length; i++){ // creates loop data if(toppings[i].checked) { //if checked storeextnames += products[productslist.selectedindex].extra[i].name + " "; storeextprice.push(products[productslist.selectedindex].extra[i].price); }//end if }//end loop you loop through array this: var arr = [ 1, 2, 3, 4, 5, 6 ]; while (arr.length > 1) { arr[0] += arr.pop(); }

Remove html autofocus use javascript/jquery -

here's full code: $('input').keypress(function(e){ var code = e.keycode || e.which, value = $(this).val() if (code==13 && value!=''){ $('.with-header').show() var secondarycontent = 'secondary-content', materialicons = 'material-icons', conllectiontitem = 'collection-item' $('ul').append('<li class='+conllectiontitem+'>\ <span class="words">'+value+'</span>\ <span href="#" class='+secondarycontent+'>\ <a class="'+materialicons+' done">done</a>\ <a class="'+materialicons+' delete">delete</a>\ <a class="'+materialicons+' edit">edit</a>\ </span></li>') //this empty input $(this).val(...

java - Need advice with nested if's -

i have attempted using nested if in following code. have initialized variables compiler telling me variable named 'bill' not initialized though has been. why compiler not recognizing value assigned variable? please see notes in code below. package killme; import java.util.scanner; public class kill_me { static scanner console = new scanner(system.in); static double premium_service = 55.00; static double premium_day_overtime_min = 0.20; static double premium_night_overtime_min = 0.15; static double regular_service = 30.00; static double regular_overtime_min = 0.40; public static void main(string[] args) { int acctnumber; double premiumdaymin; double premiumnightmin; double bill; double minutes; string name; string premium = "premium"; string regular = "regular"; system.out.println("what account number? "); acctnumber = console.nexti...

Using Ghostscript Add watermark to PDF for Print Only -

i creating program using ghostscript add watermark(stamp) on pdf file. want know, possible add watermark pdf display on print copy of pdf not on computer screen? i believe can creating optional content group has usage dictionary /print dictionary has printstate key value on. want /view dictionary viewstate key has value off. you create annotation watermark , have annotation part of optional content group created above. annotation print, not view. note consuming application decide whether viewer or printer. ghostscript, example, assumes viewer , uses viewstate determine visibility of optional content groups. you should able construct optional content groups , annotations using pdfmark operations. see adobe pdfmark reference more information.

python - IRC Bot, performance and scaling -

i have made simple irc bot myself in python works great, friends has asked me if bot can join irc channel too. irc channels active, twitch chat(irc wrapper), means lot of messages. want them use bot, have no idea how perform, first bot i've made. right code this: connect irc server & channel while true: receive data socket (4096, max data received @ once) data received what changes should make perform better? 1. should have sleep function in loop? 2. should use threads? 3. general dos , don'ts? thank reading post. threading 1 option doesn't scale beyond point (google python gic limitation). depending on how scaling want do, need multi-process (launch multiple instances). one pattern have pool of worker threads process queue of things do. there's lot of overhead creating , destroying threads in languages.

Is there a more efficient way to use assert with arrays in C? -

in 1 part of program need use assert test multiple arrays (5 sets total), , wondering if there's more efficient way besides doing right now, creating new array every time. fyi have assert.h @ beginning of program. void unittest3d(void){ double test1[3] = {0,0,0}; double test2[3] = {5,0,0}; assert(find3ddistance(test1,test2) - 5) < 0.001); double test3[3] = {-2, -3, 3.4}; double test4[3] = {-2, -3, -1.6}; assert(find3ddistance(test3,test4) - 5) < 0.001); double test5[3] = {-2, -3.2, -5}; double test6[3] = {3, 1.8, 0}; assert(find3ddistance(test5,test6) - sqrt(75)) < 0.001); return; }

reactjs - Can I use css-modules with LESS + nesting? -

the documentation on css-modules pretty sparse, i'm not sure if can or not. this article says way i'd style button normal , error states this: .common { /* font-sizes, padding, border-radius */ } .normal { composes: common; /* blue color, light blue background */ } .error { composes: common; /* red color, light red background */ } but i'd prefer write this: .common { /* font-sizes, padding, border-radius */ &.normal { /* blue color, light blue background */ } &.error { /* red color, light red background */ } } like i've done, without introducing new composes syntax. think it's more clear styles build on top of other styles if can nest them in code. but don't know exported css-modules? examples give simple class name selectors. have no idea .common.normal exported as, or .common > .normal ~ .strange ? have not use kind of css selector if use css-modules? i using less css modules, don't think way using ...

html - Why does everything but the side-menu adjust for a mobile screen? -

this website i'm updating, fonts , icons, images etc adjust screen size. reason side-menu doesn't appear on samsung s4, have scroll right find it. on desktop adjusts fine no matter how resize browser window. should mention using chrome on s4, tested on mobile "browser" app , works fine there. website even mobiletest website displays fine. when test on chrome mobile browser, or colleagues iphone 5s browser, menu pushed side , have swipe left see it. here jsfiddle reason menu doesn't appear there. edit made menu fixed screen scrolls vertically user. html: <!-- navigation --> <a id="menu-toggle" href="#" class="btn-dark btn-lg toggle"><i class="fa fa-bars"></i></a> <nav id="sidebar-wrapper"> <ul class="sidebar-nav"> <a id="menu-close" href="#)" class="btn-light btn-lg pull-right toggle"...

html - Apache "localhost is currently unable to handle this request." php request -

i'm using apache 2.4 server on laptop running under windows 10. i’m having problem running piece of php code supposed show random numbers users tap in, know user not robot. below picture shows i’m talking about: the numbers have yellow background i'm referring. so, code have generating these number follows: <?php /** usage: <img alt="" rel="nofollow,noindex" width="50" height="18" src="php/captcha.php" /> $_session['captcha'] - use in script. supported link: util/captcha.php?w=100&amp;h=50&amp;s=30&amp;bgcolor=ffffff&amp;txtcolor=000000 **/ session_start(); @ini_set('display_errors', 0); @ini_set('track_errors', 0); header('cache-control: no-cache'); header('pragma: no-cache'); /** ********************************** @random generators [ln, n, l] /** ******************************* **/ function random($length=...

c# - WPF Binding not updating Visibility -

i'm having trouble binding visibility of grid. i've had projects i've done before , have tried replicate same coding used previously, , i've searched around , added in bool visibility converter based off other articles still nothing. all trying far in project have set of options provided user. when select 1 option either bring sub-options or take them proper area. have binding set bool object , have @ times created little message boxes , others let me know if program reaching everywhere. every messagebox along way, appears reaching every piece of code. can shed light on doing wrong or point me in correct direction? converter in windows.resources (edited show code in windows.resources) <window.resources> <style targettype="{x:type button}"> <setter property="fontsize" value="15"/> <setter property="fontweight" value="bold" /> <setter property="hei...

javascript - Angular Directive inside d3 node -

Image
i've got simple version of tree layout ( https://bl.ocks.org/mbostock/4339083 ) on angular app. however, i'm trying replace "text" node angular directive. how can achieve this? instead of .text(function(d) { return d.name; }) , i'm trying compile directive takes in d.name parameter. versions : angular : 1.5.3 d3 : 3.5.17 update: compile works great, injects html it, doesn't show in svg. when hover on user-node node in dom, doesn't highlight on page... your questions little vague perhaps use $compile ? var nodeenter = node.enter().append("g") .attr("class", "node") .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }); nodeenter.each(function(d){ var el = $compile( '<node-directive></node-directive>' )( scope ); angular.element(this).append(el); }); edits i worked example. seems svg doesn...