Skip to content

Instantly share code, notes, and snippets.

View bingzer's full-sized avatar

Ricky Tobing bingzer

View GitHub Profile
@bingzer
bingzer / AspIfTagHelper.cs
Created March 14, 2023 12:05
If block TagHelper
[HtmlTargetElement("*", Attributes = "[asp-if]")]
public class IfTagHelper : TagHelper
{
/// <summary>
/// Shows the element when this condition is true
/// </summary>
[HtmlAttributeName("asp-if")]
public bool IsTrue { get; set; } = true;
public override void Process(TagHelperContext context, TagHelperOutput output)
@bingzer
bingzer / stringify.js
Created February 21, 2021 01:27 — forked from cowboy/stringify.js
JavaScript: like JSON.stringify but handles functions, good for creating arbitrary .js objects?
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 February 15, 2021 23:47 — forked from softwarespot/evaluate.js
Pass context to eval()
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 September 25, 2013 22:26
AndroidStudio updating crash log (EventViewer)
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:
@bingzer
bingzer / card_background.xml
Created August 30, 2013 18:30
Card card card
<?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" />
db.get("Table")
.update("Name = ?, Test = ?, Age = ?", "", 12, 12)
.
=.?\?(.?,)?
=.*?\?(.*?(,|;|.))?
=.*?\?(.*?(,|;|.))?.
@bingzer
bingzer / write pom.xml
Created August 7, 2013 18:24
Create pom.xml from gradle build
...
pom {
project {
artifactId = archivesBaseName
groupId = group
version = version
}
}.writeTo('$buildDir/pom.xml')
...
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'android'
@bingzer
bingzer / build.gradle
Last active December 20, 2015 09:19
Android Gradle Build: Create apk name with its versioning. i.e: MyAppName-1.1.1-release.apk
android {
...
applicationVariants.each { variant ->
def apk = variant.outputFile
def name = apk.getName().replace('.apk', versionName + '.apk');
variant.outputFile = new File(apk.parentFile, name);
}
...