Skip to content

Instantly share code, notes, and snippets.

export default function importModule(moduleName) {
return new Promise(resolve => {
require.ensure([moduleName], () => {
resolve(require(moduleName));
});
});
}
VBoxManage modifyvm "OSX" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "OSX" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "OSX" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "OSX" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "OSX" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "OSX" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
@viankakrisna
viankakrisna / php2jsx.js
Last active April 26, 2017 13:18
php2jsx
var string = `copy your php here`
console.log(
string
.replace(/class=/g, 'className=')
.replace(/<\?php/g, '{')
.replace(/\?>/g, '}')
.replace(/echo/g, '')
.replace(/{ endif; }/g, '}')
@viankakrisna
viankakrisna / restate.js
Last active February 21, 2017 22:15
state-component -- state manager using React's own state
let persist = false;
let ref = null;
export function setStateContainer(componentInstance, isPersist) {
ref = componentInstance;
persist = isPersist;
}
export function isPersist() {
return persist;
import sanitizeQuery from 'helper/sanitizeQuery';
import serialize from 'helper/serialize';
const getSuccessActionType = KEY =>
type => [ KEY, type.toUpperCase(), 'SUCCESS' ].join('_');
const initialCollectionState = {
items: {},
list: {},
infiniteList: {},
#taken from https://coderwall.com/p/guqrca/remove-all-node_module-folders-recursively
find . -name "node_modules" -exec rm -rf '{}' +
@viankakrisna
viankakrisna / 0_reuse_code.js
Created March 2, 2017 19:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
for f in $(find $dir -name '*.php');
do
(./wp-phptidy.php replace $f)
done
for f in $(find $dir -name '*.phptidybak~');
do
(rm -f $f)
done
function elt(name, attributes) {
var node = document.createElement(name);
if (attributes) {
for (var attr in attributes)
if (attributes.hasOwnProperty(attr))
node.setAttribute(attr, attributes[attr]);
}
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child == "string")
@viankakrisna
viankakrisna / ledux.js
Last active April 11, 2017 20:27
re-implementation of redux and react-redux by 52 LOC https://www.webpackbin.com/bins/-KhSxnW73-R4iCMwdfnW
import React from "react";
let store;
export default function createStore(
reducer,
initialState = {},
...middlewares
) {
const subscribers = [];
let newState = initialState;