Posts

Showing posts from August, 2015

c# - Linq to SQL Associated Table Not Accessible -

i reworking application had working code in it. necessity, i'm moving several commonly-used bits separate project. 1 of linq sql model. i have references resolved , namespaces corrected compiles correctly except couple of areas code using mapping association access different table. so example, template t = db.templates.firstordefault( f => f.templateid == templateid ); list<item> templatelist = new list<item>( ); foreach ( var r in globalitems ) { if (t.templatechildren.firstordefault( f => f.itemid == r.itemid ) != null ) // stuff... } in instance, cannot access t..templatechildren. compiler tells me inaccessible due protection level. taking @ linq sql designer code, find problem: [global::system.data.linq.mapping.associationattribute(name="template_templatechildren", storage="_templatechildren", thiskey="templateid", otherkey="templateid")] internal ent

c# - WPF MySQL connection error handling -

i try error handling when comes connecting mysql database. want separate out connection errors , sql errors. issue being error being returned doesn't seem mysql error in fact ms error. doing: using (mysqlconnection con = new mysqlconnection(constring)) { mysqldataadapter da = new mysqldataadapter(); mysqlcommand cmd = new mysqlcommand(sqlcmd, con); try { system.security.cryptography.rsacryptoserviceprovider.usemachinekeystore = true; var provider = new system.security.cryptography.rsacryptoserviceprovider(); con.open(); da.selectcommand = cmd; da.fill(dt); con.close(); } catch (exception x) { //amazing error catching code } } now lets try connect machine not have mysql installed, exception being returned: mysql.data.mysqlclient.mysqlexception (0x80004005): unable connect of specified mysql hosts. @ mysql.data.mysqlclient.nativedriver.open() @ mysql.data.mysqlclient.driver

c++ - How to generate set of enumerations with even number of ones -

i have idea of how prevent single bit flip (due cosmic radiation or similar externally induced event) causing enumerations (enum) change 1 defined value defined value in relatively easy way. put simple each value should have amount of ones, binary speaking. if 1 flips, enum odd , guaranteed not match other enum. i'm not sure how "generate" such sequence may used enum values values must compile time constant. macro function returning n:th element in set perfectly. the first few numbers in sequence 0 (000), 3 (011), 5 (101), 6 (110). think idea now. non-enumeration (non-compile time) answers appreciated may me realize how myself. to make myself clear want macro generating n:th number in enum number of ones in bit pattern, similar macros generating fibbonachi sequence. lowest bit parity bit. most of memory protected hardware ecc, l1 cache being 1 exception. single bit error in l1 has been measured occur once every 10000h enough seen requirements. vram not

java - servlet don't respond to remote requests -

on windows 10 machine. issue: servlet works on private ip on 8080 port, can't access remotely. solutions tried: open port 8080(port use on connectors) on firewall | turn off firewall (done) disable anti-viruses (done) tried once public ip on connector address , engine defaulthost , host name (and combination of of them), , same private ip!(done) i skimmed tomcat/config documentations nothing helpful!

Azure PowerShell Error - Output of Get-AzureRmLocation changes when stored to variable -

in azure powershell, version 1.5, when write line below: get-azurermlocation | {$_.displayname -eq "east 2"} i following (expected) output console: location: eastus2 displayname: east 2 providers: {microsoft.automation, microsoft.backup...} however, when instead write following code, *which should (in understanding) have exact same output above: $location = get-azurermlocation | {$_.displayname -eq "east 2"} $location i see different output console: microsoft.azure.commands.resourcemanager.cmdlets.sdkmodels.psresourceproviderlocation further, if want call of properties expect object returned get-azurermlocation (such displayname property), error. picture attached prove i'm not losing mind: error what going on?

java - Retrofit 2 - Elegant way of adding headers in the api level -

my retrofit 2 ( 2.0.2 currently) client needs add custom headers requests. i'm using interceptor add these headers requests: okhttpclient httpclient = new okhttpclient(); httpclient.networkinterceptors().add(new interceptor() { @override public response intercept(chain chain) throws ioexception { final request request = chain.request().newbuilder() .addheader("custom_header_name_1", "custom_header_value_1") .addheader("custom_header_name_2", "custom_header_value_2") ... .addheader("custom_header_name_n", "custom_header_value_n") .build(); return chain.proceed(request); } }); retrofit retrofitclient = new retrofit.builder() .baseurl(baseurl) .client(httpclient) .build(); some headers want add, headers need add based on requirements of specific endpoint, example whether user need

angular - In an angular2 component how do you get both the attribute text value as well as the bound variable? -

is there way both plain text value of attribute getting attribute input component? e.g. have @input('c-failure') cfailure; gives me this.cfailure bound outer variable. component created in outer template <c-component c-failure="failures.secondary['cause']"> . variable value "failures.secondary['cause']" variable bound value of outer this.failures.secondary.cause. tried injecting elementref, doesn't seem have or attributes bound @input. i try following leveraging @input , @attribute decorators. seems it's not possible mix them on same attribute @component({ selector: 'test' }) export class somecomponent { @input('c-failure') cfailure; constructor(@attribute('c-failure-expr') cfailureexpr:string) { } } and use way: <test [c-failure]="failures.secondary['cause']" c-failure-expr="failures.secondary['cause']"></test> see

android - statusesService.homeTimeline allways retrieve the same number of tweets -

statusesservice.hometimeline first parameters supposed number of tweets retrieved ,but whatever number pass method default number of tweets,20. public class followingactivity extends appcompatactivity { listview homelist; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_following); homelist =(listview)findviewbyid(r.id.homelist); twitterapiclient twitterapiclient = twittercore.getinstance().getapiclient(); statusesservice statusesservice = twitterapiclient.getstatusesservice(); statusesservice.hometimeline(200, null, null, null, null, null, null,//always same number of tweets new callback<list<tweet>>() { @override public void success(result<list<tweet>> result) { final fixedtweettimeline timeline = new fixedtweettimeline.builder()

parsing - Any method to restore garbled/distorted text file by Matlab? -

i got weird situation highly needs assistance. appreciate effort , time in advance. i have machine produces text file records information of machine's working status such as, coordinate of drill head , rotating speed used @ position. while examine text file, appears unreadable because of contents garbled. please see attached figure. http://ppt.cc/sa1i if open ultraedit see: http://ppt.cc/trnv as can see part of file readable; many unrecognizable characters, should numeric values want. two reasons believe problem should solved matlab. first, sure machine has many built-in matlab code inside analysis purpose. second, have .exe file, compiled matlab, can restore garbled text file arranged , readable format (the values of coordinates restored). we desperately want see contents of file ourselves. please kindly provide solution or idea or direction me solve issue. sincerely,

ember.js - Ember model not displaying field data in template -

app/models/index.js import model 'ember-data/model'; import attr 'ember-data/attr'; export default model.extend({ title: attr(), owner: attr(), city: attr(), type: attr(), image: attr(), bedrooms: attr() }); app/template/index.hbs {{#each model |rental|}} <p>location: {{rental.city}}</p> <p>number of bedrooms: {{rental.bedrooms}}</p> {{/each}} am returning sinatra /rentals data request { data: [{ id: 1, title: 'grand old mansion', owner: 'veruca salt', city: 'san francisco', bedrooms: 15, type: 'rental', image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/crane_estate_(5).jpg' }, { id: 2, title: 'urban living', owner: 'mike tv', city: 'seattle', bedrooms: 1, type: 'rental', image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/alfonso_13_highrise_t egucigalpa.jpg' }, { id: 3,

java - Spring Boot - Slow to start application on different connections -

i'm experiencing weirdness spring boot application. when i'm connected wifi (my home network) or disconnected internet entirely, application starts within 6 seconds. when i'm connected wifi b (my work network) application takes 1.5 minutes start. this simple hello, world! spring application. main class looks this: import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; @springbootapplication public class application { public static void main(string[] args) { system.out.println("start := " + system.currenttimemillis()); springapplication.run(application.class, args); system.out.println("stop := " + system.currenttimemillis()); } } i see start timestamp printed @ same speed, must springapplication.run. bare class, there no spring configurations otherwise. why change in wifi connection cause such lag start? i'm running both using mvn spring-bo

how to list the files for the next git push command -

i trying push branch origin git push --set-upstream origin v0.8 this seems take forever , stops error counting objects: 180, done. delta compression using 4 threads. compressing objects: 100% (92/92), done. writing objects: 100% (180/180), 538.00 mib | 72.00 kib/s, done. total 180 (delta 142), reused 110 (delta 87) remote: error: gh001: large files detected. may want try git large file storage - https://git-lfs.github.com. remote: error: trace: eef60ca4521006cb11e4b7f181bc7a1a remote: error: see http://git.io/iept8g more information. remote: error: file x.sql 1537.98 mb; exceeds github's file size limit of 100.00 mb https://github.com/x/x.git ! [remote rejected] v0.8 -> v0.8 (pre-receive hook declined) error: failed push refs 'https://github.com/x/x.git' so apparently tries push file 1.5gb named x.sql...? can't see file anywhere? had @ log git log v0.8 --not --remotes=origin which gave commit 046332334e1f944f64a110f92434cdc26e9fafd0 author: x date

mysql - Storing images to directory using php -

i'm creating admin side website. i have created add page , within page form few fields. 2 of these upload button me upload image. , other 1 fill box me enter url. i have set both of them update same mysql field , fill box priority when both entered. however. search box fine saves link correctly selecting image using select box saves file name in field in mysql example: xxxxxxxxxxxxx.png so my website displaying these images, not display uploaded ones. because these saved on computer , not on cpanel. so question is: how can upload image using upload box , have save /images folder have mysql display url link in relevant field? my add.php code this: <?php session_start(); include_once('../include/connection.php'); if (isset($_session['logged_in'])){ if (isset($_post['title'], $_post['content'])) { $title = $_post['title']; $content = nl2br($_post['content']); if (!empty($_post['im

objective c - Changing Color array to produce Red Tint in OpenGL -

i have run across open source code screensaver , understand how modify color array of color verticies produce red tint instead of green tent here code author uses set green color: // compute new state of color vertices - (void) computecolorvertices { int i,maxi,c; glfloat g, gstep, cursorglow; c = 0; // suppress spurious warning gstep = stripparams.colorcyclespeed; // first, run down strip cycling colors bright dark g = startcolor; maxi = cursordrawing ? cursorpos : stripsize; (i=0; < maxi; i++) { (c = 0; c < 4; c++) { // shade of green if cell not empty colorarray[16*i + 4*c + 1] = (cellstate[i] == 0) ? 0.0 : g; // cells bright whitened colorarray[16*i + 4*c + 0] = ((g > 0.7) && (cellstate[i] != 0)) ? (g - 0.6) : 0.0; colorarray[16*i + 4*c + 2] = ((g > 0.7) && (cellstate[i] != 0)) ? (g - 0.6) : 0.0; // transparent if cell empty, otherwise opaque colorar

javascript - Make text in ajax generated input field selectable -

i can't make text in ajax generated input field selectable on click. <input type="text" class="form-control input-lg" id="url" value=""> <script> $.ajax({ ... element.append('<input type="text" id="test" value="' + 'https://' + location.host + '/' + data[0].data + '">') } }); return false; }); </script> <script> $('input').on('focus', function (e) { $(this) .one('mouseup', function () { $(this).select(); return false; }) .select(); }); </script> i can select text on click in #url input, beside text in ajax generated input. want make text in both static inputs , ajax generated inputs selected on click. $('body').on('focus', 'input', function () { $(this).select(); });

excel - How can I use structured references to identify column and use row values in the identified column as criteria? -

Image
i have excel 2013 table, called 'student_courses' columns: stu_id, stu_major, stu_course, , calculated column named validated_crs. i trying create formula calculated column named validated_crs evaluates every record. in calculated column, need reference value in stu_major column find column in second table, 'qualified_courses'. headers in 'qualified_courses' table correlate stu_major values. i need check see if of values in correlated column in 'qualified_courses' match 'stu_course' value in record being evaluated in 'student_courses' table. if of values in correlated column match stu_course value given record in first table, should return value of "validated" in calculated column. so far, have found out how return second table column values using =indirect("qualified_courses"&"["&[@[stu_major]]&"]") , i'm not sure how use returned set of values check against stu_cou

Cannot echo in the same line in Batch script -

i have txt files contain several lines , need create log out of them store in log following information: file name last modified count of lines containing word "valid" i've put .bat file splits output in 2 lines. type nul > filesreceived.txt & %f in (*.log) ( find /c "valid" %f & echo(%~tf)>> logsreceived.txt ) with type nul clear contents of filesreceived.txt file. loop through files of type log. count lines contain word valid find /c , echo last modified time stamp. however output looks like: ---------- transaction_20160505_1005a.log: 6492 10/06/2016 04:37 p.m. i don't know what's generating dashes. i'd have 1 line per log file follows: transaction_20012b.log: 6492 10/06/2016 04:37 p.m. hope guys can me. thanks, bruce find prints dashes if processes file. doesn't, when processing stdin ( type file.ext /c |find "string" prints count only). there trick write without l

how can i solve the gcc problems in Debian ? when i am apt-get install gcc find one qustions? -

i'm using gcc compile files in debian terminal, : zsh: command not found: gcc so i've tried sudo apt-get install gcc . > following packages have unmet dependencies: > gcc : > depends:gcc-4.7(>=4.7.2-1~) not going installed > recommends: libc6-dev not going installed or libc-dev try installing gcc , dependencies package: sudo apt-get install build-essential

c++ - How to write "target data map" for std::vector in OpenMP 4? -

i want use c++ , vectors . had c code c arrays created this: double* data = (double*)malloc(sizeof(double) * n); double* result = (double*)malloc(sizeof(double) * n); #pragma omp target data map(tofrom: data[0:n],result[0:n]) //loop now use c++ vector , get: example.cpp:31:41: error: expected variable name or array item #pragma omp target data map(tofrom: data[0:n],result[0:n]) here openmp4 introduced user-defined reductions. have analogs data maps? you pointers of underlying storage of std::vector , use them in same way in c code. double* data = vec_data.data(); double* result = vec_res.data(); int n = vec_data.size(); #pragma omp target data map(tofrom:data[0:n],result[0:n]) //loop

Android Transform the current Fragment Class to Activity Class -

i have fragment somethings related searchview works well, but want create activity perform tasks typically fragment. there no problem xmls main problem in java code.some methods in fragment , don't know opposite of them in activity. fragment code: public class airlinesearchfragment extends fragment implements searchview.onquerytextlistener{ private recyclerview recyclerview; private list<airlinedata> airlinesdatamodel; private airlinessearchviewadapter adapter; public airlinesearchfragment() { sethasoptionsmenu(true); } @override public void oncreate(bundle savedinstancestate) { sethasoptionsmenu(true); super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { sethasoptionsmenu(true); view view = inflater.inflate(r.layout.airline_search_fragment, container, fal

Sum of sparse matrices - Matlab numerical error -

i have following problem: n=500; = sparse(1:500,10*ones(n,1),0.005*ones(n,1),n,n); a(:,300) = -0.005*ones(n,1); >> sum(a,2) ans = 0 sparse: 500-by-1 b = spdiags(0.45*ones(n,1),0,n,n); b(:,34) = -0.45*ones(n,1); b(34,34) = 0; >> sum(b,2) ans = 0 sparse: 500-by-1 c = a+b; >>max(sum(c,2)) ans = (1,1) 4.3368e-18. since sum of rows of , b 0, sum of rows of c should 0 too. large sparse matrices, not case. if e-18, need closer 0. how can make matlab improve precision in kind of computations? thank you

android - Creating and Moving Shared Preference Method from Activity to Java -

i'm still new android studio , want make shared preference method in device.java class validates correctly. however, i'm not sure variables should initialise , code placement. share preference code validates user same user , performslogin bypass login screen i.e. first time requires login, life time bypasses welcome screen. sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(loginactivity.this); if (sharedpreferences.contains("ip") && sharedpreferences.contains("username") && sharedpreferences.contains("password")) { string strusername=sharedpreferences.getstring("username", username); string strpassword=sharedpreferences.getstring("password", password); string stripaddress=sharedpreferences.getstring("ip", ipaddress); performlogin(strusername, strpassword,stripaddress); } java class: public static void login(string usern

php - Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors? -

note: reference question dealing variable scope in php. please close of many questions fitting pattern duplicate of one. what "variable scope" in php? variables 1 .php file accessible in another? why "undefined variable" errors? what "variable scope"? variables have limited "scope", or "places accessible". because wrote $foo = 'bar'; once somewhere in application doesn't mean can refer $foo everywhere else inside application. variable $foo has scope within valid , code in same scope has access variable. how scope defined in php? very simple: php has function scope . that's kind of scope separator exists in php. variables inside function available inside function. variables outside of functions available anywhere outside of functions, not inside function. means there's 1 special scope in php: global scope. variable declared outside of function within global scope. example: <?php

c# - How to make ASP.NET Application Cache Persistent -

if add asp.net application cache, persistent or re-load on interval? httpcontext.current.application["mykeyname"] = "some data"; will "mykeyname" exist until end of application's life? also, application cache available sessions correct? meaning, once loads once first user, doesn't have load again rest of users. per msdn : using application cache similar using application state. however, unlike application state, data in application cache volatile, meaning not stored in memory life of application. advantage of using application cache asp.net manages cache , removes items when expire or become invalidated, or when memory runs low. can configure application caching notify application when item removed. more information see caching application data . the example code provided httpcontext.current.application["mykeyname"] = "some data"; is using application state , not using application cache. applicatio

image - How do I reference a local file properly? -

i'm running wordpress on wamp right , i'm trying figure out how correctly reference image i'm using in header pages. if write this: <img src="wp-content/themes/my-theme/images/ssblogoalpha.png"> the logo shows on wp homepage, not on subsequent pages. if write <img src="../wp-content/themes/my-theme/images/ssblogoalpha.png"> the logo shows on subsequent pages, not homepage. to honest don't know "../" or root folder supposed when writing directory path these ways i've seen other people this. ideas? thanks! you can images following way <img src="<?php bloginfo('template_directory'); ?>/images/ssblogoalpha.png" alt=""/>

javascript - Can't access JQuery through JS file -

i have created html, css, , js documents linked through html doc. <!doctype html> <html> <head> <title></title> <script type="text/javascript" src="script.js"></script> <link rel="stylesheet" type="text/css" href="style.css"></link> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script> </head> <body> </body> </html> i have tested document connections , work fine, how jquery work in external js file? use library file first , write scripts on scripts.js. <!doctype html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="style.css"></link> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/l

ruby on rails - Gemfile ROR version and local machine ROR version mismatch -

i complete beginner ror , heroku. trying create app git bitbucket , gemfile version (2.2.3) different ruby on rails version of 2.3.1. what steps can take ensure gemfile can changed? this mismatch in gemfile caused "git push heroku master" fail following errors. an error occurred while installing mime-types (3.0), , bundler cannot remote:continue. thank much! (: ruby 2.3 kind of cool - stuff safe navigation operator , recommend installing it, if don't want - in either gemfile or .ruby-version file, you'll have line says ruby 2.3.1 . temporarily change installed version, 2.2.3. the run bundle , or perhaps bundle --without production if want skip gems marked belonging production group only. example, if don't have postgres installed locally. then switch gemfile or .ruby-version 2.3.1. commit , try , push. what accomplish? keeps ruby version pinned @ 2.3 heroku, installs gemfile.lock using installed version. heroku requires gemfile.loc

ios - How to navigate to viewcontrollers from expanded / nested UITableViewCells -

using alex di mango's popdownmenutable-master setup expanding nested uitableviewcell , functioning in project...but issue how navigate other view controllers menu , nested / expanding submenu uitableviewcells...using didselectrowatindexpth programatically created..please refer below code... **popdcell.h** #import <uikit/uikit.h> @interface popdcell : uitableviewcell @property (strong, nonatomic) iboutlet uilabel *labeltext; @property (strong, nonatomic) iboutlet uilabel *separator; @property (strong, nonatomic) iboutlet uilabel *sepshadow; @property (strong, nonatomic) iboutlet uilabel *shadow; @end popdcell.h #import "popdcell.h" @implementation popdcell - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { // initialization code } return self; } -(void)prepareforreuse { self.backgroundcolor = [uicolo

ios - CvVideoCamera - camera not available, Iphone simulator -

following example of initialization , start of cvvideocamera in swift project ios. xcode 7.3.1, using pre-built opencv 2.4.13 executing on simulator ios 9.3. have tried 2 version of cvvideocamera initialization , start. 1 , directly in swift view controller, in objective c wrapper same effect. easier debugging call initcamera followed startcamera ibaction triggered button, rather viewdidload. expecting after sequence simulator turn macbook camera on , direct video simulator. the camera not start ( led indicator off , not receiving video in parent uiimageview). there 1 message in application console: 2016-06-10 21:13:20.777 ocvtest2[57252:2485915] camera available: n is macbook camera supposed available simulator default or requires additional setup? how trouble shoot issue? thank you my initcamera , startcamera methods : var mycamera : cvvideocamera! var videocamerawrapper : cvvideocamerawrapper! var camerainitialized : bool = false var camerastarted : bool = false func st

java - ADF Call a bounded taskflow from managed bean -

i need invoke bounded task flow managed bean. able call managed bean method event listener in application. how launch bounded task flow method? please help. thanks, sash if tabcontext available. else pass tab context parameter try { tabcontext.getcurrentinstance().settabsrendered(true); tabcontext.getcurrentinstance().addorselecttab("your tab name", "/web-inf/task-flow-definition.xml#task-flow-definition"); } catch (tabcontext.taboverflowexception e) { e.printstacktrace(); } refer: taskflow

include - using a globals struct in several .cpp files, and initializing it in the constructor -

i know similar questions have been asked, none address issue. want create globals struct , initialize default values. implemented below, project won't build. i've tried can think of, notably moving "extern" declaration of *gxg in , out of header guard , changing struct class, same results: project won't build because of duplicate symbols globals constructor. builds if don't use in more 1 .cpp file, or if don't include constructor or destructor in struct's implementation file. // globals.hpp #ifndef globals_hpp #define globals_hpp struct gxglobals{ double radius; bool easement; gxglobals(); // constructor } ; extern "c" gxglobals *gxg; #endif /* globals_hpp */ ————————————— // globals.cpp #include "globals.hpp" gxglobals::gxglobals(): radius(24), easement(false) {}; ——————————— // main_file.cpp #include "globals.hpp" gxglobals *gxg = new gxglobals(); ——————————— // other_

httpwebrequest - How to pass list to POST parameter asp.net web request -

i have web service has list parameter: [webmethod] public void getdepartmentby(list<string> key, list<string> value) { string condition = ""; (int = 0; < value.count; i++) { if (!value.equals("")) { condition = condition + "[" + key + "]" + " = '" + value + "' , "; } } context.response.write(new javascriptserializer().serialize(condition)); } i try set parameter this: string poststring = string.format("key={0}&value={1}", key, value); but it's not working! there way pass list parameter web request?