Skip to content

Instantly share code, notes, and snippets.

View bingzer's full-sized avatar

Ricky Tobing bingzer

View GitHub Profile
@bdebaere
bdebaere / MyDbContext.cs
Last active June 26, 2023 15:13
Apply WITH(NOLOCK) to every table in EntityFrameworkCore 3.x
public class MyDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(connectionString);
optionsBuilder.ReplaceService<IQuerySqlGeneratorFactory, WithNolockQuerySqlGeneratorFactory>();
base.OnConfiguring(optionsBuilder);
}
@drovani
drovani / shopify-multipass-demo.cs
Last active February 18, 2022 10:19
Sample C# Code to Generate Shopify Multipass Url
string secret = "[shopify-multipass-secret]";
string store = "[shopify-store]";
var json = System.Text.Json.JsonSerializer.Serialize(new {
email = "[customer-email]",
created_at = DateTime.Now.ToString("O"),
identifier = "[customer-uid]",
//remote_ip = ""
});
var hash = System.Security.Cryptography.SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(secret));
@softwarespot
softwarespot / evaluate.js
Last active July 28, 2023 12:56
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};` : '';
@martinnedopil
martinnedopil / ITable.java
Created October 1, 2014 05:28
DbQuery files to implement leftJoin
/**
* Copyright 2014 Ricky Tobing
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rock3r
rock3r / WidgetHelper.java
Last active August 29, 2015 13:57
How to update an homescreen widget (the right way)
package net.frakbot.gists.widgethelper;
/*
* Copyright 2014 Sebastiano Poggi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@khernyo
khernyo / build.gradle
Created December 6, 2012 18:39
Gradle Android configuration with .so hack
// This hack works with com.android.tools.build:gradle:0.2, won't work in later version without modification
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@cowboy
cowboy / stringify.js
Created September 19, 2012 13:45
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);