Posts

Showing posts from April, 2012

GET request using ajax v java -

i'm writing simple web application completes 1 request custom headers. when tried making request using ajax, gave me cross domain error so: no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8080' therefore not allowed access. when make same request in java using custom headers, works fine. public static string executeget() { string response = ""; try { url url = new url("http://...."); httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("get"); //set custom headers con.setrequestproperty("header1", "2.0"); con.setrequestproperty("header2", "sellingv2"); con.connect(); inputstreamreader reader = new inputstreamreader(con.getinputstream()); scanner scanner = new scanner(reader); while (scanner.hasnext()) { ...

c# - Does SqlBulkCopy Enlist in Ambient Transaction? -

i can't seem find definitive answer on this. have sqlbulkcopy operation wrapped in transactionscope number of other operations. i aware of overloads in sqlbulkcopy constructor allow passing sqltransaction object. assuming not passing transaction in constructor, command automatically participate in ambient transaction created transactionscope? i've done testing, , appears sqlbulkcopy does, in fact, honor ambient transaction, @ least in .net 4.5. to test, did sqlbulkcopy operation while debugging, , verified rows made database (via nolock/dirty read query). threw exception on next line of code, , allowed transactionscope roll back. verified rows no longer in database.

c# - Check if image is on pdf using iTextsharp -

i working on trying make little console application can tell difference between blank page, , page 1 image on , no text. blank page i'm using itextsharp's simpletextextractionstrategy() , works great blank pages. problem pages image on them considered blank method well. there way know if pdf has image on similar way checking text on pages?

javascript - Add attribute to an object -

Image
how can change attribute of tag in html code given object? currently, if do: console.log(gallery.curritem); i get: so did: console.log(gallery.curritem.html); and html in console (not object, believe it's texy): <video width="500" height="250" controls><source src="" type=""></video> but i'm not sure how edit video tag adding attribute muted="muted" . i tried: console.log($(gallery.curritem.html).find('video')); but returned object again. :/ i assume using photoswipe. gallery.curritem.html not string actual html element. can directly edit attributes of it: gallery.curritem.html.setattribute("muted", "muted"); to make sure it's actual element, if in question, this: if(gallery.curritem.html.tagname) { gallery.curritem.html.setattribute("muted", "muted"); } else { // append dom or wrap jquery , set attributes ...

java - LibGDX Tiled Map Collision Detection with Property and Layers -

i building simple top down rpg game libgdx haven't found precise pointers on how detect collision on tiled map. i have character class looks this public class son{ spritebatch batch; texture texture; sprite sprite; private tiledmaptilelayer collisionlayer; public son(float x, float y, tiledmaptilelayer collisionlayer){ this.collisionlayer = collisionlayer; batch = new spritebatch(); texture = new texture(gdx.files.internal("characters/xter1.png")); sprite = new sprite(texture); sprite.setx(x); sprite.sety(y); } public void render(){ processkeys(); batch.begin(); sprite.draw(batch); batch.end(); } private void processkeys(){ if(gdx.input.istouched()){ //gdx.app.exit(); gdx.app.log("x touched", gdx.input.getx() + ""); gdx.app.log("y touched", gdx.input.gety() + "...

kafka log deletion and load balancing across consumers -

say consumer time intensive processing. in order scale consumer side processing, spawn multiple consumers , consumer messages kafka topic in round robin fashion. based on documentation, seems if create multiple consumers , add them in 1 consumer group, 1 consumer messages. if add consumers different consumer groups, each consumer same message. so, in order achieve above objective, solution partition topic ? seems odd design choice, because consumer scalability bleeding topic , producer design. ideally, if topic not partitioning, there should no need partition it. puts un-necessary logic on producer , causes other consumer types consume these partitions may make sense 1 type of consumer. plus limits usecase, consumer type may want ordering on messages, splitting topic partitions may not possible. second if choose "cleanup.policy" compact, mean kafka log keep increasing maintain latest value each key? if not, how can log deletion , compaction? update: seems have 2 opti...

Eloquent Javascript, listToArray. Why does my for loop return rest [object] when input array has more than 3 elements -

i'm working through eloquent javascript chapter 4. exercise asks write function arraytolist builds data structure previous 1 when given [1, 2, 3] argument using code below can necessary output - when number of elements in array 3 or less. function createnode (value, rest) { return { value: value, rest: rest } }; function arraytolist(arr) { var index = arr.length; firstnode = createnode(index,null); listbuild = firstnode; (i =(index-1); >0; i--) { listbuild = createnode(i,listbuild) } question arraytolist([1,2,3]) produces desired result of "{ value: 1, rest: { value: 2, rest: { value: 3, rest: null } } }" arraytolist([1,2,3,4]) produces output of "{ value: 1, rest: { value: 2, rest: { value: 3, rest: [object] } } }" why function generate rest property of [object] in case? thanks! your function seems work fine, suspect output issue, not problem code. if you're using node.js test code, you've run g...

authentication - I would like to add radio button in web2py auth -

hi having trouble adding radio button in web2py auth. as know web2py has built-in login feacture auth(). in db.py, i add following from gluon.tools import auth auth = auth(db) auth.settings.extra_fields['auth_user']= [field('status')] auth.define_tables(username=true) this gives me additional text box called "status" change field, user can chooses either "student" or "tutor". thanks guys. when defining field, can specify form widget validator. in case: field('status', requires=is_in_set(['student', 'tutor']), widget=sqlform.widgets.radio.widget)) by default, if specify is_in_set validator, <select> widget in form, above overrides default widget explicitly setting radio widget.

c# - How to copy data from server table to client table -

i want copy data server table client table. i copy data client table client table like insert newtable (col1, col2, col3) select column1, column2, column3 oldtable as know how copy data server table client table using linked server using ssms, want copy data using c# codes. similar question : how copy table data remote server local server in sql server 2008 any idea ?? edit : now trying open remote server connection con1 select column1, column2, column3 oldtable open client connection con2 insert newtable (col1, col2, col3) values (con1.column1,con1.column2,con1.column3) you can use sqlbulkcopy class efficiently copy data 1 table on sql server instance table on sql server instance. here have simplest code that: using (var sourceconnection = new sqlconnection(sourceconnectionstring)) using (var sourcecommand = new sqlcommand("select * sourcetable", sourceconnection)) using (var targetconnection = new sqlconnection(targetconnectionstri...

Call a python class from command line -

i have no python experience. trying figure out how trigger part of code command line. issue i'm finding looks "useraccount()" object , i'm not sure how trigger command line. a) useraccount? b) how call command line arguments? # create random use account randomint = random.randint(1, 4294967295) accountid = "random_id+" + str(randomint) + "@acme.com" randomint = random.randint(1, 4294967295) password = "random_password1_" + str(randomint) primaryemail = accountid useraccount = useraccount() useraccount.accountid = accountid useraccount.password = password useraccount.primaryemail = primaryemail useraccount.firstname = "random" useraccount.lastname = "user" useraccount.birthdaymonth = 5 useraccount.birthdayday = 31 #useraccount.firstnamephonetic = "" #useraccount.firstnameromag...

asp.net web api - how to cast Edm.Guid to Edm.String in odata -

how cast guid string in odata, have tried $filter=(startswith(cast(customerid, 'edm.string'),'1')) throws exception unknown function 'cast'. to perform cast, type shouldn't in quotes. should be: $filter=startswith(cast(customerid, edm.string),'1') (i removed brackets)

Top 10 Subquery in Access SQL -

select top 10 [final_for_db].[indemnity_paid]/[final_for_db].[claim_count] indemnity_cost, final_for_db.claimant_name, final_for_db.account_name, final_for_db.claim_id, final_for_db.file_date, final_for_db.resolution_date, final_for_db.claim_status, final_for_db.state_filed, final_for_db.expense_amount, final_for_db.claim_count, final_for_db.indemnity_paid [total indemnity] final_for_db (((final_for_db.account_name)="exxon")) order [final_for_db].[indemnity_paid]/[final_for_db].[claim_count] desc; this give me top 10 entries exxon wondering if there way top 10 entries each account name biggest indemnity cost lowest. believe there need subquery. appreciate on this. thanks other rdbms's support rank() , row_number() functions. unfortunately, access not (to knowledge). should close want. not handle duplicates (two customers same indemnity cost same rank, possibly leaving top 11 or so). select * ( select * , ( select count...

How to do this swipe view in android -

Image
how can swipe in android? android 5 app settings activity. use viewpager achieve this. can add tabs in example. refer : creating swipe views tabs viewpager

c# - Firewall port is out of range -

code should correct, when run it, says port value out of range (i tried "6" or "1433", need). know wrong? try { inetfwrule firewallrule = (inetfwrule)activator.createinstance(type.gettypefromprogid("hnetcfg.fwrule")); firewallrule.action = net_fw_action_.net_fw_action_allow; firewallrule.description = rule.text; firewallrule.enabled = true; firewallrule.interfacetypes = "all"; firewallrule.name = rule.text; firewallrule.localports = port.text; firewallrule.protocol = (int)net_fw_ip_protocol_.net_fw_ip_protocol_any; inetfwpolicy2 firewallpolicy = (inetfwpolicy2)activator.createinstance( type.gettypefromprogid("hnetcfg.fwpolicy2")); firewallpolicy.rules.add(firewallrule); } catch (exception ex) { messagebox.show(ex.tostring()); }

php - wrong with wp_generate_attachment_metadata() -

it works (upload , send db) but wp_generate_attachment_metadata() returns bad letters whene file uploaded ! some of wrong charechters : ����jfif��;creator: gd-jpeg v1.0 (using ijg jpeg v62), quality = 90 ��c ��c ����"�� ���}!1aqa"q2���#b��r��$3br� %&'()*456789:cdefghijstuvwxyzcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1aqaq"2�b���� #3r�br� $4� the code : if (isset($_files['ed_header_logo'] ) && !empty($_files['ed_header_logo']['name']) ) { $filename = $_files['ed_header_logo']['name']; $wp_filetype = wp_check_filetype( basename($filename), null ); $wp_upload_dir = wp_upload_dir(); move_uploaded_file( $_files['ed_header_logo']['tmp_name'], $wp_upload_dir['path'] . '/' . $filename ); $url = $wp_upload_dir['url'] . '/' . basename( $filename ); $attachment = arr...

android - How to load images in an ImageSwitcher from server? -

i m trying load images in image switcher http server. didnot find function setimagebitmap. tried using setimageuri() , not getting loaded. tring switch image after every 3 sec. code. when m running codes image not getting loaded. , app getting crased. string arr[]={"http://192.168.1.7/photos/dummy/1.jpg","http://192.168.1.7/photos/dummy/2.jpg","http://192.168.1.7/photos/dummy/3.jpg"} dailywear = (imageswitcher) getactivity().findviewbyid(r.id.imagedailywear); dailywear.setfactory(new viewswitcher.viewfactory() { @override public view makeview() { imageview myview = new imageview(getactivity()); myview.setscaletype(imageview.scaletype.fit_xy); myview.setlayoutparams(new imageswitcher.layoutparams(relativelayout.layoutparams.match_parent, relativelayout.layoutparams.match_parent)); return myview; } }); dailywear.setinanimation(animationutils.loadanimation(getactivity(),...

Ajax call returns nothing for secured sites URL,How to access secured sites in ajax? -

function loadmessages(){ $.ajax({ url :"https://www.yammer.com/api/v1/search.json?search=java", async: false, datatype: "json", crossdomain: true, success : function (data) { alert(data); var htmldata = ""; for(var cntr=0;cntr<data.messages.messages.length;cntr++){ htmldata += "<tr><td>"+data.messages.messages[cntr].content_excerpt+"</td></tr>" } alert("no of msgs"+data.messages.messages.length); $("#text tbody").append(htmldata); return data; } }); } xmlhttprequest cannot load https://www.yammer.com/api/v1/search.json?search=java . no 'access-control-allow-origin' header present on requested resource. origin ' http://localhost:8002 ' therefore not allowed access. response had http status code 401.

javascript - Autofill Textbox using buttons -

i have php application i'm working on. here's i'm trying do: i have search box ( textbox ) , several buttons . on clicking each button , want fill search box predefined string. clicking button erase what's in search box , replace value pre-defined string. , button clear textbox well. example: button 1 on click -> textbox value = button1 button 2 on click -> textbox value = button2 (old value replaced) can guide me js code this? thanks! apply 'button' class every button , unique id each button. $(".button").click(function(){ var id = this.id; $('#searchtextid').val($('#'+id).attr('value')); });

c++ - Run member function of an object in separate file -

i have separate files functions , variables use in program; header file , implementation file. file.hpp: #ifndef file_h #define file_h #include <sfml/graphics.hpp> extern sf::font sffont; #endif // file_h file.cpp: #include "file.hpp" sf::font sffont; sffont.loadfromfile("ubuntu.ttf"); // <- error my problem on line i've commented on. except line run member function "loadfromfile". instead, error: "error: ´sffont´ not name type". how solve this? as can see use library sfml, don't think it's relevant. lines such as sffont.loadfromfile("ubuntu.ttf"); are valid inside other functions. if want able make function call, can use helper function initialize dummy variable , make function call in helper function. static int init() { sffont.loadfromfile("ubuntu.ttf"); return 0; } int dummy = init();

ruby on rails - Git not pushing my sitemap on public folder -

i'm using ruby on rails sitemap_generator gem. when make new sitemap ruby sitemap.rb command displays this: + sitemap.xml.gz 11 links / 527 bytes sitemap stats: 11 links / 1 sitemaps / 0m00s pinging url 'http://domain.com/sitemap.xml.gz': successful ping of google successful ping of bing but when test sitemap google webmaster tools or other service displays have 3 links. how can fix it? here sitemap.rb file require 'rubygems' require 'sitemap_generator' sitemapgenerator::sitemap.default_host = "http://domain.com" sitemapgenerator::sitemap.create add '/about' add '/contact' # under services category add '/heyheyhey' add '/hey' add '/heyhey' add '/eur' add '/blog' , :changefreq => 'weekly' add '/blog/this-is-it' add '/blog/my-blog-post' add '/blog/crazy-blog' end sitemapgen...

javascript - Meteor- Facebook social plugin cant load until browser refreshes -

i'm having issue facebook social plugins. & comment box in website appears after refreshing browser. know why happening , how can fix it? i'm using meteor build website , page, social plugins placed, accessible after user logged in. thank much! :) the test website www.sgeasyaidtest.meteor.com , social plugins under planner page. this script fb login & social plugins i've placed under tag: <body> {{#if currentuser}} <!--fb login--> <script> window.fbasyncinit = function() { fb.init({ appid : '1027408483945691', xfbml : true, version : 'v2.4' }); }; (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); <...

java - Convert hash table to byte array -

i have hash table , want send through datagram socket. need have byte array. how can convert hash table byte array? i've ignore filling hash table i've tried way: hashtable<string, string> valuenick = new hashtable<>(); nickstr = valuenick.tostring(); byte[] buffernick = nickstr.getbytes(); (int = 0; < buffernick.length; i++) { system.out.print(buffernick[i] + " "); } but nothing has been printed. or advise. i have modified code(added value in it) hashtable<string, string> valuenick = new hashtable<>(); valuenick.put("name", "ankush"); valuenick.put("lastname", "soni"); string nickstr = valuenick.tostring(); byte[] buffernick = nickstr.getbytes(); (int = 0; < buffernick.length; i++) { system.out.print(buffernick[i] + " "); } } it printing below outpu...

java - Generating a SOAP client with Apache CXF 3.1.1 -

to generate client code, used follow command: wsdl2java -client helloworld.wsdl this generated java files , it's working without errors but, unfortunately, slowly, 2 seconds each call. in soap ui , same web service method called in 200ms. i noticed on logs org.apache.cxf.service.factory.reflectionservicefactorybean buildservicefromwsdl being called each time call service. seems software recreating client wsdl each time. happens when keep service objects created. how can stop this? did wrong? i discovered problem. each time call myservice.getport() , wsdl parsed. so, create port once , reuse through application. now client fast!

java - javax.transaction.HeuristicRollbackException: Failed to commit transaction Transaction -

i trying delete node. i know deleting node first have delete relationship. match (n:`dummy`) n.uuid='1aa41234-aaaa-xxxx-ffff-xxxx11xx0x62' optional match (n)-[r]-() delete n,r but not working javax.transaction.heuristicrollbackexception: failed commit transaction transaction(80074, owner:"qtp10775679-13464")[status_no_transaction,resources=1], transaction rolled ---> transaction handler failed. the error message indicates transaction event handler's beforecommit method threw exception. if happens transaction rolled back. maybe data/graph.db/messages.log contains stacktrace. if not suggest wrap contents of beforecommit() try catch block catches exception, prints stacktrace , rethrows it.

jsf - View scoped managed bean's @PostConstruct reinvoked after closing p:dialog -

i have popup defined within xhtml gets shown conditionally depending on selections user makes in main screen rendered default: <p:dialog id="commentdialogid" header="enter comment" widgetvar="commentdialog" modal="true" resizable="true" height="auto"> <h:form id="commentform"> <h:outputlabel for="comment" value="comment:"/> <p:inputtextarea id="comment" title="comment" rows="6" cols="33" value="#{managedbean.activeitem.comment}" required="true"> <f:ajax render="comment"/> </p:inputtextarea> <h:commandbutton id="commentsubmit" value="submit" action="#{managedbean.proceed}" onclick="pf('commentdialog').hide();"> <f:ajax re...

wcf - Windows Service Never Restarted from C# Code -

i have written code restart windows service never works properly. service able stop never start again. project self hosted wcf service inside windows service. below code. restart method public static void restartservice(string servicename) { try { servicecontroller svc = new servicecontroller(servicename); if (svc.status == servicecontrollerstatus.running) svc.stop(); svc.waitforstatus(servicecontrollerstatus.stopped, new system.timespan(0, 0, 20)); svc.start(); svc.waitforstatus(servicecontrollerstatus.running, new system.timespan(0, 0, 20)); svc.dispose(); } catch (exception ex) { logging.writeexception(ex); } } main program static class program { /// <summary> /// main entry point application. /// </summary> static void main() { try { servicebase[] servicestorun = ...

PHP: Next delivery date -

php newb, excuse simplicity of question. i attempting create little echo shows 'next delivery date' based on 2 parameters: start date , interval (in either days or weeks). what wanting able enter, instance, today 'start date' , interval (say, '3 weeks'), , have script return "your next delivery on xxx", xxx being next upcoming 3-week interval upcoming in future , including 2 days before, when switches "tomorrow". on actual date, moves next period (the delivery cannot ordered on delivery date) infinity or realistic date in future (the next 5 years?) is possible? i've looked through previous questions, , seems reasonably trivial add locked in date (a date + set period future) didn't come across looks @ current date , thinks next recurrence be... hence ask here. you use dateperiod this. dateperiod take datetime object start date, first parameter, dateinterval object interval on repeat, second parameter, , datetim...

Right place to add a common function which updates UI component in AngularJS -

i working on angularjs applicaion. ui divided 2 parts. on left side, have navigation tree panel. if user clicks on of item in tree, load corresponding page on right hand side. on of pages (load of right side panel), have provided button, loads page , update navigation tree panel. currently, have copied logic @ multiple places updates navigation tree. wonder right place put logic? i thinking of using this: var mynamespace = mynamespace || {}; mynamespace.helpers = { isnotstring: function(str) { return (typeof str !== "string"); } }; in controller: angular.module('app.controllers', []). controller('datactrl', ['$scope', function($scope) { $scope.helpers = mynamespace.helpers; }); or may add function root scope: $rootscope.isnotstring = fun...

objective c - iOS self.delegate is nil even after being set -

i have controller gets instantiated , pushed onto navigation controller - in parentvc.m thingcontainerviewcontroller *thingcontainer = [[thingcontainerviewcontroller alloc] init]; thingcontainer.delegate = self; [self.navigationcontroller pushviewcontroller:thingcontainer animated:yes]; now want send value parentvc when thingcontainer closed. have implemented delegate follows: in parentvc.h @interface parentvc : uiviewcontroller <..., thingcontainerviewcontrollerdelegate> in thingcontainer.h @protocol thingcontainerviewcontrollerdelegate <nsobject> - (void)additemviewcontroller:(id)controller didfinishenteringitem:(nsinteger)page; @end .... @interface .... @property (nonatomic, weak) id <thingcontainerviewcontrollerdelegate> delegate; .... @end in parentvc.m - (void)additemviewcontroller:(id)controller didfinishenteringitem:(nsinteger)page { self.page = page; } in thingcontainer.m - (iboutlet) ... closebuttonwastapped:(uibutton *)butt...

ruby - Convert two arrays into an array of Hash pairs -

i have 2 arrays: dates = [1,2,3] values = [10,20,30] how can combine them this? [{date:1,value:10},{date:2,value:20}...etc] dates.zip(values).map{|k, v| {date: k, value: v}}

wmi - Using Powershell and ADSI to set local passwords -

i'm trying automate setting bunch of local user accounts' password on windows 2008 server. i've tried few things , works if don't use variable username this: $user = [adsi]"winnt://$computer/someusername" my script block below... ideas i'm doing wrong? $accounts = get-content c:\userlist.txt $computer = somecomputername $password = "mypassword" foreach($account in $accounts) { $user = [adsi]"winnt://$computer/$account" $user.setpassword("$password") $user.setinfo() } the error when use $account variable user (from text file list) is: the following exception occurred while retrieving member "setinfo": "the group name not found. thanks help... it seems machine tries resolve $account value local group name. you can specify user object want, following account name comma , string user : $user = [adsi]"winnt://$computer/$account,user"

Sublimelinter & JSHint complaining about Facebook's Open Graph objects {og:url: "example.com"} -

i'm using jshint , sublimelinter sublime text 3, when using facebooks api doesnt object double : in structure, eg. { og:url: 'example.com' } fb.api( 'me/objects/my-app:object', 'post', { og:url: http://samples.ogp.me/12345678910, og:title: sample object, og:type: my-app:object, og:image: https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png, og:description: , fb:app_id: 12345678910, place:location:latitude: sample location: latitude, place:location:longitude: sample location: longitude }, function(response) { // handle response } ); i know how ignore variables , names in .jshintrc file on root of project, not sure how stop complaining structure. thought since facebook api popular it's worth posting here. wrap them in quotes. eg. { 'og:url': 'example.com' }

c - Taking File Inputs in OpenCL? -

i'm new opencl, , i'm curious how read in data input perform simple operations (e.g. cross/dot product) on. for particular example, i've compiled , trying run simple sample code calculate 3d dot product vectors: https://github.com/mattscar/opencl_dot_product however, i'm not sure how format input code. in following code snippet: /* create program file */ program = clcreateprogramwithsource(ctx, 1, (const char**)&program_buffer, &program_size, &err); if(err < 0) { perror("couldn't create program"); exit(1); } clcreateprogramwithsource appears operate on context ctx, don't know how assign context file on hard drive read test vector data from. going right way? one approach follows: #include <stdio.h> #include <stdlib.h> #ifdef __apple__ #include <opencl/opencl.h> #else #include <cl/cl.h> #endif int main() { cl_platform_id platform; cl_device_id device; cl_context context; ...

ReactJS Server Side rendering click event won't fire -

i have code compiled server side node-jsx click events not fire. being novice can't figure out missed /** @jsx react.dom */ var react = require('react/addons') var mui = require('material-ui'); var thememanager = new mui.styles.thememanager(); var injecttapeventplugin = require("react-tap-event-plugin"); var unydentapp = react.createclass({ childcontexttypes: { muitheme: react.proptypes.object }, getchildcontext: function() { return { muitheme: thememanager.getcurrenttheme() }; }, componentdidmount: function () { }, render: function () { var menuitems = [ { route: 'home', text: 'home' }, { route: 'about', text: 'about' }, ]; return ( <div id="uny-dent"> <mui.leftnav ref='leftnav' menuitems={menuitems} docked={false}...

scala - Retrieve typed stored values from Map -

i'd put data hashmap , retrieve these typed values using function. function takes expected type , default value in case value not stored in hashmap. type erasure of jvm makes tricky thing. q: how can retrieve typed value? code , results below. abstract class parameters(val name: string) { val parameters = new hashmap[string, any]() def put(key: string, value: any) = parameters(key) = value def get(key: string) = parameters.getorelse(key, none) def remove(key: string) = parameters.remove(key) def g0[t: typetag](key: string, defaultvalue: t) = { get(key) match { case x: t => x case none => defaultvalue case _ => defaultvalue } } def g1[t: classtag](key: string, defaultvalue: t) = { val compareclass = implicitly[classtag[t]].runtimeclass get(key) match { case none => defaultvalue case x if compareclass.isinstance(x) => x.asinstanceof[t] } } } class p extends parameters("aparmlist...

Running Windows 8.1 app built on Windows 10 with VS 2015 -

built on windows 10 vs 2015, our (managed) windows 8.1 store app crashes on startup odd xaml parsing error on devices running windows 8.1 (no stack trace or source file given, caught in unhandled exception handler, no chance debug): cannot deserialize xbf metadata property list 'horizontalcontentalignment' not found in type 'null'. additional info: built on windows 8.1 vs 2015, app work properly the app run correctly on windows 10 devices the app sideloaded on windows 8.1 devices as of visual studio 2015 compatibility guide , scenario should supported. did experience same issue , overcame it? i trace such cryptic errors style or template resource files, , indicate don't find visual studio helpful should. if inspect style or template files (e.g., generic.xaml, or own custom style files, etc), , if things missing, visual studio flags blue wavy underline (i must not accurate 90% in guesstimate). this may turn out non-answer sharing experi...

python - Can I add ini style configuration to pytest suites? -

i using pytest run tests in multiple environments , wanted include information (ideally) in ini style config file. override parts or of configuration @ command line well. tried using hook pytest_addoption in conftest.py so: def pytest_addoption(parser): parser.addoption("--hostname", action="store", help="the host") parser.addoption("--port", action="store", help="the port") @pytest.fixture def hostname(request): return request.config.getoption("--hostname") @pytest.fixture def port(request): return request.config.getoption("--port") using can add configuration info @ command line, not in config file. tried adding [pytest] addopts = --hostname host --port 311 to pytest.ini file, didn't work. there way without building own plugin? time. the parser object have addini method can use specify configuration options through ini file. here documentation it: https://pyt...

scala - How to use regex to include/exclude some input files in sc.textFile? -

i have attempted filter out dates specific files using apache spark inside file rdd function sc.textfile() . i have attempted following: sc.textfile("/user/orders/201507(2[7-9]{1}|3[0-1]{1})*") this should match following: /user/orders/201507270010033.gz /user/orders/201507300060052.gz any idea how achieve this? looking @ the accepted answer , seems use form of glob syntax. reveals api exposure of hadoop's fileinputformat . searching reveals paths supplied fileinputformat 's addinputpath or setinputpath "may represent file, directory, or, using glob, collection of files , directories" . perhaps, sparkcontext uses apis set path. the syntax of glob includes: * (match 0 or more character) ? (match single character) [ab] (character class) [^ab] (negated character class) [a-b] (character range) {a,b} (alternation) \c (escape character) following example in accepted answer, possible write path as: sc.textfile(...

Why I don't need to declare encoding when using python interpreter? -

# -*- coding: utf-8 -*- i understand line of code necessary when non-ascii characters involved in python script file. when learning python, told 2 ways of running python code (line line in interpreter vs run script file) yield same result. , do, in cases. when non-ascii characters involved in scripts, turns out have declare encoding first. moreover, have tried exec() function, trying execute string containing python codes. >>> exec ("b='你'") it works. but if save "b = '你'" script , run it, syntax error. i curious why don't need declare encoding when running python codes line line in interpreter. is there difference in executing procedures of these 2 way? thank you. i suppose interactive session of python use system encoding (see python unicode strings , python interactive interpreter ). when read source file, need know how interpret data it's parsing it's logical script not necessary written in s...

jquery - Fancybox "locked" not restricting scroll on background document -

we have been using fancybox on our website few different things. have noticed "locked" option background seems scrolling still. using version 2.1.5 should option works... missing here? $('.fancybox').fancybox({ type: 'iframe', width: '100%', height: '100%', padding: 0, autosize: false, autocenter: false, wrapcss: 'wrapper', helpers: { overlay: { locked: true, closeclick: false, css : { // set z-index higher snapengage 'z-index' : '2147000000' } } } });

python - TypeError: 'in <string>' requires string as left operand, not QString -

i'm trying write simple app send (and possibly receive) emails gmail account. managed while hardcoding account information in source code, wanted enter them in gui fields , read information there. here code: import sys import smtplib pyqt4 import qtcore, qtgui notifier_main import ui_notifier_main_gui class maingui(qtgui.qwidget, ui_notifier_main_gui): def __init__(self): qtgui.qwidget.__init__(self) self.setupui(self) self.sendbutton.clicked.connect(self.send) def send(self): fromaddr = self.senderemaillineedit.text() toaddrs = self.receiveremaillineedit.text() msg = self.msgtextedit.toplaintext() username = self.senderemaillineedit.text() server = smtplib.smtp("smtp.gmail.com:587") server.starttls() server.login(username, 'password') server.sendmail(fromaddr, toaddrs, msg) server.quit() if __name__ == "__main__": app = qtgui.qapplicatio...

date - Splitting string which includes( / and : ) into an array in Javascript -

i have string includes date , time together. need of them seperated in cases. string : 28/08/2015 11:37:47 there solutions in there not fix problem var date = "12/15/2009"; var parts = date.split("/"); alert(parts[0]); // 12 alert(parts[1]); // 15 alert(parts[2]); // 2009 this similar thing said above, need split of them. thank help if have datetime format i'd suggest simple regex "28/08/2015 11:37:47".split(/\/|\s|:/) this splits on / space , colon and return ["28", "08", "2015", "11", "37", "47"] edit per question asked in comment function parse() { /** input format needs day/month/year in numbers work **/ var datetime= document.getelementbyid("datetime").value; var time = document.getelementbyid("time").value; var output = document.getelementbyid("output") var datetimearr = datetime.split(/\/|\s|:/); var ...

Inscrutable Swift compiler error when comparing two object arrays -

i'm trying compare 2 object arrays this: if oneobjectarray != anotherobjectarray { // ... stuff } however following less helpful compiler error: binary operator '!=' cannot applied operands of type '[mymodelobject]' , '[(mymodelobject)]'` the compiler error points first operand in equality check. i think problem have not made myobectmodel equatable. in order check equality of 2 arrays of myobjectmodel need able check equality of 2 myobjectmodel objects. to need following... extension myobjectmodel: equatable {} // top level function func ==(lhs: myobjectmodel, rhs: myobjectmodel) -> bool { // check if objects equal here... return lhs.name == rhs.name }

r - plotting hypervolumes from hypervolume() in 3d -

i using hypervolume package construct hypervolumes in n-dimensional space. i can't figure out how tweak 3d plots when plot() operated on object of class 'hypervolume' or 'hypervolumelist'. arguments listed in package documentation function 'plot.hypervolumelist' (pg 21). example using data included package: # call data , run routine create hypervolumelist require(hypervolume) data(finch) dohypervolumefinchdemo = t demo(finch) # create 3d plot of hypervolumelist plot(hv_finches_list, pairplot = f) specific questions follow. included code tried--but doesn't work. how change size of data points? plot(hv_finches_list, pairplot = f, cex.data = 5) how choose whether plot uniformly random points? plot(hv_fiches_list, pairplot = f, showrandom = t) is possible add centroids or contours 3d plot? plot(hv_finches_list, pairplot = f, showcentroid = t)

arrays - glTexImage2D to Display Intensity Image -

i'm working display image in opengl using glteximage2d, having trouble data types... the image i'm grabbing slice of larger 3d volume , volsize_pix struct gives dimensions of volume indexing: unsigned _int8 *orthoplane; orthoplane = new unsigned _int8[volsize_pix.depth * volsize_pix.length]; int orthoplaneidx = 0; int halfway = (int)floor(volsize_pix.width / 2); ///printf("halfway: %d, volsize_pix.length: %d\n", halfway, volsize_pix.length); (int vx = 0; vx < volsize_pix.depth; vx++) { (int vy = 0; vy < volsize_pix.length; vy++) { orthoplane[orthoplaneidx] = (unsigned _int8)floor(volume[vx][vy][halfway]); orthoplaneidx++; } } so, can see, it's intensity image, not rgb. i'm trying pass texture opengl display 2d image follows: // load texture gluint tex2; glgentextures(1, &tex2); glactivetexture(gl_texture0); // tell opengl use generated texture name glbindtexture(gl_texture_2d, tex2); gltexpara...

Trying to use SDL 2 with Visual Studio c++ -

i trying 1 requires use sdl2 , excited start attempting write program. downloaded sdl2 , didn't have problems. next opened new empty project followed instructions add include folder, lib(x86) folder, , added sdl2.lib , sdl2main.lib linker. when tried build project received following error. 1>msvcrtd.lib(cinitexe.obj) : warning lnk4098: defaultlib 'msvcrt.lib' conflicts use of other libs; use /nodefaultlib:library 1>sdl2main.lib(sdl_windows_main.obj) : error lnk2019: unresolved external symbol _sdl_main referenced in function _main 1>c:\users\nas\documents\visual studio 2013\projects\basic sdl\debug\basic sdl.exe : fatal error lnk1120: 1 unresolved externals you need link library files. right click project , properties click vc++ directories . click include directories , down arrow , <edit> . then add directory of include files (where .h files are, example e:\visual studio .net\sdl2-2.0.3\include ). ...

javascript - Dynamic number.toFixed() function -

i using javascript number.tofixed() function. my problem have explicitly mention number of fractional length below: if number 1e11 have specifiy as number.tofixed(2) or if number 1e1 : number.tofixed(1) or if 1e0 number.tofixed(0) i want dynamically based on whether fractions present or not. , irrespective of fractional length. i dont want pass parameter of fixed fractional length. js should dynamically understand fractional length of it. there similar provision in js? or there similar function in java script need not explicitly pass parameter of fixed length? var temp = number.split('.'); if (typeof temp[1] !== 'undefined') { console.log(temp[1].length); // here got } else { // 0 }

Is it possible to save php values from a form for further use? -

i have form on 1 page calculates value depending on user has entered: // process users calculations $elecaq = trim($_post['elecaq']); $elecday = trim($_post['elecday']); $elecmonth = trim($_post['elecmonth']); $elecyear = trim($_post['elecyear']); $elecstanding_charge = trim($_post['elecstanding_charge']); <input type="text" style="padding-left: 2px" class="text-box-find" name="elecaq" placeholder="0000" value="<?php if(isset($_post['elecaq'])) echo $_post['elecaq'];?>"> <input type="text" class="day" name="elecday" style="float: left; margin-right: 2px" value="<?php if(isset($_post['elecday'])) echo $_post['elecday'];?>" placeholder="day" /> <input type="text" class="month" name="elecmonth" placeholder="...

Runtime exception while running robolectric 3.0 unit tests in Android studio 1.2 -

i running android unit tests using robolectric 3.0 , have run in runtime exception. tests pretty gives same exception. java.lang.runtimeexception: java.lang.runtimeexception: should calling main thread! @ org.robolectric.robolectrictestrunner$2.evaluate(robolectrictestrunner.java:244) @ org.robolectric.robolectrictestrunner.runchild(robolectrictestrunner.java:188) @ org.robolectric.robolectrictestrunner.runchild(robolectrictestrunner.java:54) @ org.junit.runners.parentrunner$3.run(parentrunner.java:231) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:60) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:229) @ org.junit.runners.parentrunner.access$000(parentrunner.java:50) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:222) @ org.robolectric.robolectrictestrunner$1.evaluate(robolectrictestrunner.java:152) @ org.junit.runners.parentrunner.run(parentrunner.java:300) @ org.gradle.api.internal.tasks...

Why output of my Javascript regex is inconsistent? -

this question has answer here: why regexp global flag give wrong results? 5 answers in browser console output of following function series of alterante true , false. idea? function checkspecificlanguage(text_val) { // force string type`enter code here` var regex = /^[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uffef\u4e00-\u9faf\u2605-\u2606\u2190-\u2195u203b]+$/ig; console.log( text_val+"-"+regex.test(text_val) ); console.log( text_val+"-"+regex.test(text_val) ); console.log( text_val+"-"+regex.test(text_val) ); console.log( text_val+"-"+regex.test(text_val) ); console.log( text_val+"-"+regex.test(text_val) ); return regex.test(text_val); } checkspecificlanguage("でしたコンサート"); you're using global ( g ) flag. a...

documentation - Tool to Document TM1 Processes -

we have inherited data warehouse lot of processes , no documentation. has used or knows software tool can automatically document our tm1 processes? thanks i'm aware of 1 person (a {cough} friend of mine) has written admin helper tool includes process documenter using api, it's not available general release. possible it, take time. lot of time if don't know api. if want avoid time , bunch of other features bargain @ commercial product called cubewise pulse . use it, not ti documenter (though has powerful feature there well, including showing parameters, variables, etc) replacement tm1 top / version 10 admin tools replaced tm1 top. in fact has full model documentation features. the downside? it's not free, , it's not cheap. very useful if have budget.

tcsh reading columns of a text file into variables -

i have text file in looks like: jose santiago:385-898-8357:385-555-5555:38 fife way, abilene, tx 39673:1/5/58:95600 tommy savage:408-724-0140:408-777-0121:1222 oxbow court, sunnyvale, ca 94087:5/19/66:34200 yukio takeshida:387-827-1095:387-888-1198:13 uno lane, ashville, nc 23556:7/1/29:57000 vinh tranh:438-910-7449:438-999-0000:8235 maple street, wilmington, vm 29085:9/23/63:68900 i trying write tcsh script read text file , assign each colon delimited field variable, exception of name, want set 2 separate variables. have tried several things, can't work. i'm sorry, i'm novice. in advance help. supposing name variable have 2 words separated space, first replace space : , use cut field variables: sed 's/ /:/' <filename >new_file set var1 = `cut -f1 -d ':' new_file` set var2 = `cut -f2 -d ':' new_file` set var3 = `cut -f3 -d ':' new_file` etc... each field in file ps: if don't mind rewriting original file...

peoplesoft - how to change home page logo imge in peopletools8.54 -

everone how change home page logo image in peplesoft ? had created new "pt_oraclelogo_css" image in application designer,and restart app server,web server , purge app cache,but still show oracle logo。 our peoplesoft environment : peopletools release 8.54.08 & application release:9.20.00.000 fluid branding (8.54): i had other day, real easy accomplish. navigate main menu > peopletools > portal > branding > branding objects click on 'image' tab. click 'upload image object' upload image. want open app designer: app designer > file > open > page > select: ptnui_lp_header. double click on square button right next cancel button. when properties box opens click label tab , under 'label image' upload image. click ok save page , image should appear in header. here documentation found out lot. branding (8.54): follow along article, @ describing steps need take change page logo.