Posts

Showing posts from April, 2013

git - Github connection with ssh fail because of bad name resolution -

i have registered ssh key github account. keys in ~/.ssh/id_rsa_github_snail ~/.ssh/id_rsa_github_snail.pub i have repo wherein remote url configured use ssh: $ git remote -v origin git@github.com:danielsank/pong.git (fetch) origin git@github.com:danielsank/pong.git (push) however, when try push company computer, following error message danielsank@snail:~/src/pong$ git push ssh: connect host github.com.<company>.<name>.com port 22: connection timed out fatal: not read remote repository. please make sure have correct access rights , repository exists. notice ssh is, reason, trying connect github.com.<company>.<name>.com instead of github.com . i have discovered following suspicious bit in /etc/resolve.conf : # common within <company> lookup hostnames dot in # example '<machine>.<site>'. set 'options ndots:2' such hostnames # tried first <company> search domains appended. without such # queries might ...

ruby on rails - Can't verify CRF token yet authenticity_token is in form parameters -

this question has answer here: rails: can't verify csrf token authenticity when making post request 2 answers i can see authenticity_token in form parameters when post yet getting error message: started post "/helloasdf/destroy_task?id=29" 127.0.0.1 @ 2017-08-19 21:12:14 -0400 processing taskcontroller#destroy_task js parameters: {"authenticity_token"=>"xxxx", "id"=>"29", "task_url"=>"helloasdf"} can't verify csrf token authenticity. completed 422 unprocessable entity in 1ms (activerecord: 0.0ms) (i changed token xxxx). what problem or doing wrong? my applicationcontroller has: class applicationcontroller < actioncontroller::base protect_from_forgery with: :exception this happened me while back, , couldn't figure out why out of blue started throwing er...

java - ByteBuddy Android - Create and call a method with a certain name that directly calls another method -

Image
this follow (though different) question thread: java - create anonymous exception subclass name i'm trying send non-crash error reports crashlytics on android , rafael winterhalter achieved displayed in different rows in crashlytics ui. requirement send different exception subclasses every issuetype. it looks in screenshot below now. next issue still doesn't show on 1 glance actual exception-type is. instead shows function-name error sent from. having learnt magic of byte buddy, thought - maybe it's possible create static function in custom exception subclass, directly calls crashlytics.logexception function. i've seen it's possible use interceptor class (and call code there), guess crashlytics show function name inside interceptor. is possible create static method name issuetype , have directly call crashlytics.logexception ? here's updated code far: public static void craslyticsrecorderror(string issuetype, string errormsg) { // byte bud...

How to read current time in Cloud function -

i using moment-timezone package read current time day of week. here code var moment = require('moment-timezone'); day_of_week = moment(req_date).tz("america/los_angeles").isoweekday(); console.log("day of week " + day_of_week); isoweekday should return monday 1 , sunday 7. on local development environment, works well. when code gets deployed on google cloud function, day_of_week monday returns day '7'. any ideas? what correct way read current time on google cloud function?

while loop - Control Menu in Java without case/break -

i'm trying create menu in java without case/breaks , having 2 issues. (1) when run program input should skip .hasnextint() while loop im having re-input user data program end. (2) .hasnextint() while loop not preventing associated error of user inputting wrong type of data. code still crashing string input instead of user being caught in while loop. public static void menu(library library){ scanner keyboard = new scanner(system.in); int selection = 999999; while(selection < 1 || selection > 5){ system.out.println("1. display books"); system.out.println("2. add book"); system.out.println("3. delete book"); system.out.println("4. exit program"); selection = keyboard.nextint(); while(!keyboard.hasnextint()){ system.out.println("re-enter integer value"); selection = keyboard.nextint(); } main calls menu. your current c...

arrays - How Do I update Javascript To Return 1 -

how change javascript update one? well there few of options here. first create prototype object , default value in constructor. i.e. function foo(name, quantity) { this.name = name; this.quantity = !quantity && quantity !== 0 ? 1 : quantity; } then, when instantiate array can use new foo(name, quantity); constructor create object, if quantity null or undefined , default value 1 used. var arr= [new foo('a', 1), new foo('b')]; see attached snipped examples on behavior of constructor falsy values . another option use foreach iterate throught array , reasign value of quantity if null , feels dirty. i.e. arr.foreach( x => { x.quantity = !x.quantity && x.quantity !== 0 ? 1 : x.quantity }) function foo(name, quantity) { this.name = name; this.quantity = !quantity && quantity !== 0 ? 1 : quantity; } var foo = new foo('stuff', null); console.log(json.stringify(foo, null, '\t')); f...

javascript - How to open different URLs by checkbox? -

this html , javascript code <input type="text" id="text" /> <input type="button" id="btn" value="submit" onclick="javascript: window.open('http://example.com/' + document.getelementbyid('text').value);" /> if input anytext in form box , click on submit button, open http://example.com/anytext . want add 3 checkbox named page1 page2 , page3 under form. if click on checkbox page1 , click on submit button, open http://example.com/page1/anytext how can it? you create function processes value of checkboxes , returns string need insert window.open call. this: onclick="javascript: window.open('http://example.com/' +getradiovalue() + document.getelementbyid('text').value);" also, note snippet won't redirect when click submit due sandbox restrictions on it, can see error in browser console , page code attempts redirect to. function getradiov...

swift - Convert NSDate to Date -

this might stupid question, can´t find information. i'm using coredata in app, , save array of structs. problem when fetch , try restore struct array, have problem date variable; can't find way convert nsdate date, try using as date , makes me force downcast , i'm not sure if it's safe. correct? or there way? this struc: struct mydata { var value = int() var date = date() var take = int() var commnt = string() } this how i'm fetchin data: func fetchrequestinfo() -> [mydata] { let fetchrequest: nsfetchrequest<glucoseevents> = glucoseevents.fetchrequest() { let searchresults = try databasecontroller.getcontext().fetch(fetchrequest) result in searchresults [glucoseevents] { let value = int(result.value) let date = result.date date let take = int(result.take) let commnt = string(describing: result.commnt) ...

tkinter image sizing with PIL -

from tkinter import * pil import imagetk, image import os root = tk() img = imagetk.photoimage(image.open("example_image.png")) panel = label(root, image = img) panel.pack(side = "bottom", fill = "both", expand = "yes") root.mainloop() root.minsize(width=250, height=275) root.maxsize(width=375, height=525) i've tried multiple things work it, no matter try, image remain same size. simplicity's sake, image 400x800, , want image scaled 125x250, modify above snippet (or redo it) achieve not ambitious goal? have window has min/max size of 250x350/375x525. image remains same size cut out , whole of image cannot seen, portion of image in window size can seen. there way modify size of image without having change actual image directly in other software? in advance, , ask if confused typed. here's code improved: from tkinter import * pil import imagetk, image import os def change_image_size(event): # function resizes o...

networking - Server process running on Indy10 partially stops responding when OnConnect event interacts with a TTabControls Tabs from another form in Lazarus -

tried describe of problem in title, , did. basically, i've made own little tcp server indy 10 in lazarus. accepts packets in form of bytes contain char representing letter english alphabet. i'm reading these bytes context s' iohandler this: procedure tserversideform.onexecuteserver(context: tidcontext); var io: tidiohandler; keypressed: char; begin // io := context.connection.iohandler; if not(io.inputbufferisempty) begin logform.logtoform('recieving packet ' + context.binding.ip + '(' + context.binding.peerip + ')'); keypressed := io.readchar; addkeytoappropriateclient(keypressed, context.binding.ip); end; indysleep(10); // end; and works perfectly. however, i've got form has ttabcontrol in it, has tab each user connected server, there tmemo in each tab. tabs , memos created @ runtime , function that, not throw exceptions. here's how addtab() function other form looks (for creating tabs , ...

C# WPF VS2017 - Forcing Aero theme -

Image
i'm trying fix rendering issue wpf app (a screensaver) wrote using vs2015 on windows 7. on windows 10, config window looks totally different and, more importantly, it's useless because of how renders in windows 10. here screenshots. first, windows 7 and windows 10 while there lots of little differences, , expect that, what's unforgivable coloring , cut off controls. check boxes checked , can't tell. radio buttons selected , can't tell. can't see bottom control. it's garbage. i did research , found override theme, forcing use of aero. don't know if fix problem , i'm having trouble making work. according research, if add following app.xaml, may fix things. <application.resources> <resourcedictionary source="/presentationframework.aero;component/themes/aero.normalcolor.xaml" /> <resourcedictionary source="pack://application:,,,/wpftoolkit;component/themes/aero.normalcolor.xaml" /...

java - How to do Android Motion Detection For Specific Area -

trying make motion detection app based on this project . intention make app take pictures when motion detected comparing 2 images. part, app working fine. requirement: to specify area of detection custom view. that, pictures captured if motion detected inside defined area calculating detection area. what have done far: created movable custom view, crop view of dimensions ( rect ) saved in preference each time when view moved. what not working: the motion detection inside custom view not working. believe bitmaps must cropped according size of custom view comparison. in detection thread tried setting width , height preference : private int width = prefe.detectionarea.width(); private int height = prefe.detectionarea.height(); but didn't work. please me explaining how achieved motion detection happen according size of custom view. appreciated. project source code: https://drive.google.com/drive/folders/0b7-okqt7w49mbtr6vwzyvurmvms motiondet...

javascript - i want to add and Retrieve image from firebase with js -

i wrote code , don't know why telling me err_file_not_found let database=firebase.database(); var filebutton = document.getelementbyid("filebutton"); var main = document.getelementbyid("main1"); var bildeurler =database.ref("bildeuler"); function largeurl(snap){ let url=snap.downloadurl; bildeurler.child("rose").set(url); } filebutton.addeventlistener('change', function(e){ var file = e.target.files[0]; var storageref = firebase.storage().ref('kora/'+file.name); storageref.put(file).then((largeurl)); }); function visbilder(snap){ let url=snap.val(); main.innerhtml+='<img src="${rose}">'; } bildeurler.on("child_added",visbilder);

r - Divide case by population -

in table2 dataset tidyr package, have: country year type count <chr> <int> <chr> <int> 1 afghanistan 1999 cases 745 2 afghanistan 1999 population 19987071 3 afghanistan 2000 cases 2666 4 afghanistan 2000 population 20595360 5 brazil 1999 cases 37737 6 brazil 1999 population 172006362 7 brazil 2000 cases 80488 8 brazil 2000 population 174504898 9 china 1999 cases 212258 10 china 1999 population 1272915272 11 china 2000 cases 213766 12 china 2000 population 1280428583 how code can divide type cases type population , multiply 10000. (yes, question r data science hadley wickham.) i've thought of: sum_1 <- vector() (i,j in 1:nrow(table2)) { if (i %% 2 != 0) { sum_1 <- (table2[i] / table2[j]) * 10000 assuming there 2 values 'type' each 'country', 'ye...

java - Getting ExceptioninitializerError in JUnit -

below error getting while running junit test case. while running junit test case sv code, getting below error, though sv code jars. code create virtual services. in case remove line "forget(url)......;" test case pass, else throws error. java.lang.exceptionininitializererror @ com.ca.svcode.protocols.http.agent.httpagentprotocol.getinterceptor(httpagentprotocol.java:77) @ com.ca.svcode.protocols.http.agent.httpagentprotocol.getinterceptor(httpagentprotocol.java:48) @ com.ca.svcode.engine.ipvconnectedserver.start(ipvconnectedserver.java:135) @ com.ca.svcode.engine.ipvprotocolserver.withconnection(ipvprotocolserver.java:67) @ com.ca.svcode.protocols.http.fluent.impl.httptransactionbuilderimpl.buildtransaction(httptransactionbuilderimpl.java:77) @ com.ca.svcode.protocols.http.fluent.abstracthttptransactionbuilder.doreturn(abstracthttptransactionbuilder.java:132) @ testclass.testsimplehttpgetwithresponsecodeandstringbody(testclass.java:25) @ sun.reflect.nativemethodaccess...

kotlin - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lorg/jetbrains/anko/collections/CollectionsKt; -

i tried creating simple kotlin program i'm encountering unknown errors , them. here gradle file , code i'm using: import android.support.v7.app.appcompatactivity import android.os.bundle import org.jetbrains.anko.button import org.jetbrains.anko.edittext import org.jetbrains.anko.verticallayout class mainactivity : appcompatactivity() { override fun oncreate(savedinstancestate: bundle?) { super.oncreate(savedinstancestate) verticallayout { edittext() button("ok") } } }

unity3d - Sound doesnt play when object collides with collider/ How to play sound and change scene at the same time - unity -

hello want sound play when gameobject collides collider. checked unity documentation , don't seem understand why not working. have audiosource applied collider. enter code here public audioclip impact; audiosource audiosource; void start(){ audiosource = getcomponent<audiosource>(); } void oncollisionenter2d(collision2d coll){ if (coll.gameobject.tag == "enemy") { audiosource.playoneshot (impact); application.loadlevel ("win"); } } } the problem in start function because 's'of start capital replace this void start() with void start() this fix null reference exception

reactjs - componentDidMount fires twice when using TransitionGroup for animation -

Image
i'm using react-transition-group in conjunction react-router-dom animate route changes , working fine. the issue i'm having when switching routes , need send or fetch data in componentdidmount life-cycle hook, fires twice. i'm sure due react-transition-group wondering if there obvious solution issue. i discovered inserting entity in database twice, far intended behavior. example of transition logging in componentdidmount i've found issue switch component, see github issue basically need location prop in wrapped switch component.

Jquery CSS and JS to limited elements -

i want apply jquery mobile css , js limited elements , no other elements on page. idea how can that. i have salesforce standard customer portal in including tab having jquery ,mobile , css. now when open tab in customer portal , overrides salesforce standard styling. thanks depending on jquery mobile version you're using. solution 1: modify global settings on mobileinit , setting ignorecontentenabled true . however, affects app performance negatively, slows down processing/initializing widgets/elements. <head> <script src="jquery.js"></script> <script> $(document).on("mobileinit", function () { $.mobile.ignorecontentenabled = true; }); </script> <script src="jquery-mobile.js"></script> <head> add data-enhance="false" elements or div want keep untouched jqm. <div data-role="content" data-enhance="false"> <!-- e...

java - Says "android.support.v4.app.FragmentTransaction" required -

this question has answer here: error: required: android:support.v4.fragmentmanager, found: android.app.fragmentmanager 3 answers android.support.v4.app.fragmenttransaction required 5 answers i trying change fragment on button click error getting in android studio says; incompatible types. required: android.support.v4.app.fragmenttransaction found: android.app.fragmenttransaction however using same package i.e. android.support.v4.app.fragmenttransaction. the code change fragment is; public void replacefragment(fragment somefragment) { fragmenttransaction transaction = getfragmentmanager().begintransaction(); transaction.replace(r.id.sgpa, somefragment); transaction.addtobackstack(null); transaction.commit(); } i hope have provided necessary information. ...

Angular 4 / Reactive form and json as select value -

i have reactive form created in component: this.details = this.formbuilder.group({ status: {} }); then in template have: <select class="form-control" formcontrolname="status"> <option *ngfor="let status of formvalues?.status" [ngvalue]="status">{{status.name}} {{status.description}}</option> </select> and onchanges called: this.details.setvalue({ status: this.data.status }); the idea is, have single select, has have object value. can't make status nested formgroup, since have spitted 3 formcontrols. works fine, despite setvalue. select not getting default data. however, when change option in select, form model updates correctly. any ideas :)? first off syntax option is: <option *ngfor="let entry of entries" [value]="entry">{{entry}}</option> value instead of ngvalue . secondly u need use 2 way data biding right values emited template m...

How to get name of connected UPnP-device with vb.net -

sounds rather simple, i'm stuck find way programmatically (vb.net) extract name of router connected lan! when click "connect-icon" on right side of tool-bar, name displayed (in case "d-link"). system knows name already. tried wmi , upnp not find query list name. can kinds of info little upnp-tool writes out maker , things, not name see connect-icon! can push me in right direction solution? please help! in advance effort! hans

sql server 2012 - Parallel Period give wrong values by using Calculated Member -

by using below mdx with member parallel_period sum ( (existing [timehierarchy].[hierarchy].[month].members) ,( parallelperiod ( [timehierarchy].[hierarchy].[year] ,1 ,[timehierarchy].[hierarchy].currentmember ) ,[measures].[sales value] ) ) select non empty { [measures].[lastyearsales] ,[measures].[sales value] ,parallel_period } on columns [reportive] { [timehierarchy].[hierarchy].[month].&[201612] ,[timehierarchy].[hierarchy].[month].&[201611] }; it returns value (115397005) right, when put in calculated member gives me wrong values advice?

C# javascript reload all tabs in Panel -

i using reload active tab: parent.parent.bodypanel.activetab.reload(); how can reload tabs of bodypanel @ once? solved reloading whole page: parent.parent.document.location.reload();

c# - How to calculate a value in WPF Binding -

i have app uses 2 sliders generate product used elsewhere in code. have product value bound textblock or tooltip, example, "10 x 15 = 150". the first part easy, , looks this: <textblock.text> <multibinding stringformat="{}{0} x {1}"> <binding elementname="amount_slider" path="value" /> <binding elementname="frequency_slider" path="value"/> </multibinding> </textblock.text> but what's nice easy way product in there well? using pavlo glazkov's solution, modified this: public class multiplyformulastringconverter : imultivalueconverter { public object convert(object[] values, type targettype, object parameter, cultureinfo culture) { var doublevalues = values.cast<double>().toarray(); double x = doublevalues[0]; double y = doublevalues[1]; var leftpart = x.tostring() + " x " + y.tostring(); ...

magento - PHP Redirecting by Accept_Language -

ok, i'm new php please bear me if make basic mistakes here: i'm trying magento 1.9.x shop redirect substore language. i've made this: function checkstorelanguage() { $result = ''; if (isset($_server['http_accept_language'])) { $langstring = strtolower(substr( $_server["http_accept_language"],0,2 )); if($langstring == 'da'){ $result = '/dk'; } elseif ($langstring == 'en'){ $result = '/uk'; } else { $result = '/eu'; } } return $result; } if ($_server['request_uri'] === '/') { header('location: '.checkstorelanguage()); exit; } now seems working in incognito-mode not in normal mode might cache thing, can cache affect server redirection , how avoid that? you can set http-response code 303 tell browser shouldn't cached. documentation/rfc : the 303 response must not ca...

ios - How To Use UITextField Instead Of UISearchBar In Objective-C -

i have searchbox in app. it's class uitextfield instead of uisearchbar. want set searchbar. each string entered @ time, (void)search function string. don't know how that. in fact want call (void)search after each character entered. -(void)textfielddidbeginediting:(uitextfield *)textfield { [self search]; } -(void)textfielddidendediting:(uitextfield *)textfield { [self search]; } you can use shouldchangecharactersinrange current user input - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string{ nsstring * searhquery = [[textfield text] stringbyreplacingcharactersinrange:range withstring:string]; [self search:searhquery]; return yes; }

Visual studio Visual basic And condition -

i trying update row in database using information form 2 dropdownlists locate correct row , using other dropdownlists replace information in row. "and" condition not work. have tried: &, &&, and, andalso. none of worked. the problem: an exception of type 'system.data.sqlclient.sqlexception' occurred in system.web.dll not handled in user code. additional information: incorrect syntax near keyword 'where'. my code is: dseditdeletemodulerelationships1.updatecommand = "update tbl_modules_modules set modules_id_fk2 = " & ddlprimary.selectedvalue & " modules_id_fk2 = " & ddlprimarymodule.selectedvalue & "where modules_id_fk3 = " & ddlsecondarymodule.selectedvalue dseditdeletemodulerelationships1.updatecommand = "update tbl_modules_modules set modules_id_fk3 = " & ddlsecondary.selectedvalue & " mod...

javascript - Pagination button in php won't work -

i have form. when click paginate button, nothing. how can solve problem? index.php: <?php include('phpcode.php'); $record_per_page = 5; $page_query = "select * student order id desc"; $page_result = mysqli_query($db, $page_query); $total_records = mysqli_num_rows($page_result); $total_pages = ceil($total_records/$record_per_page); ?> <?php if (isset($_get['edit'])) { $id = $_get['edit']; $edit_state = true; $rec = mysqli_query($db, "select * student id=$id"); if (count($rec) == 1 ) { $record = mysqli_fetch_array($rec); $name = $record['name']; $course = $record['course']; $age = $record['age']; $department = $record['department']; $dateadded = $record['dateadded']; $id = $record['id']; } } ?> <!doctype html> <html> <head> <meta name ="viewport" content="w...

c# - MDF file in windows application - after setup it become read only -

i have generated windows application. have used sql server .mdf database file. project working fine when have attached setup project , installed it. permission of .mdf file changed , become read not able write/update. i able change permission of .mdf file manually after working fine. not current way of deployment, guide me should can read, write , update properly. code or technique should use can so? i using : visual studio 2010 c# .mdf file of microsoft sql server 2008 express

Using an enum as a parameter and a return type in a function in C -

if decided use enum, such one: typedef enum { false, true = !false } bool; as parameter, , return type in function: bool foo(bool param) { <do something> return true; } would cause problems? example, across compilers. ps: don't intend use #include <stdbool.h> since don't intend #include <stdbool.h> (which might cause conflicts), there should not problem approach. however, if big project, others contribute too, wouldn't recommend go on approach, because might include header. moreover, if decide use code in future project of yours, pretty sure not remember detail prevention of including header, except if document nicely.

r - NWRFCSDK Libray for RSAP on windows 64 bit laptop -

i trying connect r x64 3.3.3 sap bi data cubes i have trouble installing pre-requisites please provide procedure install nwrfcsdk library , rsap package i getting error "there no package called ‘rsap’" - after installation of rsap

sql - MySQL Select - Merge rows when number -

i show results in 1 row , separated column specific values. mysql> +----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+------+---------------------+ -> | temp_series_id | co | dp | bo | dz | kt | kr | dr | gz | gp | pd | cd | date | -> +----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+------+---------------------+ -> | 272138 | 21.12 | null | null | null | null | null | null | null | null | null | null | 2017-08-20 14:06:46 | -> | 272138 | null | 20.06 | null | null | null | null | null | null | null | null | null | 2017-08-20 14:06:46 | -> | 272138 | null | null | 18.69 | null | null | null | null | null | null | null | null | 2017-08-20 14:06:46 | -> | 272138 | null | null | null | 21.81 | null | null | null | null | null | null...

python - pandas isin() function with lists -

i have 2 data frames , want use isin() method to check exists in df1 , in df2. when compare 1 column (index1) - result ok - 2 values of df1.index1 exists in df2.index1. but when compare 2 columns (index1, index2) of both df1 , df2 result false 3 rows, there 1 common row (index1 = 3, index2 = 6). why that? thanks. in [2]: import pandas pd in [3]: df1 = pd.dataframe({'a': [1,2,3], 'index1':[1,2,3], 'index2':[4,5,6]}) in [4]: df2 = pd.dataframe({'a': [4,5,6], 'index1':[2,3,4], 'index2':[7,6,5]}) in [5]: df1 out[5]: index1 index2 0 1 1 4 1 2 2 5 2 3 3 6 in [6]: df2 out[6]: index1 index2 0 4 2 7 1 5 3 6 2 6 4 5 in [7]: df1['index1'].isin(df2['index1']) out[7]: 0 false 1 true 2 true name: index1, dtype: bool in [8]: df1['index2'].isin(df2['index2']) out[8]: 0 false 1 tru...

javascript - Jquery stop rotation on hover -

$(function(){ var camera, renderer; var mpi=math.pi /180; var circleradius = 1000; var startangle = 0; var centerx = 0; var centerz = 0; var startradians = startangle + mpi; var totalspheres = 4; var incrementangle = 360/totalspheres; var incrementradians = incrementangle * mpi; var element = function ( id, dat, position, rotation ) { var html = [ '<div class="wrapper" >', '<ul class="stage clearfix">', '<li class="scene" >', '<div class="movie i1" id="' + id + '" >', '</div>', '</li>', '</ul>', '</div>' ].join('\n'); var div = document.createeleme...