Skip to content

Instantly share code, notes, and snippets.

Avatar

Ricky Tobing bingzer

View GitHub Profile
@bingzer
bingzer / stringify.js
Created Feb 21, 2021 — forked from cowboy/stringify.js
JavaScript: like JSON.stringify but handles functions, good for creating arbitrary .js objects?
View stringify.js
var stringify = function(obj, prop) {
var placeholder = '____PLACEHOLDER____';
var fns = [];
var json = JSON.stringify(obj, function(key, value) {
if (typeof value === 'function') {
fns.push(value);
return placeholder;
}
return value;
}, 2);
@bingzer
bingzer / evaluate.js
Created Feb 15, 2021 — forked from softwarespot/evaluate.js
Pass context to eval()
View evaluate.js
function evaluate(code, args = {}) {
// Call is used to define where "this" within the evaluated code should reference.
// eval does not accept the likes of eval.call(...) or eval.apply(...) and cannot
// be an arrow function
return function evaluateEval() {
// Create an args definition list e.g. "arg1 = this.arg1, arg2 = this.arg2"
const argsStr = Object.keys(args)
.map(key => `${key} = this.${key}`)
.join(',');
const argsDef = argsStr ? `let ${argsStr};` : '';
@bingzer
bingzer / Crash and Burn
Created Sep 25, 2013
AndroidStudio updating crash log (EventViewer)
View Crash and Burn
Faulting application name: java.exe, version: 7.0.400.43, time stamp: 0x521c3d55
Faulting module name: ntdll.dll, version: 6.2.9200.16579, time stamp: 0x51637f77
Exception code: 0xc0000374
Fault offset: 0x00000000000ebd59
Faulting process id: 0x14c4
Faulting application start time: 0x01ceba3c7c7a19fe
Faulting application path: C:\Program Files\Java\jdk1.7.0_40\jre\bin\java.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: ba6238e6-262f-11e3-beac-78e3b5b94d68
Faulting package full name:
View card_background.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#CCC" />
</shape>
</item>
<item android:bottom="2.5dp" android:left="1dp" android:right="1dp" android:top="0.5dp">
<shape android:shape="rectangle">
<solid android:color="#FFF" />
View Update Expression
db.get("Table")
.update("Name = ?, Test = ?, Age = ?", "", 12, 12)
.
=.?\?(.?,)?
=.*?\?(.*?(,|;|.))?
=.*?\?(.*?(,|;|.))?.
@bingzer
bingzer / write pom.xml
Created Aug 7, 2013
Create pom.xml from gradle build
View write pom.xml
...
pom {
project {
artifactId = archivesBaseName
groupId = group
version = version
}
}.writeTo('$buildDir/pom.xml')
...
View AndroidAnnoation + Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'android'
@bingzer
bingzer / build.gradle
Last active Dec 20, 2015
Android Gradle Build: Create apk name with its versioning. i.e: MyAppName-1.1.1-release.apk
View build.gradle
android {
...
applicationVariants.each { variant ->
def apk = variant.outputFile
def name = apk.getName().replace('.apk', versionName + '.apk');
variant.outputFile = new File(apk.parentFile, name);
}
...