Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
@icodeforlove
icodeforlove / ScrollRestoration.tsx
Last active July 24, 2024 10:11
ScrollRestoration for React
'use client';
import { useEffect } from 'react';
function ScrollRestoration() {
useEffect(() => {
const pushState = history.pushState;
history.pushState = function (data, unused, url) {
const scrollY = window.scrollY;
@icodeforlove
icodeforlove / ResizeHandle.js
Created April 15, 2019 12:23
Custom window resize handle for nw.js
import React, { useState, useEffect } from 'react';
const {
resizeWindowTo
} = nw.global;
function ResizeHandle () {
let timeout,
startW,
startH,
@icodeforlove
icodeforlove / worker.js
Last active May 31, 2018 00:02
GDPR Block All European Countries (Cloudflare Worker)
const BLOCKED_COUNTRIES = [
'AL', 'AD', 'AM', 'AT', 'BY', 'BE', 'BA', 'BG', 'CH', 'CY', 'CZ', 'DE',
'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GE', 'GI', 'GR', 'HU', 'HR',
'IE', 'IS', 'IT', 'LT', 'LU', 'LV', 'MC', 'MK', 'MT', 'NO', 'NL', 'PL',
'PT', 'RO', 'RU', 'SE', 'SI', 'SK', 'SM', 'TR', 'UA', 'VA'
];
addEventListener('fetch', event => {
event.respondWith((async request => {
let country = request.headers.get('CF-IpCountry'),

Keybase proof

I hereby claim:

  • I am icodeforlove on github.
  • I am icodeforlove (https://keybase.io/icodeforlove) on keybase.
  • I have a public key ASCiKauZxmftV2AKdSE2hZh4cpakK0fdE8yx7A-zCMZWiQo

To claim this, I am signing this object:

@icodeforlove
icodeforlove / java to smali.sh
Created December 9, 2016 11:09
commands to see java converted into smali
javac -source 1.7 -target 1.7 HelloWorld.java
sudo dx --dex --output=classes.dex HelloWorld.class
java -jar ~/bin/baksmali.jar disassemble classes.dex
@icodeforlove
icodeforlove / generateTK.js
Created November 22, 2016 21:35
Generate the tk for signing the google translate payload
var generateTK = (function () {
function b(a, b) {
for (var d = 0; d < b.length - 2; d += 3) {
var c = b.charAt(d + 2),
c = 'a' <= c ? c.charCodeAt(0) - 87 : Number(c),
c = '+' == b.charAt(d + 1) ? a >>> c : a << c;
a = '+' == b.charAt(d) ? a + c & 4294967295 : a ^ c;
}
# LSI doesnt support JBOD, but what we can do is set each drive as raid0 and enable caching
MegaCli -CfgLdAdd -r0[252:0] WB RA Cached CachedBadBBU -strpsz512 -a0
MegaCli -CfgLdAdd -r0[252:1] WB RA Cached CachedBadBBU -strpsz512 -a0
MegaCli -CfgLdAdd -r0[252:2] WB RA Cached CachedBadBBU -strpsz512 -a0
MegaCli -CfgLdAdd -r0[252:3] WB RA Cached CachedBadBBU -strpsz512 -a0
/*! task.js - 0.0.17 - clientside/minified */
var task=function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=r(1),o=n(i),s=r(3),a=n(s),u=r(4),l=n(u),c={maxWorkers:navigator.hardwareConcurrency},f=r((0,o["default"])()?5:7);t.exports=new a["default"](c,f),t.exports.defaults=(0,l["default"])(c,f,a["default"])},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=r(2),o=n(i);t.exports=function(){if("undefined"!=typeof Worker&&(window.URL||window.webkitURL))try{var t=new Worker((0,o["default"])(function(){}));return t.terminate(),!0}catch(e){}return!1}},function(t,e){"use strict";t.exports=function(t){var e,r=t.toString();r=r.substring(r.indexOf("{")+1,r.lastIndexOf("}"));try{e=new Blob([r],{type:"text/javascript"})}catch(n){window.BlobBuilder=window.
@icodeforlove
icodeforlove / Float32Array.concat.js
Last active March 7, 2022 23:09
Float32Array concatenation uses buffers
Float32Array.prototype.concat = function() {
var bytesPerIndex = 4,
buffers = Array.prototype.slice.call(arguments);
// add self
buffers.unshift(this);
buffers = buffers.map(function (item) {
if (item instanceof Float32Array) {
return item.buffer;
@icodeforlove
icodeforlove / Easing.js
Last active June 18, 2016 04:11
nice set of easing javascript functions
function EasingClamp (func) {
return function (k) {
k = Math.min(Math.max(func(k), 0), 1);
return isNaN(k) ? 0 : k;
};
}
var Easing = {
Linear: {
None: EasingClamp(function (k) {
return k;