Skip to content

Instantly share code, notes, and snippets.

View evanlouie's full-sized avatar

Evan Louie evanlouie

View GitHub Profile
@evanlouie
evanlouie / filename_extractor.regex
Last active August 29, 2015 14:09
Extract filename from directory
.*(?:\/)
@evanlouie
evanlouie / CraftSchematicMatrixConverter.php
Created April 27, 2017 23:47
Schematic Schema FieldTab to Matrix Dumper
<?php
public function actionDumpFields()
{
$name = 'Resource';
$matrixFieldHandle = 'resource';
$section = 'resources';
$entryType = 'resources';
$schema = CRAFT_CONFIG_PATH.'/schema.yml';
@evanlouie
evanlouie / types.js
Created August 31, 2017 21:37
Types Installer
const package ={
"name": "project-euler",
"version": "1.0.0",
"description": "Evan Louie's solutions to the problems found on https://projecteuler.net",
"main": "./dist/bundle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack -p --progress",
"watch": "webpack -d --progress --watch"
},
@evanlouie
evanlouie / parallelPromises.js
Created September 28, 2017 19:53
Limiting Concurrrent Execution
async function concurrent(maxConcurrency = 4) {
const thingsToOperateOn = [];
const createConcurrentPromise = () => {
const thing = thingsToOperateOn.shift();
return new Promise((resolve, reject) => {
// Do something to thing
console.log(thing);
})
.then(() => {
createConcurrentPromise();
@evanlouie
evanlouie / tmobile-dethrottle.sh
Created October 17, 2017 18:46
Bypass T-Mobile Tether Throttling
sudo sysctl -w net.inet.ip.ttl=65
# functional
Enum.sum(Integer.digits(trunc(:math.pow(2,1000))))
# Pipe
:math.pow(2,1000) |> trunc |> Integer.digits |> Enum.reduce(&(&1+&2))
@evanlouie
evanlouie / euler.js
Last active May 8, 2018 02:51
Project Euler solutions in JS
// Some of these answers will only run in Firefox (browsers which support TCO)
/**
* Problem 1
* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
* Find the sum of all the multiples of 3 or 5 below 1000.
*/
const problem1 = () => {
return Array(1000)
.fill(null)
@evanlouie
evanlouie / turbo_inject.js
Created December 13, 2017 01:37
Attach Turbolinks to page
script = document.createElement('script')
script.src = "https://cdn.rawgit.com/turbolinks/turbolinks/1066805f/dist/turbolinks.js"
document.head.appendChild(script)
@evanlouie
evanlouie / emacs26.sh
Created May 7, 2018 08:33 — forked from kissge/emacs26.sh
Compile Emacs 26 on Ubuntu 16.04 on Windows Subsystem for Linux (WSL, aka Bash on Ubuntu on Windows)
mkdir emacs
cd emacs
git init
git remote add origin https://github.com/emacs-mirror/emacs.git
git fetch --depth 1 origin emacs-26
git reset --hard FETCH_HEAD
sudo apt install autoconf make gcc texinfo libgtk-3-dev libxpm-dev libjpeg-dev libgif-dev libtiff5-dev libgnutls-dev libncurses5-dev
./configure
make
sudo make install
@evanlouie
evanlouie / spacemacs-cheshe.md
Created May 7, 2018 22:15 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers