Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
shagamemnon / react-atom-setup.sh
Created September 4, 2017 18:47
Package setup for React Nanodegree / Atom text editor
cd ~/.atom/packages && apm install chester-atom-syntax atom-beautify atom-transpose prettier-atom case-keep-replace change-case copy-path duplicate-line-or-selection editorconfig tab-foldername-index sync-settings atom-wrap-in-tag atom-ternjs autoclose-html autocomplete-modules docblockr emmet emmet-jsx-css-modules es6-javascript react-es7-snippets js-hyperclick hyperclick linter-eslint lodash-snippets language-babel atom-jest-snippets
@shagamemnon
shagamemnon / game.js
Created September 7, 2017 23:16
Stack Overflow // emscripten-canvas-jquery-toggle-focus
var layout = '<div class="game-title" style="position:fixed;left:0;right:0;top:100px;text-align:center"><h1>Frogger</h1><h3>Click a character to get started.</h3></div><div class="player-selection"> <img class="player" src="https://shagamemnon.github.io/frogger/images/char-boy.png" id="hero" alt="char-boy"><img class="player" src="https://shagamemnon.github.io/frogger/images/char-princess-girl.png" alt="char-princess-girl"> <img class="player" src="https://shagamemnon.github.io/frogger/images/char-pink-girl.png" alt="char-pink-girl"> </div><img id="enemy" src="https://shagamemnon.github.io/frogger/images/enemy-bug.png" style="display:none" alt="enemy"> <canvas id="canvas" class="game-canvas" style="margin-top:5px"></canvas> <div id="scoreboard" class="game-scoreboard"> <div class="row"><span>Level</span> <br><span id="level" tabindex="1">1</span> </div><div class="row"><span>Score</span> <br><span id="counter" class="game-score" tabindex="0">0</span> </div></div><div class="pause pause-button"></div><div clas
@shagamemnon
shagamemnon / example_request.cs
Last active September 19, 2017 19:27
Example C# HTTP Request
namespace MyNamespace {
public class MyRequest {
private async Task<bool> Request () {
// Replace MY_TOKEN with a test token object id
string url = "https://api.stripe.com/v1/charges?amount=1000&currency=usd&source=MY_TOKEN&description=Test%20charge%20to%20text%40example.com";
// Replace MY_SECRET_KEY with test secret key (e.g. sk_test_...)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (new Uri(url));
@shagamemnon
shagamemnon / backend.py
Last active September 20, 2017 11:23
Snippet for question number 4
...
def create_and_charge_customer():
token = request.form['token']
email = request.form['email']
amount_in_cents = int(10000)
try:
charge = stripe.Charge.create(
amount=amount_in_cents,
@shagamemnon
shagamemnon / gulpfile.babel.js
Created October 16, 2017 03:34 — forked from nicekiwi/gulpfile.babel.js
New ES6 project with Babel, Browserify & Gulp + Bundling/Watching Multiple Files
import gulp from 'gulp';
import sourcemaps from 'gulp-sourcemaps';
import buffer from 'gulp-buffer';
import uglify from 'gulp-uglify';
import tap from 'gulp-tap';
import browserify from 'browserify';
import babel from 'babelify';
gulp.task('build', () => {
/**
* IMPORTANT NOTE:
* When you try to run 301/302 redirects using Workers, the preview
* browser on the right of this script will throw an error. Disregard it!
*
* The script will function properly. The reason the preview browser runs
* into this problem is that it's actually trying to redirect you, but
* the Cloudflare dashboard is ensuring that you stay on the page to finish
* your code
*

Keybase proof

I hereby claim:

  • I am shagamemnon on github.
  • I am shagamemnon (https://keybase.io/shagamemnon) on keybase.
  • I have a public key ASDQzBR4cnFTxuE3KHiuTyfTRkepkGL4daWVylWV578q-go

To claim this, I am signing this object:

@shagamemnon
shagamemnon / install_node.sh
Last active July 13, 2018 03:05 — forked from carlosvillu/install_node.sh
Configure NodeJs + NPM + NGINX
#!/bin/bash
NODE_VERSION=0.4.10
NPM_VERSION=1.0.22
sudo apt-get update
sudo apt-get install -y build-essential git-core nginx libssl-dev pkg-config curl
# Install node
mkdir -p $HOME/local/node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
addEventListener('fetch', event => event.respondWith(handleRequest(event)))
async function cacheOnRequest (requestOrUrl, { headers, options }) {
let request = new Request(requestOrUrl)
/* You can pass a JSON object or a new Headers instance - both are accepted by
* the Service Workers spec
*/
if (headers && headers.req) {
request.headers = new Headers(request.headers)
addEventListener('fetch', e => e.respondWith(handleRequest(e.request)))
async function handleRequest(request) {
let url = new URL(request.url)
let params = new URLSearchParams(url.search.slice(1))
let features = {
minify: ['html', 'css', 'js'],
polish: ['lossy', 'lossless', 'off']
}