Skip to content

Instantly share code, notes, and snippets.

⚛️
slingin code

Phil upvalue

⚛️
slingin code
View GitHub Profile
View routed_cloud_function.py
# hack together router with werkzeug because google cloud functions does not
# support full flask apps
from werkzeug.routing import Map, Rule, NotFound
from werkzeug.exceptions import MethodNotAllowed, HTTPException
url_map = []
def route(path, methods=("GET",)):
def decorator(fn):
View clone.fish
# https://news.ycombinator.com/item?id=18214677
# clone foo/bar => git clone https://github.com/foo/bar
function clone; git clone --recursive https://github.com/$argv; end
@upvalue
upvalue / empty-gql.js
Created Jul 10, 2018
Empty gql tag to get VSCode IDE features without any library dependencies
View empty-gql.js
const gql = (strings: ReadonlyArray<string>) => {
return strings.join('');
}
View gist:99b5d6775a9e292f1df0de0920369eec
For future reference:
- Check proxy is set
- Check that deployment branch is set if not developing on master
- Check that letsencrypt is set
@upvalue
upvalue / index.tsx
Last active Jan 13, 2018
TypeScript + React + mobx-state-tree
View index.tsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import { types } from 'mobx-state-tree';
const Todo = types.model({
@upvalue
upvalue / circleci-try.sh
Last active Aug 21, 2017
Try a new CircleCI config without committing
View circleci-try.sh
#!/usr/bin/env bash
# circleci-try.sh -- Tries to run a new .circleci/config.yml from a checked out github repo without committing
# Usage: circleci-try.sh from the toplevel of a Git repo
# Requires $CIRCLECI_CLI_TOKEN to be set
# Thanks: https://discuss.circleci.com/t/running-new-config-files-without-committing/11842
set -x
GITHUB_REPO_STR=`git config --get remote.origin.url`
RESULT=$?
@upvalue
upvalue / bootstrap.scss
Created Jul 31, 2017
strip unneeded bootstrap components
View bootstrap.scss
@import "~bootstrap/scss/variables";
@import "~bootstrap/scss/mixins";
@import "~bootstrap/scss/custom";
// Reset and dependencies
@import "~bootstrap/scss/normalize";
@import "~bootstrap/scss/print";
// Core CSS
@import "~bootstrap/scss/reboot";
@upvalue
upvalue / tslint.json
Created Jul 3, 2017
tslint.json that mostly follows tslint-config-airbnb; requires tslint-config-airbnb to be installed
View tslint.json
{
"defaultSeverity": "error",
"extends": [
"tslint-config-airbnb"
],
"jsRules": {},
"rules": {
"align": [false],
"import-name": false,
"variable-name": false
@upvalue
upvalue / settings.json
Last active Jul 2, 2017
vscode settings
View settings.json
// settings.json - VSCode settings
{
"editor.fontSize": 12,
"editor.lineNumbers": "relative",
"workbench.colorTheme": "Zenburn",
"window.menuBarVisibility": "toggle",
"typescript.check.tscVersion": false,
"editor.tabSize": 2,
"editor.renderWhitespace": "boundary",
"editor.rulers": [100],
@upvalue
upvalue / cloccomment.py
Last active Jun 10, 2017
count comments as a percentage of LOC with cloc
View cloccomment.py
#!/usr/bin/env python
# cloccomment.py - using cloc, return percentage of code that is comments
# usage: cloccomment <arguments to be passed to cloc>
import sys
import subprocess
args = sys.argv[1:]
results = subprocess.check_output(['cloc'] + args).decode('utf-8')
You can’t perform that action at this time.