local

Function calls vs. local variables

谁都会走 提交于 2019-11-30 19:21:15
I often see functions where other functions are called multiple times instead of storing the result of the function once. i.e (1) : void ExampleFunction() { if (TestFunction() > x || TestFunction() < y || TestFunction() == z) { a = TestFunction(); return; } b = TestFunction(); } Instead I would write it that way, (2) : void ExampleFunction() { int test = TestFunction(); if (test > x || test < y || test == z) { a = test; return; } b = test; } I think version 2 is much better to read and better to debug. But I'm wondering why people do it like in number 1? Is there anything I don't see?

DateFormatter date from string returns nil

自作多情 提交于 2019-11-30 19:04:43
For some reason some devices fail to convert a string to a date. This is my date converting code: func dateFromString(string: String) -> Date? { let f = DateFormatter.init() f.dateFormat = "yyyy-MM-dd HH:mm:ss" return f.date(from: string) } Now, through my analytics platform I capture when this return nil. I have no clue why so. I assume it has something to do with local and maybe timezone or 12/24h settings but I can't figure out what is the problem. More Details... I have tracked the following settings that causes a nil return: timezone - Asia/Muscat local - en_GB string - "2016-12-18 08:31

use local image to display in webview for windows phone 8.1

扶醉桌前 提交于 2019-11-30 18:10:58
问题 I have created hybrid app in Windows phone 8.1 One of my pages uses the webview control. It has an img element on it. I have a small image as part of the build of my application. The 'copy to Output Directory' is set to 'Copy always' I have followed the instructions from this page: enter link description here None of the samples work. If I could assign that image in my c# code then that would be another alternative to use? I would need to know how to get the absolute path of my image in my

Automatically import a local CSV file with Javascript or Jquery

≯℡__Kan透↙ 提交于 2019-11-30 16:23:43
My client wants a website that includes importing CSV data WITHOUT it being hosted on a server. The idea is so that their sales people can demonstrate their products without having web access or hosting set up on their PCs. They will also be able to update the data by exporting a new CSV file from the original Excel document, without any knowledge of HTML or Javascript. I've found quite a few solutions online - like Papa Parse ( http://papaparse.com/ ) but all of them require the user to select a file using <input type="file" /> . As an example, the following script, using Papa Parse, works

R equivalent of Stata local or global macros

穿精又带淫゛_ 提交于 2019-11-30 14:45:23
I am a Stata user trying to learn R. I have a couple of lengthy folder paths which, in my Stata code, I stored as local macros. I have multiple files in both those folders to use in my analysis. I know, in R, I can change the working directory each time I want to refer to a file in one of the folders but it is definitely not a good way to do it. Even if I store the folder paths as strings in R, I can't figure out how to refer to those. For example, in Stata I would use `folder1'. I am wondering if trying to re-write Stata code line by line in R is not the best way to learn R. Can someone

iPhone: How to play local notification sound loud independent of volume setting?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 13:49:08
The FoneHome iPhone app has a feature where you can play a sound as part of a local notification. That sound is loud regardless of what the iPhone's volume level is set at. How is it possible to get a local notification (or push) to play an audio alert that is loud independent of what the current iPhone volume level is? I tried just setting the soundName to a WAV file but it plays at whatever the current volume is, and I see no options to set it otherwise. Try using the following code NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle]

Schedule notification using alarm manager in xamarin forms for android

不问归期 提交于 2019-11-30 13:05:06
I have created a dependencie to show the notifications In My DeviceDetails_Droid.cs I've set set alarm for 30 seconds The functionality for local notification works perfectly when app is active but when I killed the app (close app) the alarm receiver not getting called. public void ShowNotification(string message, string title) { Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver)); alarmIntent.PutExtra ("message", message); alarmIntent.PutExtra ("title", title); PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags

Defining Setter/Getter for an unparented local variable: impossible?

纵然是瞬间 提交于 2019-11-30 11:47:07
问题 There's a few previous questions on StackOverflow questioning how one goes about accessing local variables via the scope chain, like if you wanted to reference a local variables using bracket notation and a string, you'd need something like __local__["varName"] . Thus far I haven't found even the hackiest method for accomplishing this, and haven't come up with a method after hours of exploiting every trick I know. The purpose for it is to implement getters/setters on arbitrary unparented

SQLite database in Javascript locally

随声附和 提交于 2019-11-30 11:37:36
问题 I'm using a PhoneGap project on XCode. I am trying to connect to a SQLite databse by using Javascript. I have made a file "myDatabase.sqlite" in an SQLite tool. Now my question is how do I open that database in my code? Right now I'm using the following code: var db; var shortName = 'myDatabase'; var version = '1.0'; var displayName = 'myDatabase'; var maxSize = 65535; db = openDatabase(shortName, version, displayName,maxSize); db.transaction(function(transaction) { transaction.executeSql(

python dictionary passed as an input to a function acts like a global in that function rather than a local

雨燕双飞 提交于 2019-11-30 10:28:23
问题 I am very confused by the behaviour below. Cases 1, 3, and 4 perform as I would expect, but case 2 does not. Why does case 2 allow the function to change the value of the dictionary entry globally, even though the dictionary is never returned by the function? A main reason I am using functions is to isolate everything in the function from the rest of the code, but this does not seem to be possible if I choose to use the same variable names inside of the function. I was under the understanding