This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://speakingjs.com/es5/ch17.html#code_copyOwnPropertiesFrom | |
// To create an identical copy of an object, you need to get two things right: | |
// - The copy must have the same prototype as the original. | |
// - The copy must have the same properties, with the same attributes as the original. | |
function copyObject(orig, deep) { | |
// 1. copy has same prototype as orig | |
var copy = Object.create(Object.getPrototypeOf(orig)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = [1, 2, 3]; | |
var bar = [1, 2, 3]; | |
var foo2 = foo; | |
var bar2 = bar; | |
// assigns a reference to a new array to a variable, while any other references are unaffected | |
foo = []; | |
// deletes everything in the array, which does hit other references | |
bar.length = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test Build (armv7 only) | |
# | |
ionic platform remove ios | |
gulp useref | |
ionic platform add ios | |
cp assets/build/ios/build.xcconfig platforms/ios/cordova/build.xcconfig | |
ionic build ios --device | |
xcrun -sdk iphoneos PackageApplication -v platforms/ios/build/device/appname.app -o deployments/appname-test.ipa | |
/usr/bin/codesign --display platforms/ios/build/device/appname.app | |
/usr/bin/codesign --verify platforms/ios/build/device/appname.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to return boolean value in a cordova android plugin | |
public class ExampleClass extends CordovaPlugin { | |
@Override | |
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { | |
if (action.equals("test")) { | |
try { | |
boolean result = testAction(); | |
callbackContext.sendPluginResult(new PluginResult(Status.OK, result)); | |
} catch (Exception e) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('myApp', []); | |
app.directive('consecutive', function () { | |
return { | |
require: 'ngModel', | |
restrict: 'A', | |
priority: 50, | |
link: function(scope, elem, attrs, ctrl) { | |
if (!ctrl) return; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Note: this code is for Angular.js v1.3 or earlier | |
* In Angular.js v1.4+ you can use angular.merge() | |
* | |
* Extends the destination object `dst` by copying all of the properties from the `src` object(s) | |
* to `dst`. You can specify multiple `src` objects. | |
* @param {Boolean} deep If true, the merge becomes recursive (optional aka deep copy) | |
* @param {Object} dst Destination object. | |
* @param {Object} src Source object(s). | |
* @returns {Object} Reference to `dst`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parse URL | |
// References: | |
// http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ | |
// https://github.com/angular/angular.js/blob/c94329a891a1c082567c490ccf58ba8592b464ad/src/ng/urlUtils.js | |
(function() { | |
window.parseUrl = function(url) { | |
var href = url, | |
a = document.createElement('a'); | |
if (document.documentMode) { | |
a.setAttribute('href', href); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* RSA Encrypt a String with Public Key | |
* | |
* @uses forge encryption library | |
* @param <String> text - string to encode | |
* @param <BigInteger> modulus - public key modulus | |
* @param <BigInteger> exponent - public key exponent | |
* @return <String> - encoded string in hex | |
*/ | |
function RSAEncrypt(text, modulus, exponent) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Apply CDATA tags in XSLT | |
--> | |
<xsl:template match="/"> | |
<DOCUMENT> | |
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text> | |
<xsl:apply-templates /> | |
<xsl:text disable-output-escaping="yes">]]></xsl:text> | |
</DOCUMENT> | |
</xsl:template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem print timestamp (valid for Hungarian language settings) | |
rem result: 2014.08.29. 13:48:52 | |
set datecode=%date:~0,4%.%date:~5,2%.%date:~8,2%. %time:~0,2%:%time:~3,2%:%time:~6,2% | |
echo %datecode% | |