Posts

Showing posts from July, 2011

c++ - pack (type erase) a random number generator -

the c++11 std library has several random number generators (rng), each implementing concept uniformrandomnumbergenerator . these can used argument random distributions, see this documentation overview. the advantage of design choice of underlying rng engine de-coupled application. however, design requires definition (not merely declarations) of calls rng available (if rng type remain unspecified template parameter). thus, in struct complicated_random_distribution { /* data , auxiliary methods here */ // complicated; may call rng::operator() many times template<typename rng> some_type operator()(rng&gen) const; }; the member operator() cannot straightforwardly implemented in separate compilation unit (cu), must available in same header file (or 1 #include d it). for separate implementation, 1 ideally want way pack rng in same way std::function<> packs callable object. (simply using std::function , providing values rng::min() , rng::max()

android - TextView Ellipsize not working -

below textview defined in xml. <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="select language" android:singleline="true" android:maxlines="1" android:maxlength="30" android:ellipsize="end" android:padding="4dp" android:textappearance="?android:textappearancemedium" android:textcolor="@android:color/holo_blue_dark" android:id="@+id/selected_language" /> i want ellipsize text when text length greater 30 chars not working @ all.please check if missing anything.i tried answers posted similar question did not work. i have changed maxlength maxems in textview working use this. <textview android:layout_width="wrap_content" android:layout_he

c# - How to do optimal write rule definition in NRules -

the code of nrules simplerule define following rule: public class preferredcustomerdiscountrule : rule { public override void define() { customer customer = null; ienumerable<order> orders = null; when() .match<customer>(() => customer, c => c.ispreferred) .collect<order>(() => orders, o => o.customer == customer, o => o.isopen, o => !o.isdiscounted); then() .do(ctx => applydiscount(orders, 10.0)) .do(ctx => logorders(orders)) .do(ctx => orders.tolist().foreach(ctx.update)); } ... } i wondering why conditions seperate pareameters in stead of using && operator i.e. following have same effect? public class preferredcustomerdiscountrule : rule { public override void define() { customer customer = null; ienumerable<order> orders = null;

javascript - Remove false values in object -

the problem i'm facing -removing values in onject has property false here object var myobj={105:true,183:false,108:true,106:false} i'm able values in array using following logic: object.keys(myobj) gives ["105","183","108","106"] need way remove values have property false , generate ["105",108"] .can me out ? i've created solution problem on jsbin: working demo please find below code: var myobj={105:true,183:false,108:true,106:false}; var myarray = []; function removefalseandtransformtoarray () { (var key in myobj) { if(myobj[key] === false) { delete myobj[key]; } else { myarray.push(key); } } } removefalseandtransformtoarray(); console.log("myobj: ", myobj); console.log("myarray: ", myarray); // result = ["105", "108"] please, let me know if have question.

javascript - backbone database search firing 4 times -

i have search functionality in backbone application queries database via api, reason fires 4 times (or atleast returns results 4 times). here code, collections app.collections.searchablecollection = backbone.collection.extend({},{ search: function(query, options) { var search = $.deferred(); options = options || {}; var collection = new this([], options); collection.url = _.result(collection, 'url'); var fetch = collection.fetch({ data: { q: query } }); fetch.done(_.bind(function(){ pops.events.trigger('search:done'); search.resolvewith(this, [collection]); }, this)); fetch.fail(function(){ pops.events.trigger('search:fail'); search.reject(); }); return search.promise(); } }); app.collections.projectsearch = app.collections.searchablecollection.extend({

php - Issue with EXPORT to CSV FILE -

i want export write in input text : -i have created class called "excelfile", contain methods exporting data csv file. -i have issue, when try export file data, colone added automatically in csv file, colone contain code html of table -this code : excelfile.php <?php class excelfile { private $csv = null; function colonne($file) { $this->csv.=$file."\n"; return $this->csv; } function insertion($file){ $this->csv.=$file."\n"; return $this->csv; } function output($nomfichier){ header("content-type: application/vnd.ms-excel"); header("content-disposition: attachment; filename=$nomfichier.csv"); print $this->csv; exit; } } ?> index.php <?php include_once 'excelfile.php'; ?> <html> <form method='post' action="index.php"> <table> <tr

Database integrity errors when deploying Python(2.7)/Django(1.5) app on Heroku -

these days i'm learning python(2.7)/django(1.5) via developing reddit clone. clone done , works in local environment (db = sqlite3). when try host same thing on heroku (db = postgres), things go awry. specifically, web app still loads, login , logout , comments part throwing errors (i'm using django-registrations-redux, django-comments , south). since app online, can go here see error trace: login: https://salty-ridge-5419.herokuapp.com/login/ comments: https://salty-ridge-5419.herokuapp.com/comments/post/ and files, including requirements.txt etc., can found here: https://github.com/mhb11/unconnectedredditapp it perplexes me thing continues work locally, not on heroku. i'm assuming may have fudged south migrations. however, i've been deleting heroku app , setting new ones day long. every time run syncdb command on new app, following error after setting super user credentials post django-auth system installation , table creation: databaseerror: rela

php - Sing in on twitter via Codeigniter -

i'm using php framework codeigniter. need implement twitter login on website. every solution find until deprecated. if know useful post, library, tutorial helpful. version of codeigniter 3.0, guess if have solution older 1 should work on 1 too.

Meteor: How to override verify email popup dialog which appears after clicking email verification link -

i want add fields popup dialog appears when user click on verification email link sent there email. want extend sign process. when user clicked on verify link want show more fields zip code , date of birth in popup , on clicking save fields should save user modal. highly appreciated. new meteor. i using ian:accounts-ui-bootstrap-3 sign process. some more details if needed ! with following package, can replace templates : https://github.com/aldeed/meteor-template-extension so create own template, replace default 1 : template.emailverifieddialog.replaces("_justverifiedemaildialog") your dialog shown on every pages, have add behaviour make visible when necessary template.emailverifieddialog.helpers({ visible: function () { return loginbuttonssession.get('justverifiedemail'); } and manage click button event : template.emailverifieddialog.events({ 'click #just-verified-dismiss-button': function () { loginbuttonssession.set

amazon web services - DynamoDB: Insert a new Row with unique GSI -

i using dynamodbmapper insert new object table. table structure: key: hash_key attribute1: global sec index other attributes now want value of attribute1 unique in table. how that? already tried: a. map.put("attribute1", new expectedattributevalue(false)); b. map.put("atrribute1", new expectedattributevalue().withexists(false)); i using mapper.save() default savebehaviour. you cannot gsi. index not nothing uniqueness. indexes table faster lookup based on attribute also see: dynamodb key uniqueness across primary , global secondary index

c - Does free() set errno? -

if buf malloc() allocated char buffer, free(buf) set/reset errno ? let's want write buffer file, , free it, don't need more. let's error policy code return -1 on error. is proper way write out buffer , error check without leaking memory? fputs(buf, somefile); free(buf); if (errno) return -1; or need consider free possibly setting errno, in... fputs(buf, somefile); if (errno){ free(buf); return -1; } free(buf); or, horror of horrors, do { fputs(buf, somefile); int save_errno = errno; free(buf); errno = save_errno; if (errno) return -1; } while(0); where use of block allows local save_errno exist in various places should need reused. all of seem depend on whether free() sets errno. the linux man page free() man page malloc() , etc. mentions malloc() setting errno, not free() . the gnu c library manual page freeing dynamic memory not mention whether free() sets errno. so wrote short program force write error see if f

jsp - User not logged out after invalidating session -

give me suggestion instead of using scriptlets in jsp i clicked on logout works , says logout without inserting username , password when clicked on sign in, automatically login how solve this? <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="css/style.css"> <title>logout page</title> </head> <body bgcolor ="#61b3de"> <% session.removeattribute("userid"); session.removeattribute("password"); session.invalidate(); %> <center> <h1>you have logged out</h1> login again <a href="login.jsp">click here</a>. </center> </body> </html> by looking @ code provided link can check if have both user name , password in session

intellij 14 - Unable to import maven project in IntelliJ14 -

Image
i'm trying import maven projects intellij button (the 1 arrows in circle), following message "unable import maven project. see logs details", shown in following picture if go log, see: 2015-06-01 11:16:46,932 [ 89176] error - #org.jetbrains.idea.maven - org/apache/maven/execution/mavenexecutionrequestpopulationexception java.lang.noclassdeffounderror: org/apache/maven/execution/mavenexecutionrequestpopulationexception @ org.jetbrains.idea.maven.server.maven32serverimpl.applyprofiles(maven32serverimpl.java:81) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ sun.rmi.server.unicastserverref.dispatch(unicastserverref.java:322) @ sun.rmi.transport.transport$1.run(transport.java:177) @ sun.rmi.tran

Is that possible to save data user from Auth0 Social(e.g facebook) to Database(mysql) after login via facebook(auth0 social)? (using ionic framework) -

i've used auth0 service ionic project create login page , it's working own-database connection. want save data social(e.g facebook) own-database. possible? i've tried using social login in auth0, profile data saved on auth0 account. need data saved in own-database. yes, can in rule. taken post @ ask.auth0.com : function (user, context, callback) { if (context.connectionstrategy === 'connection') { // store user data in database } callback(null, context, callback); }

Tool to monitor & log system metrics during automated Java performance tests -

we have application using spring integration in core, , have created performance tests see processing speed (msgs/sec) different generated input types. this process automated, whenever such test run, separate instance created in cloud, , disposed after done & output artefacts copied. what want have performance tests monitored during run basic system metrics -- cpu, memory, i/o, gc runs/time. obviously, result of should csv files metrics readings (e.g., once or twice second). so question is: are there , configurable tools these purposes? i'm in middle of investigation, profiling tools reviewed far require human interaction , ui oriented. an option i'm considering writing separate tool access mxbean & use log such data during performance tests. wondering if around. please note application running in tomcat, performance tests using spring integration's file endpoints. please note, 'switchable' component within application possible solution. ho

javascript - How to check the css change without firing command each time -

i working on symfony framework first time. , web site highly depend on css , javascript , jquery. need fire command each time test small css change also. app/console server:stop 0.0.0.0:8000 app/console cache:clear app/console assets:install app/console assetic:dump app/console server:start 0.0.0.0:8000 is there other solution test css without having command each time. please let me know. in advance try disabling assets , cache. think involve framework core changes. can write bat (if on windows) file these commands single file run.

sql - hash several strings tsql -

i trying create unique hash this: select cast(hashbytes('sha1', ltrim(rtrim(isnull('9',''))) + ltrim(rtrim(isnull('x',''))) + ltrim(rtrim(isnull('',''))) + ltrim(rtrim(isnull('y',''))) + ltrim(rtrim(isnull('','')))) varbinary(20)) select cast(hashbytes('sha1', ltrim(rtrim(isnull('9',''))) + ltrim(rtrim(isnull('x',''))) + ltrim(rtrim(isnull('y',''))) + ltrim(rtrim(isnull('',''))) + ltrim(rtrim(isnull('','')))) varbinary(20)) unfortunately, end same hash despite different strings. ideas why? ps: this solves above 'issue': select ltrim(rtrim(isnull('9', '-'))) + n',' + ltrim(rtrim(isnull('x', '-'))) + n',' + ltrim(rtrim(isnull('', &#

angularjs - Angular Delay custom directive's link function -

i have simple custom directive checks , sets href on element. need check href data loaded server (async) make sure user has access link(kind of acl). so how can delay link function of doing job until data has finished loading? ok, cook self, appreciate pointers improving it, made gist angular.module('mymodule') .factory('dataloader', ['$http', function ($http) { var __list = null; var __request = null; return function (callbak) { if (__list) callbak(__list); else { if (!__request) __request = $http({ method: 'get', url: '/myurl', params: {} }); __request.success(function (d) { if (d.data) { __list = d.data; callbak(__list); }

python - Assigning result of pandas groupby -

i have following dataframe: date, industry, symbol, roc 25-02-2015, health, abc, 200 25-02-2015, health, xyz, 150 25-02-2015, mining, tyr, 45 25-02-2015, mining, ujk, 70 26-02-2015, health, abc, 60 26-02-2015, health, xyz, 310 26-02-2015, mining, tyr, 65 26-02-2015, mining, ujk, 23 i need determine average 'roc', max 'roc', min 'roc' how many symbols exist each date+industry. in other words need groupby date , industry, , determine various averages, max/min etc. so far doing following, working seems slow , inefficient: sector_df = primary_df.groupby(['date', 'industry'], sort=true).mean() tmp_max_df = primary_df.groupby(['date', 'industry'], sort=true).max() tmp_min_df = primary_df.groupby(['date', 'industry'], sort=true).min() tmp_count_df = primary_df.groupby(['date', 'industry'], sort=true).count() sector_df['max_roc'] = tmp_max_df

python 2.7 - I want to add mobile and email icon in Odoo -

i want add mobile , email icon in odoo not show required out put , show scattered picture. <div align="left"> support contacts: <i class="icon-mobile-phone icon-large"></i> tempdata <a href="mailto:temp@gmail.com"> <i class="icon-envelope-alt"></i> retail@itsrelevant.com </a> </div> <div align="left"> support contacts: <i class="fa fa-phone icon-large"></i> tempdata <a href="mailto:temp@gmail.com"> <i class="fa fa-envelope-o fa-fw"></i> retail@itsrelevant.com </a> </div> use fa fa-phone phone icon , fa fa-envelope-o email icon

c# - text in textbox if in datagrid selection change is null -

Image
how can command return empty space, if have in database null id , other space??? you need check if row.cells[18] null. use inline operator ?: var cotaid = (row.cells[18] == null) ? 0 : (int)row.cells[18].value; this "inline if statement" equal to if(row.cells[18] == null) cotaid = 0; else cotaid = (int)row.cells[18].value;

java - Does order of compared literals matter if both are evaluated? -

this question has answer here: boolean equal: 0 == a, operand order matter? 6 answers i have rather stupid question. point is, see if statement looking this: private int smth; // ... if (3 == smth) // ... the order feels odd me. think decreases readability of code. is there profit putting literals compared each other binary operator in order within if statement? is there profit putting literals compared each other binary operator in order within if statement? not in java, unless booleans: if (false == flag) in one case , helps avoid typo: if (flag = false) ...which compiler won't protect (that assign false flag , never evaluate true). in other cases (anything isn't boolean ), java compiler won't let make mistake. , of course, when testing booleans, it's best test boolean: if (!flag) or if (flag) depending

javascript - Crafty element with 2 gravity's -

i'm trying understand crafty. here's code. crafty.init(500,300, document.getelementbyid('game')); crafty.e('floor, 2d, canvas, color') .attr({x: 0, y: 250, w: 200, h: 10}) .color('green'); crafty.e('secondfloor, 2d, canvas, color') .attr({x: 250, y: 230, w: 200, h: 10}) .color('red') crafty.background('#ffffff url(http://samenvattingleren.nl/img/img2.jpg) no-repeat center center'); crafty.e('2d, canvas, color, fourway, gravity') .attr({x: 25, y: 5, w: 50, h: 50}) .color('orange') .fourway(4) .gravity("floor") .bind('keydown', function(e) { if(e.key == crafty.keys.left_arrow) { this.x = this.x - 1; } else if (e.key == crafty.keys.right_arrow) { this.x = this.x + 1; } else if (e.key == crafty.keys.up_arrow) { this.y = this.y - 1; } else if (e.key == crafty.keys.down_arrow) { this.y = this.y + 1; } else if (e.key == crafty.keys.esc)

javascript - Trim strings before using map? -

i want input values page user has made , want store in array make ajax-call process data. i'm doing way: $('#save').click(function(){ var data = $('*[data-array]').map(function(idx, elem) { $.trim(elem); return $(elem).val(); }).get(); the problem won't trim strings before creating array. seems $.trim doesn't apply? example if type abc____________ ( _ being whitespace, have write here show whitespace demonstration) i'll result: abc_ (with 1 whitespace after abc) you have trim value $('#save').click(function(){ var data = $('*[data-array]').map(function(idx, elem) { $(elem).val($.trim($(elem).val())); return $(elem).val(); }).get(); $('#save').click(function(){ var data = $('*[data-array]').map(function(idx, elem) { $(elem).val($.trim($(elem).val())); return $(elem).val(); }).get() console.log(data);

c# - Deserialize a json serialized CookieCollection -

in code have json serialize cookiecollection object , pass string, achieve this: var json = newtonsoft.json.jsonconvert.serializeobject(resp.cookies); resulting following json [ { "comment": "", "commenturi": null, "httponly": false, "discard": false, "domain": "www.site.com", "expired": true, "expires": "1970-01-01t03:30:01+03:30", "name": "version", "path": "/", "port": "", "secure": false, "timestamp": "2015-06-01t12:19:46.3293119+04:30", "value": "deleted", "version": 0 }, { "comment": "", "commenturi": null, "httponly": false, "discard": false, "domain": ".site.com", "expired": false, "expires": "2015-07-31t12:19:48+0

ios - Doesn't Show Current location on google map? -

Image
i using google map sdk version 1.9.1. i want display map current location . here code. @interface viewcontroller () { gmsmapview *mapview_; } - (void)viewdidload { [super viewdidload]; mapview_ = [gmsmapview mapwithframe:cgrectmake(0.0f, 100.0f, 320.0f, 300.0f) camera:nil]; mapview_.mylocationenabled = yes; [self.view addsubview: mapview_]; } but can't display current location. appreciate help. you must set location in debug>location>custom lacation like if can test in device enable location in setting screen

android - Update the view in the MainActivity immediately from the server -

i createing checkbox list arraylist getting server, programmatically.the checkbox list being created facing problem value change in mysql table every minute. regarding, have update values of checkboxes list in mainactivity. there way in android update values (gettext) of checkboxes in mainactivity ajax in javascript? what trying achieve, rebuild check box list in mainactivity when value of tables's record changes immediately. approach can use achieve or best can achieve, remove chechbox list element xml file , send new request server periodically? i appreciate help. try use code in onpostexecute() new handler().postdelayed(new runnable() { @override public void run() { new myasynctask().execute(); } }, 5*60*1000); // gap of 5 minutes

java - AspectJ on Confluence -

hello running confluence 5.5.1 , start working aop programming. plugin utilises aop throws an beanpostprocessor before instantiation of bean failed; nested exception java.lang.noclassdeffounderror: org/aspectj/lang/reflect/ajtypesystem because aspectj not part of confluence. i tried add aspectjrt 1.6.11 in $confluence_home/confluence/web-inf/lib without success. extracted jar atlassian-plugins-osgi-3.0.15.jar in order include aspectjrt in osgi-framework-bundles.zip still no success. is there other workaround can in order able work aspectj? the plugin breaks when insert <aop:aspectj-autoproxy/> .xml in meta-inf folder. check thread in answers, seems same issue https://answers.atlassian.com/questions/5352 regards, gorka

javascript - Dont understand why .remove() not working -

this question has answer here: event binding on dynamically created elements? 18 answers hi learning jquery , not understand why fucntion not work. when click button should remove div not. the remove function $(".editbutton").click(function () { $(".editbutton").remove(); }); function creates div var formatpost = function (d) { var s = ''; s = '<div class="post" data-id="' + d.id + '"><h2 class="postheading">' + d.title + '</h2>'; s += d.body; s += '<p> posted on: ' + d.date + '</p>'; s += '<div class="btn editbutton">edit post</div>' s += '</div>' return s; }; currently using direct binding, works when element exist on page @ time code makes event b

.net - verifying digital signature in c# -

i have signed "dll" file want validate digital signature in run time ("before i'm loading it") i have public key of certificate embedded in code, there way "message digest" digital signature? or way validate file hasn't manipulated? i don't want check "ca" , other attributes of certificate because malicious user can create certificate same attributes *note don't want user signtool :) there job cryptoapi , p/invoke (i don't know how extract authenticode signature .net). here code example of meant in comment: using system; using system.componentmodel; using system.runtime.interopservices; using system.security.cryptography.pkcs; namespace clrsignatures { class program { static void main(string[] args) { intptr phcertstore = intptr.zero; intptr phmsg = intptr.zero; intptr ppvcontext = intptr.zero; int pdwmsgandcertencodingtype = 0; int p

logging - How to analyze httpd (apache webserver) logs in CentOS 7 -

i have configred static ip on server using centos 7. here httpd webserver. have analyze following things. total number of queries per day (or toall) total requests sent , served. unique visitors details list of queries recieved. (status etc.) hosts/os/browsers request query errors etc. should able save in csv etc. format can import excel. can suggest me log analyzer fullfill above requirements ? i think goaccess fulfill requirements.

c++ - Accessing Iterator After Deletion Causes Crash -

so i'm used coding in c# , have started using c++ again after pretty substantial break. i'm trying create program has lists of students ids, in courses. i have code prints out available students in courses. auto allcourses = wsucourse::getallcourses(); std::for_each( allcourses.begin(), allcourses.end(), getcourseprinter()); the getcourseprinter() called in code in constructor struct getcourseprinter { void operator () ( mycourse *courseptr ) { std::cout << courseptr->getidentifier() << ": " << courseptr->gettitle() << std::endl; } }; my problem after delete enrollment so myenrollment *enrollmentptr = myenrollment::findenrollment( mystudent::getstudentwithuniqueid(1000002), mycourse::getcoursewithidentifier("cs 2800") ); delete enrollmentptr; and try print getcourseprinter crashes. believe because it's trying access doesn'

javascript - AngularJS ng-repeat grid of two divs per row -

i want load data array , display 2 divs per row. eg: there 8 objects. want them appear in 4 rows of two 1 2 3 4 5 6 7 8 code: <div ng-repeat="accobj in accountsarr" width="100%"> <div class="col" width="100%"> <div ng-if="$even" style="width:50%;height:70px;background-color:red"> {{accobj.account}}<br> {{accobj.type}} </div> <div ng-if="$odd" style="width:50%;height:70px;background-color:yellow"> {{accobj.account}}<br> {{accobj.type}} </div> </div> </div> this how code works @ moment. plnkr can please guide me how desired result? any highly appreciated. it css issue - add float:left; style of both divs & work.

android studio - Documentation window takes focus from the editor -

it's kind of tricky explain let me try. say want type log.wtf documentation window ( view → quick documentation ) open whether floating or docked, gets focused finish typing lo (doesn't have 2 keystrokes). after sigh, click on last character , try add g , editor has lost focus again. it happens sometimes , when documentation window active. rest of time, code completion shows first expected , documentation window gets updated without focus robbery. am 1 suffering this? i found workaround. place cursor on meaningful token such variable, class, etc. hit [view] → [quick documentation] ( ctrl + q me) "several times". you might see start work... pretty smells bug. :s

javascript - Jquery Remove Element After Deletion From Server -

i'm working on function deletes images gallery. on php side works. jquery/ajax works. when modified jquery remove element when image gets deleted(remove element client side) no longer works(when no longer works giving me error function built code: this code works: function deleteimage(file_name) { var r = confirm("are sure want delete image?") if(r == true) { $.ajax({ method: "post", url: '/images/gallery/deleteimage.php', data: {'delete_file' : file_name }, success: function (response) { ohsnap("image has been deleted.", "green"); }, error: function () { ohsnap("an error has occured.", "red"); } }); } } but 1 doesn't function deleteimage(file_name) { var r = confirm("are sure want delete image?") if(r == true) { $.ajax({ met

html - CSS selector to bold only labels without child elements -

i have basic html form label tags used define field names , label tags used around checkboxes user clicking on text next checkbox selects checkbox. <label>valid?</label> <label> <input type="checkbox" /> yes </label> what css best practice field name bold ("valid?"), checkbox descriptor not bold? i have tried several variations adding different :not , :empty , i'm not hitting right selector - either both bold or neither bold. know :empty isn't working since text element messes up, there must simple way bold labels have text elements. label:empty { font-weight: bold; } js fiddle: http://jsfiddle.net/z77tq8bs/ you can use next sibling selector, this: label { font-weight: bold; } label + label { font-weight: normal } check fiddle: https://jsfiddle.net/8cluhznb/

sql - Transpose row results to single row -

perhaps example simple need transpose results being multiple rows being multiple columns in single row. issue number of returned initial rows may vary therefore final number of columns may vary also. as example, returned results select name pets could be: dog cat fish rabbit and need each value in separate column: dog cat fish rabbit declare @columns nvarchar(max), @sql nvarchar(max) -- first create list of columns need in end result set @columns = n'' select @columns += n', ' + quotename(name) (select distinct name pets) x -- create pivot statement as: set @sql = n' select ' + stuff(@columns, 1, 2, '') + ' ( select name pets ) j pivot ( max(name) name in (' + stuff(replace(@columns, ', p.[', ',['), 1, 1, '') + ') ) p;' exec sp_executesql @sql; demo

java - making the backround of a javafx textArea clear -

Image
i looking whole text area class in java, going use in cool gui i'm making but, when looking make background clear thing find method allows set opaqueness. of whole text area (including text) want background clear. advice/tips also google searches made came lot of css related posts huh? a textarea contains scroll pane internally. 3 things need make transparent make text area appear transparent the text area iteself the viewport text area's internal scroll pane the content pane displays text inside scroll pane the css rule is .text-area, .text-area .viewport, .text-area .content { -fx-background-color: transparent ; } complete example: transparenttextarea.java: import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.textarea; import javafx.scene.layout.stackpane; import javafx.stage.stage; public class transparenttextarea extends application { @override public void start(stage primarystage) {

javascript - how to change a obj value in the uploader (ajax)? -

i still try change 1 value on thish script via js (remotepath), please give me informations :) thank you! $('#uploader_div').ajaxupload( { url: 'upload.php', droparea: '#drop_here', remotepath: 'user/user1/', <-- how change value ... like this remotepath: 'user/user2/' update: <div id="uploader_div"></div> <a id="link" href="#" onclick="newvalue();"> change user2 </a> <!--change click--> <script> var uplobj = { url: 'upload.php', droparea: '#drop_here', remotepath: 'user/user1/', // change click autostart: true, hideuploadbutton: true, removeonsuccess: true, maxconnections: 0, maxfilesize: '20m', allowext: ['mp3'] }; function newvalue() { up

Android Studio errors -

i new android studio , finding interesting compared eclipse. when run application runs, after , when starting android studio again, has errors of classes imported. says cannot recognize objects. as follows: import android.os.bundle; import android.view.menu; import android.view.menuitem; //bundle, menu , menuitem underlined indication of error import com.android.volley.*; //volley imports shows correctly public class mainactivity extends actionbaractivity { requestqueue queue; request request; yet when rebuild following message: information:gradle tasks [clean, :app:compiledebugsources, :app:compiledebugandroidtestsources] :app:clean :app:prebuild up-to-date :app:predebugbuild up-to-date :app:checkdebugmanifest :app:prereleasebuild up-to-date :app:preparecomandroidsupportappcompatv72211library :app:preparecomandroidsupportsupportv42211library :app:preparedebugdependencies you should copy/paste of import code comment. also, might want post build.gradle

javafx - no border on focused button -

hey i'm starting out javafx. found custom buttons css code on net lost borders of buttons when clicked (the vanilla blue border). have back. .root{ -fx-background:#222222; } .glass-grey { -fx-background-color: #c3c4c4, linear-gradient(#d6d6d6 50%, white 100%), radial-gradient(center 50% -40%, radius 200%, #e6e6e6 45%, rgba(230,230,230,0) 50%); -fx-background-radius: 30; -fx-background-insets: 0,1,1; -fx-text-fill: black; -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 3, 0.0 , 0 , 1 ); } .menu-btn{ -fx-background-color: linear-gradient(#686868 0%, #232723 25%, #373837 75%, #757575 100%), linear-gradient(#020b02, #3a3a3a), linear-gradient(#9d9e9d 0%, #6b6a6b 20%, #343534 80%, #242424 100%), linear-gradient(#8a8a8a 0%, #6b6a6b 20%, #343534 80%, #262626 100%), linear-gradient(#777777 0%, #606060 50%, #505250 51%, #2a2b2a 100%); -fx-background-insets: 0,1,4,5,6; -fx-p

string - Check if the following position of a pointer is null or end of line C++ -

well, have iterator on string in c++ std::string::iterator itb = itc->begin(); and want check if the next position of iterator reaches end of line. i've tried this: if(*itb ++ != null) also this: itb++ == itc->end() but i'm confused , need help, since i'm rookie @ pointers in c++. you want check without modifying it. both of attempts involve modifying itb . if have c++11, that's std::next : std::next(itb) == itc->end() if don't, make iterator: std::string::iterator next = itb; ++next; next == itc->end() although, in case know std::string::iterator random access iterator, can do: itb + 1 == itc->end() (the previous 2 work iterator category)

Python read text file as binary? -

i trying build encryption program in python 2.7. read binary file , use key encrypt it. however, ran problem. files image files , executables read hex values. however, text files not using open(). if run file=open("myfile.txt", "rb") out=file.read() it still comes out text. i'm on windows 7, not linux think may make difference. there way read binary file (including text files), not image , executable files? take @ below code .also has many points you from hashlib import md5 crypto.cipher import aes crypto import random def derive_key_and_iv(password, salt, key_length, iv_length): d = d_i = '' while len(d) < key_length + iv_length: d_i = md5(d_i + password + salt).digest() d += d_i return d[:key_length], d[key_length:key_length+iv_length] def encrypt(in_file, out_file, password, key_length=32): bs = aes.block_size salt = random.new().read(bs - len('salted__')) key, iv = derive_key_a

Meteor.js - how do I include a debugOnly package when I deploy to production? -

i deploy meteor app , packages bundled , deployed, including marked debugonly -- how can accomplish this? using arunoda's mup , mupx tools deploys , pushing heroku others. thanks. when run meteor deploy --debug , deploy application same way in development mode. i'd bet running meteor build --debug yield same results. of course, may not idea with debugonly packages :)

ios - My ViewControllers is not dismissing properly -

i have, 3 viewcontrollers, idea is, viewcontroller viewonecontroller, , viewtwocontroler, want go viewcontroller directly, when do, memory goes little bit, viewcontrollerdelegate protocol viewcontrollerdelegate{ func viewcontrollerdidfinish(controller: viewcontroller) } this viewtwo trying go viewcontroller protocol viewtwodelegate{ func viewtwodidfinish(controller: viewtwo) } class viewtwo: uiviewcontroller, viewcontrollerdelegate { var button: uibutton! var delegate: viewtwodelegate? = nil override func viewdidload() { super.viewdidload() button = uibutton.buttonwithtype(uibuttontype.system) as! uibutton button.frame = cgrectmake(self.view.frame.size.width/2 - button.frame.size.width, 100, 250, 50) button.layer.cornerradius = 3 button.backgroundcolor = uicolor.bluecolor() button.center.x = self.view.center.x button.settitle("viewcontroller", forstate: uicontrolstate.normal) button.addtarget(self, action: "

django - What are the pros and cons of using GenericForeignKey vs multitable inheritance vs OneToOneField? -

context i in process of modeling data using django models. main model article . holds actual content. then each article must attached group of articles. group may blog , category portfolio or story . every article must attached one, , 1 of those. is, either blog, category or story. models have different fields , features. i thought of 3 ways reach goal (and bonus 1 looks wrong). option #1: generic foreign key as in django.contrib.contenttypes.fields.genericforeignkey . this: class category(model): # fields class blog(model): # some fields class article(model): group_type = foreignkey(contenttype) group_id = positiveintegerfield() group = genericforeignkey('group_type', 'group_id') # fields on database side, means no relation exists between models, enforced django. option #2: multitable inheritance make article groups inherit articlegroup model. this: class articlegroup(model): group_type = foreignkey(contenttype

Produce points out of csv dataset in matlab -

i've got csv file this: title, longitude, latitude photo1, 77.94, 20.665 photo2, 62.508, 36.548 photo3, 39.64, 52.547 photo4, 39.6435, 52.77 photo5, 70.642, 20.547 longitude , latitude coordinates each photo taken. now, need produce points out of file , cluster them different algorithms. i tried this: t = readtable('testdata.csv','format','%s%f%f') x = t(:, 2); y = t(:, 3); lon=[x,0]; lat=[0,y]; data = [lon lat]; using lon, lat in scatter function, seems i'm wrong. if me, great. sorry silly question, i'm new matlab. the scatter function expects 2 vectors point coordinates. thus, think need is: scatter(x, y); where x , y defined in question.

java - How to set a timer to an ActionListener -

i have created slot machine game. in slot machine game have button generate 3 random images when pressed. want button generate 3 random images 5 seconds after pressed. here code button , action listener. b1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { randompicturegenerator(evt); repaint(); } }); private void randompicturegenerator(java.awt.event.actionevent evt) { this.run(); } public void run() { pictures = new arraylist<>(); pictures.add(new file("question.png")); pictures.add(new file("banana.png")); pictures.add(new file("chocolate.png")); pictures.add(new file("icecream.png")); pictures.add(new file("bell.png")); pictures.add(new file("apple.png")); pictures.add(new file("money.png")); pictures.

ios - I want multiple non-random numbers in swift -

i using swift , want have number of duplicatable patterns throughout game. ideally have sort of shared class worked sort of (this sort of pseudo-swift code): class randomnumberutility { static var sharedinstance = randomnumberutility() var random1 : random() var random2 : random() func seedrandom1(seed : int){ random1 = random(seed) } func seedrandom2(seed : int){ random2 = random(seed) } func getrandom1() -> int { return random1.next(1,10) } func getrandom2() -> int { return random2.next(1,100) } } then, begin series, anywhere in program go this: randomnumberutility.sharedinstance.seednumber1(7) randomnumberutility.sharedinstance.seednumber2(12) and know (for example) first 4 times called randomnumberutility.sharedinstance.getrandom1() i same values (for example: 6, 1, 2, 6) continue until @ point seeded number again, , either exact same series (if used same seed), or different series