Posts

Showing posts from June, 2010

java - How do you create Swing "dropdown" buttons? -

this question has answer here: splitbutton in java 2 answers how netbeans create buttons have little down arrow right of main button when pressed brings menu? netbeans "debug project button 1 example. 2 separate jbutton components? how constructed? it's called jcombobox believe. can find documentation on how make comboboxes here: https://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html

swift - My iOS app cannot locate my plist in code -

Image
i doing this tutorial there plist in provides datasource collectionview data. have plist in folder called resources: the name property of plist items name of images displayed, why names not correspond fruit, images of clothing icons. function here not make past first if statement. why be? func populatedata() { if let path = nsbundle.mainbundle().pathforresource( "fruits", oftype: "plist") { if let dictarray = nsarray(contentsoffile: path) { item in dictarray { if let dict = item as? nsdictionary { let name = dict["name"] as! string let group = dict["group"] as! string let fruit = fruit(name: name, group: group) if !contains(groups, group){ groups.append(group) } ...

javascript - Why is my variable referencing the global scope variable? -

i tried write function finds possible permutations given array of numbers. here code. var perm = []; var usedchar = []; function findallpermutations(arr) { (var = 0; < arr.length; i++) { var x = arr.splice(i,1)[0]; usedchar.push(x); if (usedchar.length == 3) { perm.push(usedchar); } findallpermutations(arr); usedchar.pop(); arr.splice(i,0,x); } } findallpermutations([1,2,3]); console.log(perm); //-> [[],[],[],[],[],[]] i expect get: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] can explain why i'm not getting answer? you're using same array holds intermediate result storage algorithm , things getting mixed up. need either separate 2 or make sure clone usedchar array before pushing perm array. plunker: http://plnkr.co/edit/hq6q8fo8s0k21cisqkvt var perm = []; var usedchar = []; var = []; function findallpermutations(arr) { (var = 0; < arr.length; i++) { var x = arr.splice(i,1)[0]; ...

Is there a Url-redirect Service without Hash? -

iam looking url redirect service without generating hashes. simple "go.to/?url=google.com". because dont want generate hashes before , host detection ban host/ip maybe. or there shortener-service can generate hashes myself without api request possible delicio.us api years ago? ok, found service redirect without detecting host/ip: http://nullrefer.com/?http:/google.com

java - queuing networking formula -

http://postimg.org/image/w79si81zn/ hi!, i'm trying code formula posted on picture above, i'm having weird value, wondering if y'all can take @ code see what's i'm missing. import java.util.*; public class queuing{ //get factorial int m = 20;//20 double b = .2; double p = .02; double prob = .05;//.5 int notque = 0; int not = 1-notque; double b = 0; public static int factorial(int n) { if (n <= 1) { return 1; } else { return n * factorial(n-1); } } public string math(){ while((1-notque) > prob){ b += .2;// notque = 0; double n = math.round(b/b); for(int = 0; i<=n ;i++ ){ double mfact = factorial(m);// double nfact = factorial(i);// double msns = factorial(m-i);// double ncr = (mfact)/(nfact*msns) ;//;nfact*factorial((int)msns) double pow1 = math.pow(...

javascript - JS not working correctly -

i have html page, 2 buttons: 1 onclick="reshuffle('c') on it, , other onclick="reshuffle('bw') . then, have javascript: function reshuffle(set) { if (set = "bw") { console.log("shuffling b&w pictures..."); var blackandwhite = shuffle(resize([], 20)); // second arg # of images in folder go(blackandwhite, "bw"); } if (set = "c") { console.log("shuffling color pictures..."); var color = shuffle(resize([], 0)); // second arg # of images in folder go(color, "c"); } function resize(array, size) { (i = 1; < size + 1; i++){array.push(i)} return array; } function shuffle(array) { var = array.length, j = 0, temp; while (i--) { j = math.floor(math.random() * (i+1)); temp = array[i]; array[i] = array[j]; array[j] = temp; ...

Json sent from android to php defaults to index.php -

i new php. have android app sends json string myphp.php gets redirected index.php . normal behavior? how can go around that? code url url= null; httpurlconnection urlconn; url = new url ("http://192.***.*.**/myserver/myphp.php"); urlconn = (httpurlconnection)updateurl.openconnection(); this content of myphp.php. <?php /* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ //include '/index.php'; $json = file_get_contents("php://input"); $decoded = json_decode($json, true); $lat = $decoded['lat']; $lon = $decoded['lon']; sendid($pasid, $lat, $lon); function sendid($tokenid, $lat, $lon) { //request url $url = 'https://android.googleapis.com/gcm/send'; //your api key $apikey = 'key'; //payload data $data = array('lat' ...

sql - How can I produce rows that sum subgroups of rows, without grouping? -

let's have table this: id income expenses ------------------------- 1 $1000 $200 1 $2000 $400 2 $500 $200 2 $100 $60 i'd add 1 row per id sums id's income , expenses. example: id income expenses ------------------------- 1-sum $3000 $600 1 $1000 $200 1 $2000 $400 2-sum $600 $260 2 $500 $200 2 $100 $60 is possible sql? read on , partition that'll add new column, not new row. might union best way go here? using group by : sqlfiddledemo create table tab(id int , income int , expenses int); insert tab(id, income, expenses) values (1, 1000, 200),(1, 2000, 400),(2, 500, 200),(2, 100, 60) select id, [income] = sum(income), [expenses] = sum(expenses), [grouping_level] = grouping_id(id, income, expenses) /* 0 - actual data , 3 - group based on column income, expenses*/ tab group grouping sets ((id), (id,income, expens...

javascript - AngularJS Test a Factory with Mocha -

i new mocha , angularjs unit testing want test application using mocha. have basic language tests working, cannot run tests against applications factory or controller. i have following basic files. apps.js aangular.module('myapp', []); file1.js angular.module('myapp').factory('factory1' ...); file2.js angular.module('myapp').factory('factory2' ...); angular.module('myapp').factory('controller' ...); describe('main test', function() { var factorytotest; beforeeach(module('myapp')); beforeeach(inject(function (_factory_) { factorytotest = _factory_; })); describe('factory2', function () { it('should return "unknown"', function () { game = {}; expect(new factory2(game)).to.equal('unknown'); }); }); }); when run test, generates error, , not sure fix work. error: message: object not f...

java - How do you remove the first and the last characters from a Multimap's String representation? -

i trying output result of multimap.get() file. [ , ] characters appear first , last character respectively. i tried use program, doesn't print separators between integers. how can solve problem? package main; import java.io.file; import java.io.filenotfoundexception; import java.io.printwriter; import java.io.unsupportedencodingexception; import java.util.arraylist; import java.util.collections; import java.util.list; import java.util.scanner; import com.google.common.collect.arraylistmultimap; import com.google.common.collect.maps; import com.google.common.collect.multimap; public class app { public static void main(string[] args) { file file = new file("test.txt"); arraylist<string> list = new arraylist<string>(); multimap<integer, string> newsortedmap = arraylistmultimap.create(); try { scanner s = new scanner(file); while (s.hasnext()) { list.add(s.next()); } s.close(); ...

ios - How to ensure didSelectRowAtIndexPath opens correct View -

i know how send user new cell after select cell if order of cells change because retrieving data parse each new cell, row number changes. how ensure user sent correct page when select cell? i'm using know there's got better solution hardcoding every possible option.. any advice? func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { if indexpath.section == 0 && indexpath.row == 1 { self.performseguewithidentifier("tosettingspage", sender: self) } } for understanding of questions, suggest use nsmutabledictionary store user info data, , on didselectrowatindexpath function, use indexpath find correct user info.

android - How to draw squares instead of circles in MPAndroidChart? -

how can draw square instead of circle on linechart in mpandroidchart ? linechart supports circles. but solution combine line- , scatterchart in combinedchart . use scatterchart draw squares use linechart without circles draw lines example of combinedchart here .

node.js - Pass data through to the view in Express -

i trying pass through result of query through view in express. query made using mongodb counts total points of collective users. when try pass count through variable, referenceerror: /sites/test/views/dashboard.ejs:76 which refers <%= totalpoints %> in ejs view. below code in app.js app.get('/dashboard', function(req, res) { user.find({}, function(err, docs) { console.log(docs); }); user.find({ points: { $exists: true } }, function(err, docs) { var count = 0; (var = 0; < docs.length; i++) { count += docs[i].points; } return count; console.log('the total # of points is: ', count); }); var totalpoints = count; res.render('dashboard', { title: 'dashboard', user: req.user, totalpoints: totalpoints }); }); any ideas how can pass query result through? node executes query asynchron...

SSH -D flag in config -

i'm using ssh direct local internet traffic remote machine, using following command: ssh -d 4321 -n -v user@server how add entry .ssh/config file can simple ssh user@server ? specifically, how map -d option it's config-equivalent? the equivalent .ssh/config entry -d option dynamicforward . takes same options -d , , applied on per-host basis. host server username user dynamicforward localhost:4321 requesttty no

Is is possible to call the child classes and the parent class from another python script dynamically -

class animal(self): def putdata(self, dict) # @ abc.abstractmethod def getsum(self, *args, **kwargs): pass class dog(animal): def display(self): # def getsum(self,count): # class cat(animal): def calculate(self): # def getsum(self,*dict): # all these class files in folder /username/pacagename/ , python script have call these 4 classes in /username/packagename/bin

selenium - How to do vertical scrolling in Android app using Python-Appium client -

i working on python , appium server. want automate app. there page called friend list consists large number of friends. want scroll friend list each , every contact. please how this. you can try : driver.execute_script("mobile: scrollto", {"element": <webdriver object element>.id}) more information problem here : https://discuss.appium.io/t/how-to-scroll-in-appium-using-python/1180/18

php - How can I get the name of the specified field in a result using mysqli functions -

function table($sql,$border) { $con = mysqli_connect("localhost","root","","dbit36"); $resource = mysqli_query($con,$sql); echo"<table border=0>"; for($i = 0; $i < mysqli_num_fields($resource); $i++) { echo "<td style='border:".$border."1px dotted;'><b><font color='990099'size='10'>".mysql_field_name( $resource, $i )."</b></font></td>"; } echo "</tr>"; while($row = mysqli_fetch_array($resource)) { echo "<tr>"; for($i = 0; $i < mysqli_num_fields($resource); $i++) { echo "<td style='border:".$border."px ridge;'>".$row[$i]."</td>"; } echo "</tr>"; } echo "</table>"; } i know using mysql function deprecate...

css - Media query not found in my style section -

Image
do have add link or file media queries work. when try use media query inline in .cshtml file red line under '@media' says "cannot resolve symbol media". in asp.net mvc project. when move media query it's own .css file works fine. media queries not allowed inline in asp mvc project? here solved it. @@media screen , (max-width:768px) { /* size 'xs' , below */ .searchresults { height: 100%; } i added 2 @ symbols.

double - Using swift to calculate with very small values expressed in standard form -

Image
i had long tedious homework calculate specific charge of first 20 elements' nuclei. being wishes not succumb typing in different numbers same formula on scientific calculator 20 times, tried code it. realised: swift hard use standard form natively small numbers seem cause problems i took 2 inputs of a, , z being believe called nuclide number , proton number respectively , applied them formula: using this, seemed cause problems value of e , m p , m e , , m n small , couldn't seem work them. yet scientific calculator can , hand. how swift? datasheet: http://filestore.aqa.org.uk/resources/physics/aqa-7408-sdb.pdf edit: my problem lied in fact not casting numbers correctly, believe caused them end being 0 in cases. question ended being rather pointless apologise for, i'll post solution cannot replicate original problem. you need cast each value double retain accuracy. after value of sc calculated i've formatted display more see on calculator. ...

ios - iPhone how can i apply a pdf file as image on a table view cell -

Image
i working on project in have put images on table view cells. possible put .pdf format files on table view cells image? i used following code: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (!cell) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier]; } // nsdictionary *menuattr = [menuitems objectatindex:indexpath.row]; // cell.textlabel.text = [nsstring stringwithformat:@"%@", [menuattr objectforkey:@"name"]]; if (indexpath.row ==0 ) { cell.imageview.image = [uiimage imagenamed:@"about us.pdf"]; cell.imageview.layer.cornerradius =cell.imageview.image.size.width/2; } if (indexpath.row == 3) { cell.imageview.im...

php - How to link external CSS and Script (assets) in Laravel 5.1 project -

hi guys new laravel , first project in laravel, had trouble linking assets(css & js) file on views.. did research found if use {{url::asset('assets/plugins/bootstrap/css/bootstrap.min.css')}} in laravel 5.1 work. did succeed when single link, when add other links.. <link rel="stylesheet" href="{{url::asset('assets/plugins/animate.css')}}"> <link rel="stylesheet" href="{{url::asset('assets/plugins/line-icons/line-icons.css')}}"> <link rel="stylesheet" href="{{url::asset('assets/plugins/parallax-slider/css/parallax-slider.css')}}"> <link rel="stylesheet" href="{{url::asset('assets/css/custom.css')}}"> the server denied access files in assets folder access forbidden! . .htaccess file code is.. <ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c> options -multiviews </ifmodule> rewriteengine on # redirect trai...

javascript - two columns - with one fixed -

Image
i have wordpress site utilizes bootstrap 3 framework. have set have a narrow column on left, larger column on right (that has posts. want left column stick in place while right column scrolls. $(document).ready(function() { var s = $("#nav"); var pos = s.position(); $(window).scroll(function() { var windowpos = $(window).scrolltop(); if (windowpos >= pos.top) { s.addclass("stick"); } else { s.removeclass("stick"); } }); }); .stick { position: fixed; top: 0; z-index: 100; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="indx-wrap" class="row"> <div class="col-md-3"> <div id="nav"> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. proin vitae sodales nunc, eu aliquet ex.</p> </div> </div> <...

Partial and duplicate records while sqoop import -

sqoop import resulting in duplicate/partial records when using following setting --query - custom query --split-by - non-integer column (char) --num-mappers - more 2 verified source data count 1000 records verified import data count 1923 records when using split-by , field non integer . sqoop uses textsplitter provides warning follows : warn db.textsplitter: if database sorts in case-insensitive order, may result in partial import or duplicate records warn db.textsplitter: encouraged choose integral split column. solution 1: use single mapper or 2 solution 2: use rank function in query , use --split-by on rank field solution 3: sort --split-by field in ascending order in query

python - How can I run two django projects through Apache webserver in Ubuntu 14.04? -

i able run 1 django project through apache server. have 2 projects: yota_admin_module , yotasite. apache conf file: /etc/apache2/sites-available/000-default.conf <virtualhost *:80> # servername directive sets request scheme, hostname , port # server uses identify itself. used when creating # redirection urls. in context of virtual hosts, servername # specifies hostname must appear in request's host: header # match virtual host. default virtual host (this file) # value not decisive used last resort host regardless. # however, must set further virtual host explicitly. #servername www.example.com alias /static /home/abhay/django-project/yota_admin_module/yota/static/ wsgidaemonprocess yota_admin_module python-path=/home/abhay/django-project/yota_admin_module:/usr/local/lib/python2.7/site-packages wsgiprocessgroup yota_admin_module wsgiscriptalias / /home/abhay/django-project/yota_admin_module/yota_admin_module/wsgi.py <directory /home/abhay/django-project/yota_admin_m...

background - How to send mouse events to a minimized form in c#? -

i try write simple tester tool, testing web site (win form, using webbrowser control). need send mouse click , keystrokes site. works when form on top, run tester in background. how can send mouse click, keystrokes minimized/background form? current mouse event code: [dllimport( "user32.dll", charset = charset.auto, callingconvention = callingconvention.stdcall )] public static extern void mouse_event( uint dwflags, uint dx, uint dy, uint cbuttons, uintptr dwextrainfo ); [flags] public enum mouseeventflags { leftdown = 0x00000002, leftup = 0x00000004, middledown = 0x00000020, middleup = 0x00000040, move = 0x00000001, absolute = 0x00008000, rightdown = 0x00000008, rightup = 0x00000010 } void mouseevent( uint flag, point p ) { p = caller.pointtoscreen( p ); cursor.position = p; mouse_event( flag, (uint) 0, (uint) 0, (uint) 0, (uintptr) 0 ); } public void sendmouseclick( point p ) { uint flag = (uint) mouseeventflags.left...

javascript - How to make use of recursion in preg_replace_callback -

i have javascript function (not plain javascript) function formatstring () { var args = jquery.makearray(arguments).reverse(); var str = args.pop(); return str.replace(/{\d\d*}/g, function () { return args.pop(); }); } that use format string e.g formatstring("{0} , {1}", "first", "second"); returns "first , second" i want replicate same functionality in php , have following function: function formatstring() { if(func_num_args() > 1) { $args = array_reverse(func_get_args()); $input = array_pop($args); } return preg_replace_callback('/{\d\d*}/', function() use ($args) { return array_pop($args); }, $input); } however, in case formatstring("{0} , {1}", "first", "second"); returns "first , first" unlike javascript version of function callback executes every match, php variation seems execute callback once. i considering making ...

eclipse - error: strings in switch are not supported in -source 1.6 (use -source 7 or higher to enable strings in switch) in Android Studio -

i have created 1 project in eclipse ,but converting project android studio project. when trying run converted project, getting "error: strings in switch not supported in -source 1.6 (use -source 7 or higher enable strings in switch)" in messeges tab of android studio my build.gradle file apply plugin: 'com.android.application' android { compilesdkversion 19 buildtoolsversion "23.0.0" defaultconfig { applicationid "com.pcs.sliderringtineproj" minsdkversion 10 targetsdkversion 19 } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } } compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } dependencies { compile project(':facebooksdk') compile 'com.android.support:support-v4:19.1.0' compile 'com.android.support:appcompat-v7:20.+' co...

SQL - value for the last date -

Image
sounds easy guess of guys can't find solution due poor sql knowledge. i have request: first 3 columns margin can null i want create column last application margin rule: if margin null last value no null find. screenshot here: thanks lot use isnull / coalesce , subquery: select scope_enum_compete, margin, date_test, isnull(margin, ( select top 1 margin dbo.tablename t2 margin not null , t2.date_test < t1.date_test order date_test desc )) [last applicable margin] dbo.tablename t1

wpf - C# class properties enumerable -

i have problem enumeration of class. searched on internet , stackoverflow, i'm afraid limited experience c# limits me recognizing exact situation , solution. code have: public list<annotation> annotations = new list<annotation>(); public class annotation { public annotation(int pos, int x2, int y2, string artnr) { this.artnr = artnr; this.pos = pos; this.x2 = x2; this.y2 = y2; } public string artnr; public int pos; public int x2; public int y2; } public void add_anno(string artnr, int x2, int y2) { annotations.add(new annotation(0,x2,y2,artnr)); } after adding sever annotations want display them in wpf canvas object. problem can't loop through items in list. question method should use enumeration , how apply it? list contains both integers , string. tried use: system.collections.ienumerator ie = annotations.getenumerator(); while(ie.movenext()) { annotation test = ie.gettype().getprope...

java - org.hibernate.MappingException: <mapping> element in configuration specifies no known attributes -

when run code gives me exception: org.hibernate.mappingexception: element in configuration specifies no known attributes i not sure error occurs, can me solve this.. hibernate.cfg.xml <hibernate-configuration> <session-factory> <property name="hbm2ddl.auto">create</property> <property name="hibernate.dialect">org.hibernate.dialect.mysqldialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> <property name="hibernate.connection.url">"url"</property> <property name="hibernate.connection.username">"username"</property> <property name="hibernate.connection.password">"password"</property> <mapping resource="student.hbm.xml"/> <mapping/> student.java public class student { private string name; private int id; pu...

XSLT Transformation not working with xsl:incldue -

we using xml/xslt transformation using java. here loading book.xlst using following url. http://example.company.com/xslt/book.xslt book.xlst internally refers xslincludefile.xsl using xsl:include tag. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:for-each select="collection/book"> <xsl:apply-templates select="title"/> <xsl:apply-templates select="author"/> <xsl:apply-templates select="publisher"/> <br/> </xsl:for-each> </xsl:template> <xsl:template match="title"> <div style="color:blue"> title: <xsl:value-of select="."/> </div> </xsl:template> <xsl:include href=...

android - Pixate Freestyle library alternatives? -

we using pixate freestyle multiple projects right now, looks library no longer being developed. its functionality on android questionable (ex. custom fonts not working yet), , can't spend our time fixing it, therefore looking similar library, allows style elements css, working both ios , android. do guys know of similar libraries?

asp.net - link not working when putting colon in datanavigator field -

i facing strange problem. problem when puttting values in mail_subject column colon (:) link not working. can tell me doing mistake?my code given below: asp:hyperlinkfield datanavigateurlfields="delivery,group,mail_subject,data_period,delivery_status,ftpserver,ftp_location" datanavigateurlformatstring="mailsender.aspx?delivery={0}&group={1}&mail_subject={2}&data_period={3}&delivery_status={4}&ftpserver={5}&ftp_location={6}" text="delivery" datatextfield="delivery" tia. rafayel

java - Export to Excel for absolute path -

i'm trying export report excel. using poi i'm able store in path (say d:/reports) hardcoded in code. my requirement is, before report generation, ask path, user wants save report to. how achieve this? you cannot store file in user's computer without permission/action. 1)store generated file in container (tomcat's folder). 2)write file response content. 3) users get's prompt select location save file disk. 4) delete generated file after writing user's computer.

Photoshop pixels to Android dp -

i'm trying convert text dimension psd representation android dp format. on internet there resources explain dp, sp how convert them still don't understand do. need example case. let's have psd 3 lines of text different dimensions: 18px font - ? dp 21px font - ? dp 28px font - ? dp which dimensions choose handheld device if want maintain same apparent dimension? how make gui similar psd template? taken this thread px 1 pixel. sp scale-independent pixels dip (dp) density-independent pixels. use sp font sizes dp else from android developer +---------+-------------+---------------+-------------+--------------------+ | density | description | units per | density | same physical size | | | | physical inch | independent | on every screen | +---------+-------------+---------------+-------------+--------------------+ | px | pixels | varies | no | no | +---------+---...

javascript - Download PHP, HTML coded page in pdf format. -

i've 'download in pdf' button on page. page contains php , html code.i want download page pdf(not open in browser window). tried 1 code using jspdf coverts div contents pdf format not applying css , same formatting per original page. js code: <script type="text/javascript" src="https://parall.ax/parallax/js/jspdf.js"></script> var doc = new jspdf(); var specialelementhandlers = { '#editor': function (element, renderer) { return true; } }; $('#cmd').click(function () { doc.fromhtml($('#div-bill').html(), 15, 15, { 'width': 170, 'elementhandlers': specialelementhandlers }); doc.save('sample-file.pdf'); }); button: <button id="cmd">generate pdf</button> page div: <div class="container" id="div-bill"> //page elements here </div> take @ phantomjs , great job @ rendering we...

Unknown error with Paperclip and ImageMagick - Rails 2 -

i using paperclip , imagemagick upload , generate images in rails 2.2.2 application. it working fine. when uploading image, different sizes of image gets generated @ time of upload not working. image getting uploaded. i getting following error in log. info production : [paperclip] /usr/local/bin/identify -format "%w" /www/hosts/{path} info production : <paperclip::paperclipcommandlineerror> error while running identify /www/hosts/{path}/vendor/plugins/paperclip/lib/paperclip.rb:101:in `run' i can't understand happening here. checked path of identify using which identify returned user/local/bin/identify . the paperclip in config as paperclip.options[:image_magick_path] = "/usr/local/bin" paperclip.options[:command_path] = '/usr/local/bin' any idea happening here?? i tried add paperclip custom validation model. think image upload went wrong after validation. have removed it. still not working. this line of code st...

r - Using Apply functions instead of for loops -

i have data set consists of 59 columns columns 4 59 contain mixture of email addresses , nonsense want create vector (which go data frame) picks unique email addresses columns 4:59. below function works 1 column email0. columns sequential email0-email55 udf.unique.emails <- function (strcol, data) { vector <- as.character() # columns email in data set for(i in 1:length(data)) { # check items in row per email if (grepl("@", strcol[i])) { vector <- unique(c(vector,strcol[i])) } } return (vector) } test <- udf.unique.emails (foo$email0, foo.data) i wish implement on columns 4:59 produce single column, can point me in right direction using apply family? thank time #######update##### due sensitivity of data in question cant give detail. below mock data called foo.data , data , column fed function for email0, foo@fpo.com returned function the end result single column unique emails other email columns below $ email0 (chr) ...

javascript - jQuery validation moves bootstrap button add-on -

Image
i using jquery validation plugin , works great - however, on field using bootstrap button add-on, when required alert shown, button doesn't move text box - i've replicated issue here: jsfiddle here html: <form id="frmpo" action="" method="get" runat="server"> <div class="form-group input-sm"> <div class="row"> <div class="col-sm-6"> <label for="txtclientcontract"> client contract</label> <div class="input-group"> <input type="text" class="form-control" id="txtclientcontract" runat="server" required/> <span class="input-group-btn"> <button class="btn btn-default" type="button" id="btncl...

php - insert multiple duplicate rows in a same table mysql -

i have table of amenities in data inserted 1 one each property , want create duplicate of property gives error. $sql = "insert property ($column_str) select $column_str property pid = $duplicate_id"; it works single row when insert property id doesn't work. other query $sql = "insert apartment_amenity (`property_id`,`amenity_id`) select `1495`,`amenity_id` apartment_amenity `property_id` = 1494" use single quotes ' wrap 1495 instead of tick marks `

R Survival Analysis: error in survreg using Weibull -

i'm trying replicate survival analysis using weibull distribution have produced in sas - i'm working unlicensed machine using r (both windows). (right censored) input data looks like: > head(mydata) id key time score event censor 1 1231231 zxc 28 182.34 0 1 2 4564564 asd 28 320.04 0 1 3 7897897 qwe 28 306.32 0 1 4 9879879 qwe 28 211.92 0 1 5 6546546 asd 28 276.14 0 1 6 3213213 zxc 28 331.50 0 1 with event , censor being binaries, score varying between 150 , 450 , time between 1 , 28. there 30,000 rows in input dataset. when try: mydatasr <- survreg(surv(time, censor) ~ score, dist = "w") i warning message: in survreg.fit(x, y, weights, offset, init = init, controlvals = control, : ran out of iterations , did not converge, and no output. i've searched msg online (and through site) have not managed find indicates problem might be. had...

javascript - Unexpected Token while Parsing JSON -

this fraustating me 5 hours , have ask question. i trying parse json using javascript, don't know why getting error on console: uncaught syntaxerror: unexpected token (…) (anonymous function) @ vm382:2injectedscript._evaluateon @ vm251:904injectedscript._evaluateandwrap @ vm251:837injectedscript.evaluate @vm251:693 json : http://pastebin.com/dddxqj6d js code: var json=**big json**; var obj=json.parse(json); tried: json.stringify(json); json= "'" + json+ "'"; loading json url according jsonlint , pastebin posted, json invalid, due use of \' . once replace of them ' , should work normally. in original json file there going occurrences of \\' . string become \' . if you’re using linux, simple sed -i "s/\\\\\\\'/\'/g" yourjsonfile.json on file fixes everything. jsonlint says “valid json” then. you can try json.parse(json.replace(/\\'/,'\''));

scala - classOf[] for a higher-kinded type -

given class foo[f[_]] , how class object? usual syntax doesn't work: scala> classof[foo[_]] <console>:9: error: _$1 takes no type parameters, expected: 1 classof[foo[_]] ^ neither does scala> classof[foo[_[_]]] <console>:9: error: _$1 not take type parameters classof[foo[_[_]]] ^ ah, right. leaving in case looks it: scala> classof[foo[f] forsome { type f[_] }] warning: there 1 feature warning(s); re-run -feature details res0: class[foo[_[_] <: any]] = class foo

Bing maps on Cordova -

i have been trying implement bing maps in cordova app have been unsuccessful in it. the bing mas doesn’t load , throws exception : “0x800a1391 - javascript runtime error: 'microsoft' undefined" same goes google maps too. says “0x800a1391 - javascript runtime error: 'google' undefined" any pointers? <!doctype html> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="css/index.css" /> <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"> </script> <script type="text/javascript" src="js/index.js"></script> <title>bing maps</title> </head> <body> <div id="divmap" style="width:100%; height:92%; position:absolute; left:0px; top:55px;" onload="getma...

javascript - removing scope does not work -

unfortunately did not find answer myself in documentation or in google, maybe can me find out 1 thing. imagine have directive "mydirective". located on div element. when remove div using remove method jquery, "$destory" event triggered on dom node. scope of "mydirective" still exists. can listen "$destroy" on div element , manually call scope.$destroy(), why angular not this? use integrated jqlite instead of jquery. example : angular.element(yourelement).remove(); documentation angular.element after, if have problem, reset scope variable related directive (if exists) : $scope.yourelement = {};

swift - Upload image with alamofire -

i'm trying upload image server alamofire code doesn't work. code: var parameters = ["image": "1.jpg"] let image = uiimage(named: "1.jpg") let imagedata = uiimagepngrepresentation(image) let urlrequest = urlrequestwithcomponents("http://tranthanhphongcntt.esy.es/task_manager/iosfileupload/", parameters: parameters, imagedata: imagedata) alamofire.upload(urlrequest.0, data: urlrequest.1) .progress { (byteswritten, totalbyteswritten, totalbytesexpectedtowrite) in println("\(totalbyteswritten) / \(totalbytesexpectedtowrite)") } .responsejson { (request, response, json, error) in println("request \(request)") println("response \(response)") println("json \(json)") println("error \(error)") } and urlrequestwithcomponents methos: func urlrequestwithcomponents(urlstring:string, paramet...

track logs for scheduler using Whenever gem, Ruby and sinatra -

i have written scheduler using "whenever gem", have 2 schedulers in scheduler.rb file. want logs scheduled tasks, have set :output, "log/cron_log.log" in scheduler.rb. logs schedulers logged in log file, instead want output logged 1 scheduler , not other scheduler. how can this? my scheduler.rb set :output, "log/cron_log.log" #donot set output log this. every 6.hours rake "sidekiq:restart" end #set output log scheduler every :day, :at => '01:00am' rake 'prune_users:older_than_2months' end you can try # donot set output log this. every 6.hours rake "sidekiq:restart" end # set output log scheduler every :day, :at => '01:00am' rake 'prune_users:older_than_2months', :output => {:error => 'error.log', :standard => 'cron.log'} end btw, can refer @ link: https://github.com/javan/whenever/wiki/output-redirection...

jquery - How to use model int array variable in javascript MVC 4 -

model public int[] mobileid{get;set;} script var k; for(var i=0;i<3;i++) { k=@model.mobileid[i]; alert(k); } this method not working,how assign int array variable javascript var . use below method: var k=[]; k=@html.raw(json.encode(model.mobileid));//not work you can convert model.mobileid string separator of choice , convert javascript array: <script> var k = "@(model.mobileid == null ? string.empty : string.join(",", model.mobileid))"; alert(k); k = k.split(","); k // k array @ point </script>

ios - RestKit with CoreData and pagination -

i have simple pagination scheme http://api/users?page=1 gives users @ page 1 after can ask next page like http://api/users?page=2 and etc next pages but have 2 problems: i can't ordering users in response show them came server me [user1, user2, user3] when try fetch database can got [user2, user1, user3] example. i try use restkit metadata property @metadata.mapping.collectionindex but it's work each request independently. happen next http://api/users?page=1 got array [user1, user2, user3] collectionindex [1,2,3]. but ask next page , got array [user4, user5, user6] collectionindex [1,2,3] so in database [user1, user4, user2, user5, user3, user6] it's not correct. so first question: possible use collectionindex pagination requests without resets collectionindex? problem in new arrived data i ask http://api/users?page=1 , got 2 users [user1, user2] in response after ask second page , got 2 users [user3, user4] in re...