Posts

Showing posts from August, 2015

r - Error in read.table duplicate row.names -

when tried read following table dataframe (data100) by: data100 <- read.table(header=true, text=' verb_object session_id 1: ba31c1cc63e5043483fae25f085e25e5 insert 41595370 2: bece6374d91d47e6285efdeba6d65bb9 database 41595371 3: 26d695c8ca82caffdf985201f3aa44d7 update 41595282 4: 26d695c8ca82caffdf985201f3aa44d7 update 41595282 5: 2bc5a4199a0dda16fa17a9ca1aa17c02 database 41595373 6: 6d944d54c54ed75d487288fe1505bb59 insert 41595368 ') following error: error in read.table(header = true, text = "\n verb_object session_id\n ba31c1cc63e5043483fae25f085e25e5 insert 41595370\n bece6374d91d47e6285efdeba6d65bb9 database 41595371\n 26d695c8ca82caffdf985201f3aa44d7 update 41595282\n 26d695c8ca82caffdf985201f3aa44d7 update 41595282\n 2bc5a4199a0dda16fa17a9ca1aa17c02 database 41595373\n

javascript - How to create a custom circle with arc method? -

Image
i want customize arc() function able make own circle, can't draw flattened cicrle. how can this? var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.beginpath(); ctx.arc(100, 75, 50, 0, 2 * math.pi); ctx.stroke(); <canvas id="mycanvas" width="200" height="150" style="border:1px solid #d3d3d3;"></canvas> arc piece of circle. use scale transform circle ellipse: edit: use save , restore keep canvas state. keep line-width constant. var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.linewidth=5; ctx.save(); ctx.beginpath(); ctx.scale(2,1); ctx.arc(50, 75, 40, 0, 2*math.pi); ctx.restore(); ctx.stroke(); <canvas id="mycanvas" width="200" height="150" style="border:1px solid #d3d3d3;"></canvas>

java - Removing remote Git branch using JGit -

i trying remove remote branch called test . don't errors while running code remote branch not getting removed. 'ans' destination including branch id. this code worked me when used full branch. must have changed because doesnt work more. git.branchdelete().setbranchnames(ans).setforce(true).call(); refspec refspec = new refspec() .setsource(null) .setdestination("refs/remotes/origin/test"); git.push().setrefspecs(refspec).setremote("origin").call(); assuming 'ans' full branch name of local branch e.g. refs/heads/test branchdelete() code looks ok. but destination of ref spec pased push command should denote name of branch referenced on remote end. in case refs/heads/test refspec refspec = new refspec().setsource( null ).setdestination( "refs/heads/test" ); or in short refspec refspec = new refspec( ":refs/heads/test" );

android - App Not Responding on click of image -

i working on application, , when click on image app stop responding. can't figure out issue is below click listener cause app not responding holder.ivlike.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { log.d("logfavourite", "like onclicklistener"); log.e("loglike", "count: " + holder.tvnewscountlike.gettext().tostring()); if (!utils.isnewslikedorfaved(context, postsdata, true)) { like(postsdata.getnews_id()); utils.likeorfavnews(context, postsdata, true); // notifydatasetchanged(); holder.tvnewscountlike.settext("" + (integer.parseint(holder.tvnewscountlike.gettext().tostring()) + 1)); holder.ivlike.setimageresource(r.drawable.dark); } else {

html - I am just trying to pass some javascript value from function func() to the tag "p".But it's not happening.Can anyone help me with this? -

a part of html body: <div id="d"> <div class="imge"> <img src="meter.jpg" width="450" height="350" alt="" /> <h2>1234578 kwh</h2> </div> </div> this javascript function. function func() { document.getelementbyid("d").getelementsbyclassname("imge").getelementsbytagname("h2")[0].innerhtml="string" } is above syntax correct? thanks in advance the code in func() should document.getelementbyid("d").getelementsbyclassname("imge")[0].getelementsbytagname("h2")[0].innerhtml="string" as getelementsbyclassname returns array

java - Browser Cache Headers Change on Server (Spring MVC + tomcat) -

my spring mvc app works on localhost. have following bean set browser caches: public void addresourcehandlers(final resourcehandlerregistry registry) { // @formatter:off registry.addresourcehandler("/doc/**").addresourcelocations("/web-inf/doc/").setcachecontrol(default_browser_cache_control); registry.addresourcehandler("/style/**").addresourcelocations("/web-inf/style/").setcachecontrol(default_browser_cache_control); registry.addresourcehandler("/image/**").addresourcelocations("/web-inf/image/").setcachecontrol(default_browser_cache_control); registry.addresourcehandler("/javascript/**").addresourcelocations("/web-inf/javascript/").setcachecontrol(default_browser_cache_control); registry.addresourcehandler("/plugin/**").addresourcelocations("/web-inf/plugin/").setcachecontrol(default_browser_cache_control); registry.addresourcehandler("/**&q

what should be the DDS communication structure? -

i have 2 exiting c++ project have sender , receiver. connected udp socket connection , build through cmakefile.txt root |→ sender | |→ src | |→ include | |→ cmakefile.txt |→ receiver | |→ src | |→ include | |→ cmakefile.txt |→ cmakefile.txt now want change udp dds context idl root |→ sender | |→ src | | |→ publisher.cpp | |→ include | |→ cmakefile.txt |→ receiver | |→ src | | |→ subscriber.cpp | |→ include | |→ cmakefile.txt |→ cmakefile.txt root |→ sender | |→ src | |→ include | |→ cmakefile.txt |→ receiver | |→ src | |→ include | |→ cmakefile.txt |→ ddscom | |→ src | | |→ publisher.cpp | | |→ subscriber.cpp | |→ include | |→ cmakefile.txt |→ cmakefile.txt what should structure? project structure (source files): the project structure present seems reasonable. in

git - Why there is not function name after @@ when I use jgit to get difference? -

when use jgit acquire difference between 2 files, can deference this: diff --git a/src/core/ngx_output_chain.c -wsrc/core/ngx_output_chain.c index 554fe1b..6bb463a 100644 --- a/src/core/ngx_output_chain.c +++ -wsrc/core/ngx_output_chain.c @@ -377,8 +377,9 @@ dst->in_file = 0; } but there not function name after @@ use git diff. how can function name when use jgit? there's no function name in diffs produced jgit because, well, feature not supported jgit . relevant lines org.eclipse.jgit/src/org/eclipse/jgit/diff/diffformatter.java : protected void writehunkheader(int astartline, int aendline, int bstartline, int bendline) throws ioexception { out.write('@'); out.write('@'); writerange('-', astartline + 1, aendline - astartline); writerange('+', bstartline + 1, bendline - bstartline); out.write(' '); out.write('@'); out.write('@'); out.write

node.js - How to test javascript function independently with mocha chai and sinon? -

i new unit testing , have been reading few tutorials practice javascript. use silly example explain problem. let's john needs go school , before knowing if he's ready go has check if has bag , headphones. called following function: john.isreadytogo; the implementation of isreadttogo() function character object follows: characher.isreadytogo = function() { return this.hasbag() && this.hasheadphones(); } characher.hasbag = function() { // return true or false } characher.hasheadphones = function() { //return true or false } now, let's want test function. in unit testing recommended test functions without them being affected other functions. means in case have test 3 functions character.isreadytogo() function need have mock values this.hasbag() , this.hasheadphones(). right? if so, give me hint on how can mock these 2 values? here's example: let character = {}; character.isreadytogo = function() { return this.hasbag() &

osx - EventMonitor .LeftMouseDownMask Type of expression is ambiguous without more context -

i learning make status bar application xcode using swift 2. have completed tutorial , on line eventmonitor = eventmonitor(mask: . | .rightmousedownmask) { [unowned self] event in , .leftmousedownmask gives me error saying type of expression ambiguous without more context . how fix type of expression issue? here appdelegate.swift file: import cocoa @nsapplicationmain class appdelegate: nsobject, nsapplicationdelegate { @iboutlet weak var window: nswindow! //event monitering var eventmonitor: eventmonitor? /////////////////// let statusitem = nsstatusbar.systemstatusbar().statusitemwithlength(-2) let popover = nspopover() func applicationdidfinishlaunching(notification: nsnotification) { if let button = statusitem.button { button.image = nsimage(named: "statusbarbuttonimage") button.action = selector("togglepopover:") } popover.contentviewcontroller = quotesviewcontroller(nibnam

ember.js - Emberjs 2 remove CORS and CSP -

Image
i'm trying emberjs 2 , found problem making ajax requests. have read lot of questions on stackoverflow , still can't resolve problem. access emberapp http://localhost:4200 , api server(php) in http://localhost . below screen shoot of console. what should step step? can me please? thanks in advance. routes/users.js import ember 'ember'; export default ember.route.extend({ model(){ console.log($.getjson('http://localhost/api')); } }); environment.js: module.exports = function(environment) { var env = { /*......*/ contentsecuritypolicy:{ 'connect-src':" 'self' http://localhost ", 'font-src' : " 'self' http://localhost " } /*......*/ }; this in php localhost/api/index.php: <?php header("access-control-allow-origin: *"); $array = array( 'name'=>"firstname", 'lastname' => 'lastname&#

html - Why reset button does not work here? -

in below html code, <h1>our contact form</h1> <hr> <form action="process_form.php" method="get"> <p> title: <input type="radio" name="title" value="mr"> mr <input type="radio" name="title" value="mrs"> mrs </p> <p> first name:<br> <input type="text" size="15" name="first_name"> </p> <p> sur name:<br> <input type="text" size="15" name="surname"> </p> <p> gender: <select> <option value="select">select gender</option> <option value="male">

Python define class functions in seperate py file -

i working on project deals data analysis. in order simplify process of finding , modifying functions, have decided put functions of similar purposes in different py files. issue comes in when functions in 1 py file require functions work. think can solve issue working class. demonstrate solution trying implement, have 3 files: a.py def a1(self): self.var=3 def a2(self): self.b1(4) b.py def b1(self, x): self.var=x def b2(self): self.a1() testclass.py class test(object): def __init__(self): self.var=0 b import * import * a=test() print a.var a.a1() print a.var a.a2() print a.var a.b2() print a.var this want python unhappy me importing these 2 py files in fashion. in c++ prototype functions, forward declaration, , place definitions in file , have no issues. proper way define functions class in py file class definition not in? use mix-in classes: # in a.py class a(object): def a1(self): self.var=3 def a

git - How to logout / switch accounts in Sourcetree -

Image
after installing sourcetree, prompted log atlassian account. however, once logged in, there no logout option log out or switch accounts. how do this? after installing sourcetree, prompted log atlassian account. however, once logged in, there no logout option log out or switch accounts. to this, close sourcetree navigate <username>\appdata\local\atlassian\sourcetree\ delete accounts.json after making backup. restart sourcetree. you should see following dialog , prompted login atlassian account. note: i'm using windows 10, assume same other systems.

javascript - TinyMCE Custom Elements with a ' : '? -

so i'm looking allow thymeleaf tags inside tinymce editor (using angular-ui-tinymce if matters) i understand basic format extended_valid_elements : 'script[charset|language|type|src]' but how use allow things like <p th:text="..."> //or// <img th:src="..."/> before asks, yes necessary have both tinymce , thymeleaf, , no don't need thymeleaf work inside tinymce, need editor stop stripping tags. try putting in tinymce configuration: valid_elements: "*[*]"

arrays - PHP Given increasing numbers in this order, calculate all possible combinations -

the problem simple, giving me headache, have example 4 numbers array, can have 20 numbers. given in following order: [1] [2] [4] [5] i need obtain combinations of numbers, except numbers can't permuted, order maintained, i'll give example of i'm trying obtain: [1] [ ] [4] [5] [1] [2] [ ] [5] [ ] [2] [4] [5] [ ] [ ] [ ] [5] , [ ] [ ] [ ] [ ] the resulting array contain sub arrays of resulting numbers update: empty arrays optional, [1] [4] or [2] [4] [5] would ok also, less complications. what want can done quite easily, if realize want accomplish in fact recursive. each subpart need make choice: add space, or add number our list. function wonkypermutations( $numbers ) { return wonkypermutationswithspaces( array(), $numbers, count( $numbers ) ); } function wonkypermutationswithspaces( $prefix, $numbers, $maxlength ) { if( $maxlength == 0 ) { //we can't add

css - How to overlap Navigation Menu over slide image -

am trying make menu list overlap slide image using position absolute can't work out. when try change position, menu mix up. slide image relative , menu list absolute. <!doctype html> <head> <title>quantum pc shop</title> <link rel="stylesheet" type="text/css" href="quantumpcshop.css"> <link rel="stylesheet" type="text/css" href="mangapage.css"> <script src="jquery-2.1.4.min.js"></script> <link href="owl.carousel.css" rel="stylesheet"> <link href="owl.theme.css" rel="stylesheet"> </head> <body> <!--<<<<<<<<< nav menu >>>>>>>>>>--> <center> <div class="bodynav2"> <div class="menu"> <ul id="css3menu

c++ - __declspec (dllexport) custom type variable -

i'm working on visual studio solution multiple projects (visual studio 2013). 1 project generating .dll file, other projects use .dll file , generate .exe files. when export standard type variable works fine. in case if want use custom defined type compilation error. here example // dll.cpp #define dllexport __declspec (dllexport) dllexport int maxpacksize = 20; // custom type struct dllexport header { int m_data; // data }; dllexport header qhead = { 100 }; // exe.cpp #define dllimport __declspec (dllimport) dllimport extern int packetsize; // ok struct dllimport header; dllimport extern header qhead; // leads error when use qhead in exe.cpp compilation error on line. error error c2027: use of undefined type 'header' what doing wrong? ideas? the error message compiler error (not linker error!). need define header prior first use. you move struct dllexport header { ... }; separate header file (e.g. dll.h ) , #include "

ruby on rails - How to test a class method in rspec that returns a model instance -

i'm trying test user model's class method #registered_but_not_logged_in(email) , grabs first user matches email has confirmed_at entry has never logged in (which i'm counting sign_in_count ). i'm using rspec factorygirl, plus shoulda-matchers v2.8. here's ruby: def self.registered_but_not_logged_in email self.with_email( email ).confirmed.never_signed_in.first end i've tested in rails console , know works expected it's not logic problem on end, i'm thinking i'm doing wrong in test: describe user # create @user describe ".registered_but_not_logged_in" "returns user matches provided email confirmed, has not yet signed in" @user.confirmed_at = 2.days.ago @user.email = "fisterroboto5893@mailinator.com" result = described_class.registered_but_not_logged_in("fisterroboto5893@mailinator.com") expect(result).to be_instance_of(user) end end in example, result ni

javascript - Filtering an array of objects by an object property within an object within the array -

i'm in nested hell of objects, here. feel there's answer this, can't quite figure out how phrase what's happening. so, giant array of objects rest return (something 450+ objects) comes loaded this: results[0] = { prop0: "string", prop1: "string", prop2: bool, prop3: object { prop0: "string" } prop4: "string" } i'm doing thing, first, i'm creating array of objects contains unique strings out of nested object's property, along count of number of times string appears within data set. i need, each unique string, create array of objects within original dataset results.prop3.prop0 matches string in collapsed array. confusing enough? from this: name: "joe", place: state { state: "new york", }, alive: false } to this: new york (120) joe - dead i've gotten far, using underscore.js: for(index in collapsed){ var details = _.where(results,{state: {state:

php - APN Working with One Device but Not with Multiple Devices -

i trying send push notification bunch of ipads , tested first device have. worked fine. tried expand include multiple devices, including own, , doesn't seem work (checked other relevant device holders make sure). device token information appears fine. wrong? maybe it's throttling issue? i tried rewrite following tutorial , issue still same: http://learn-php-by-example.blogspot.co.il/2013/01/working-with-apple-push-notification.html i no error in checkappleerrorresponse function. here code changes when changed 1 device many: foreach ($device_tokens $token) { $apple_identifier = '[censored]'; $payload = json_encode($body); $msg = pack("c", 1) . pack("n", $apple_identifier) . pack("n", $apple_expiry) . pack("n", 32) . pack('h*', str_replace(' ', '', $token)) . pack("n", strlen($payload)) . $payload; /* sends notification */ fwrite($fp, $msg); $this->checkap

windows - Batch STDOUT / STDERR redirection weirdness -

i'm running strange issue batch scripts , redirection logs while trying run scripts during provisioning phase of windows 2012r2 system. the general flow this: execute init.cmd: init.cmd: @echo off echo init - foo call start.cmd >start.log 2>&1 echo init - bar start.cmd: @echo off echo start - foo call test1.cmd >test1.log 2>&1 echo start - bar call test2.cmd >test2.log 2>&1 echo start - baz test1.cmd @echo off echo hello test2.cmd @echo off echo aloha what happens start.log looks like: start - foo then test1.log looks like: hello start - bar and test2.log looks like: aloha start - baz init - bar basically, appears once redirect stdout/stderr, redirects everything , until redirect elsewhere, @ point, goes new place. i've tried several ways of doing redirection, calling subroutines call :test1 >test1.log 2>&1 , directing those, or wrapping in >start.log 2>&1 (commands) , of same thing. i p

C++ Armadillo: mat initialization from vector<vector<double>> destroys data -

i'm trying initialize data vector of vectors armadillo mat. found site explaining how it: http://www.kaiyin.co.vu/2014/07/initialize-armadillo-matrix-with-std.html after printing vector of vectors , resulting mat came conclusion armadillo makes garbage of data. the main part of function: vector<vector<double>> c_mat(num_of_functions,vector<double>(num_of_points)); for(int j=0; j< num_of_functions; ++j) { for( int i=0;i<num_of_points; ++i) { c_mat[j][i]=(functions[j](points[i].x()));// shouldn't bother you, works. } } mat c(&(c_mat.front()).front(),num_of_points, num_of_functions); cout << c << endl << endl; for(int i=0; i< num_of_functions;++i) { print_vec(c_mat[i]); } print_ve(vector) function wrote prints vector. output: 1.0000e+00 0e+00 1.9965e+01 1.0000e+00

HL7 SIU Schedule Information -

we're working on hl7 interface right , we've setup mirth connect , receiving , parsing sample hl7 feeds (for siu messages, specially s12 think appointment schedule information). new working hl7, , since mentioned mirth thought ask couple of questions: one thing unsure of patient email address (if 1 exists in emr) in hl7 message. advice on piece of information should located if present? often times need determine department or clinic particular appointment in (e.g. in "orthopedics" or "general surgery". in sample messages i've seen things appointment having "x-ray" label in alongside provider name, location of department or clinic names - or information elsewhere? thanks help! first, mirth connect interface engine has nothing hl7 messages. need original hl7v2.x specification, can download hl7.org site, locate required fields. thus, siu^s12 has pid , pd1 segments conveying personal information, email included. same siu^s1

ios - Disable Max Zoom -

i'm making camera , has pinch zoom. i'm trying find way disable maximum zoom level. here code... func pinch(pinch: uipinchgesturerecognizer) { let device = avcapturedevice.defaultdevicewithmediatype(avmediatypevideo) let pinchvelocitydividerfactor:cgfloat = 10 if pinch.state == uigesturerecognizerstate.changed { { try device.lockforconfiguration() let desiredzoomfactor = device.videozoomfactor + atan2(pinch.velocity, pinchvelocitydividerfactor) device.videozoomfactor = max(1, min(desiredzoomfactor, device.activeformat.videomaxzoomfactor)) device.unlockforconfiguration() } catch { // handle error return } } } is there anyway not have camera have max zoom snapchat? thanks!

algorithm - Augmented interval tree -

i'm trying implement augmented interval tree using balanced binary search tree ordered "'low' values of intervals". in plain old search trees, when trying insert key present in tree, common ignore duplicate (no insertion). but when storing intervals, might have (1,2) , (1,3) have same 'low' value distinct. how deal duplicate 'low' values in augmented interval trees? mean, should allow insertion of multiple same 'low' values? in order? , how search through tree if there duplicate keys? the linked article suggests using high value of each interval secondary ordering. have total order on intervals, , can search normally. intersection queries don't require particular order among intervals same low value; become obvious once write code.

hyperlink - Is it possible to link to an external htm page? -

i have review box on website has 10 or more reviews. since it's text it's getting crawled , indexed. i'd rather didn't crawled , i've placed google:off , google:on idea discovered. may work googlebot crawl, if @ all. thinking if review box link text in external htm page, can css page, might prevent being crawled , still load space accordingly. don't know, possible?? response. i have found excellent solution on own, , share it... i created iframe review box , styled width, height, , border in css. within iframe tag put src="reviewstext.htm". created htm page , copied , pasted reviews. within head tag of page put... meta name="robots" content="noindex,nofollow" link rel="stylesheet" href="styles.css" type="text/css" also, reason iframe tag takes on same background color body of site. in case blue colour. wanted iframe have white background instead. css styling didn't seem work sty

rest - Web API oData - Should I forget about view models? -

ive been working mvc while , used creating view model class every mvc view. trying out web api , think may hung on mvc mentality. relationship looks this: public class supplier { public int id { get; set; } public string title { get; set; } public virtual icollection<supplierproduct> supplierproducts { get; set; } } public class product { public int id { get; set; } public string title { get; set; } public virtual icollection<supplierproduct> supplierproducts { get; set; } } public class supplierproduct { public int id { get; set; } public string title { get; set; } public int supplierid { get; set; } public virtual supplier supplier { get; set; } public int productid { get; set; } public virtual product product { get; set; } } i working on creation of supplier in create form user able select multiple products exist. in mvc, post view model looks this: public class suppliercreateviewmodel { public string ti

docker - Bluemix IBM Container with Mongodb connection failed -

i've been trying prepare image containing mongodb in docker container following dockerfile: # dockerizing mongodb: dockerfile building mongodb images # based on ubuntu:latest, installs mongodb following instructions from: # http://d...content-available-to-author-only...b.org/manual/tutorial/install-mongodb-on-ubuntu/ # format: repository[:version] ubuntu:latest # format: maintainer name <email@addr.ess> maintainer name <my@gmail.com> # installation: # import mongodb public gpg key , create mongodb list file run apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7f0ceb10 run echo "deb http://r...content-available-to-author-only...b.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee/etc/apt/sources.list.d/mongodb-org-3.0.list # update apt-get sources , install mongodb run apt-get update && apt-get install -y mongodb-org # create mongodb data directory run mkdir -p /data/db # expose port 2701

Run Time error while performing Toast Application in Android -

11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/androidruntime: fatal exception: main 11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/androidruntime: process: com.example.tejeswar.project0, pid: 8051 11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/androidruntime: java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.tejeswar.project0/com.example.tejeswar.project0.mainactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'android.content.context android.content.context.getapplicationcontext()' on null object reference 11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/androidruntime: @ android.app.activitythread.performlaunchactivity(activitythread.java:2225) 11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/androidruntime: @ android.app.activitythread.handlelaunchactivity(activitythread.java:2388) 11-01 21:11:03.260 8051-8051/com.example.tejeswar.project0 e/and

javascript - Update: Errors with postCSS and Babel in Gulpfile -

goal i'm updating old gulpfile.js , used compiling sass css, i'm trying gulp following: sync browser, whip localhost server - done compile sass => css - done show javascript errors jshint - done compile es6 => es6 babel (working on) minify assets (working on) show project file size - done deploy index.html, style.css , images s3 (working on) watch files, reload browser when .scss or .html changes - done problem trying minify javascript , create scripts.min.js file, keeps adding suffix min every new minified javascript file. folder structure index.html gulpfile.js package.json .aws.json .csscomb.json .gitignore assets - css style.css style.scss --partials ---base ---components ---modules - img - js scripts.js - dist gulpfile.js // include gulp var gulp = require('gulp'); var postcss = require("gulp-postcss"); // of plugins var autoprefixer = require('autoprefixer'); var browsersync = require('brow

Rails to symbol problems? Error: undefined method `[]' for nil:NilClass -

background info: deal has many coupons (@freedeals contains coupons) , coupon belongs_to deal. controller: @freecoupons = coupon.where(discount: 100).order("created_at desc").page(params[:page]) @deals = deal.all this code below works want , finds title deal (hard coded in 2 testing purposes) <% @freecoupons.each |f| %> <%= @deals[2][:title] %> <% end %> but when switch on trying find title of deal based on coupons association through f.deal_id <% @freecoupons.each |f| %> <%= @deals[f.deal_id][:title] %> <% end %> it gives me error "undefined method `[]' nil:nilclass". not sure i'm missing here. symbol problem i'm missing? appreciated. in coupon model do belongs_to :deal then in controller, include deals using includes - ensure don't make n+1 query: @free_coupons = coupon.includes(:deal).where(discount: 100).order("created_at desc").page(params[:page])

CSS Bootstrap 3.0 in Scheduled Emails CF -

i trying create automatic email gets sent straight server. trying have bootstrap table appear in email. unable use plugins email creation if you're still using html, or doing wrong? have idea of how make bootstrap type table appear in email? <cfmail to="#sendto#" from="#sendto#" subject="overdue item" type="html"> <html> <link rel="stylesheet" type="text/css" href="js/vendor/datatables/bootstrap-3.3.5/css/bootstrap.min.css"/> <body> <h4>there overdue item in dealer work.</h4> <p> <cfif overduetextarea.recordcount 0> there no overdue items. <cfelse> <table> <thead> <th><b>item id</b></th> <th><b>date due</b></th> <th><b>qty</b></th> </thead> <tbody> <cfloop query="overduetextarea"> <tr>

swift - Convert dictionary containing `Any?` to `AnyObject`? -

i'm looking straightforward way of converting dictionary of type [string : any?] dictionary of [string: anyobject] . loop through elements individually, seems 'wrong' me. if try cast original dictionary, crash. let dict:[string : any?] = ["something" : "else"] // crashes fatal error: 'can't unsafebitcast // between types of different sizes' let newdict = dict as? [string: anyobject] looping correct, , swift encourages this. efficient , swift-like (*) approach is: var result = [string: anyobject]() (key, value) in dict { if let v = value as? anyobject { result[key] = v } } (*) isn't "swift-like" because includes anyobject , should never part of non-temporary data structure. proper swift implementation convert anyobject real type. note crash not appropriate , should open radar (bugreport.apple.com). as? should never crash this. should either nil or compiler failure.

java - How to store enums in Realm? -

how store java enum classes when using realm ? from documentation , seems realm yet support storing enums: field types realm supports following field types: boolean , byte , short , ìnt , long , float , double , string , date , byte[] . integer types byte, short, int, , long mapped same type (long actually) within realm. moreover, subclasses of realmobject , realmlist supported model relationships. there similar question asked objective-c , got answered here . none yet java though. without custom methods unfortunately cumbersome @ moment, can store string representation instead , convert to/from enum. public enum foo { foo } // v1: using static methods public class bar1 extends realmobject { private string enumvalue; // getters/setters // static methods handle enum values public static foo getenum(bar1 obj) { return foo.valueof(obj.getenumvalue()) } public static foo setenum(bar1 obj, foo enum) { return obj.setenumvalue(enum.tostri

c# - How to get and assign entire column form Database to individual button's text? -

i trying values of entire column in table , assign them individual button text. this have achieved far. string query = "select type service"; mysqlcommand command = new mysqlcommand(query, con); var reader = command.executereader(); if (reader.read()) { button5.text = reader[0].tostring(); button6.text = reader[1].tostring(); button7.text = reader[2].tostring(); button8.text = reader[3].tostring(); button9.text = reader[4].tostring(); button10.text = reader[5].tostring(); button11.text = reader[6].tostring(); button14.text = reader[7].tostring(); button15.text = reader[8].tostring(); button16.text = reader[9].tostring(); button17.text = reader[10].tostring(); button18.text = reader[11].tostring(); } con.close