Skip to content

Instantly share code, notes, and snippets.

View benloong's full-sized avatar

benloong benloong

View GitHub Profile
@benloong
benloong / NesteScrollRect.cs
Created December 28, 2022 08:00 — forked from Josef212/NesteScrollRect.cs
A nested ScrollRect for unity
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class NestedScrollRect : ScrollRect
{
public override void OnInitializePotentialDrag(PointerEventData eventData)
{
for(int i = 0; i < m_parentInitializePotentialDragHandlers.Length; ++i)
{
@benloong
benloong / README-Template.md
Created January 11, 2019 09:14 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@benloong
benloong / copyContent.js
Last active November 29, 2021 21:48 — forked from coclav/copyContent
Copy file out of ASAR archive for Electron app
var fs = require("fs");
var path = require("path")
var app = require("electron").remote.app;
// var fsj = require("fs-jetpack");
// example usage : copyFileOutsideOfElectronAsar( "myFolderInsideTheAsarFile", app.getPath("temp") + "com.bla.bla"
var copyFileOutsideOfElectronAsar = function (sourceInAsarArchive, destOutsideAsarArchive) {
// http:// stackoverflow.com/questions/23202489/how-does-this-code-find-the-number-of-trailing-zeros-from-any-base-number-factor
// https://comeoncodeon.wordpress.com/2010/02/17/number-of-zeores-and-digits-in-n-factorial-in-base-b/
function zeroes (base, number) {
var noz = Number.MAX_VALUE;
// Now we can break the Base B as a product of primes :
// B = a^p1 * b^p2 * c^p3 * …
//Then the number of trailing zeroes in N factorial in Base B is given by the formulae
// min{1/p1(n/a + n/(a*a) + ….), 1/p2(n/b + n/(b*b) + ..), ….}.
var j = base;
@benloong
benloong / UIDissolve.shader
Last active April 17, 2024 20:30 — forked from nukeop/dissolve.shader
Dissolve shader for Unity
Shader "UI/Dissolve"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@benloong
benloong / ExportSprites.cs
Created July 11, 2016 03:52 — forked from tsubaki/ExportSprites.cs
Load Multiple Sprite with scriptableObject
using UnityEngine;
using System.Collections;
using UnityEditor;
public class ExportSprites {
[MenuItem("Assets/Create/SpriteScriptableObject")]
static void Export()
{
foreach (var sprite in Selection.objects) {
@benloong
benloong / pattern-examples.swift
Created January 21, 2016 02:01 — forked from terhechte/pattern-examples.swift
Swift pattern examples for the swift, for, and guard keywords
import Foundation
// 1. Wildcard Pattern
func wildcard(a: String?) -> Bool {
guard case _? = a else { return false }
for case _? in [a] {
return true
}
public static int getVersionCode(Context ctx) {
int versionCode = 0;
try {
PackageInfo pInfo = ctx.getPackageManager().getPackageInfo(
ctx.getPackageName(), 0);
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
// C++11 32bit FNV-1 and FNV-1a string hasing (Fowler–Noll–Vo hash)
//
// Requires a compiler with C++11 support
// See main(...) for examples
#include <iostream>
#include <cassert>
namespace hash
{