Skip to content

Instantly share code, notes, and snippets.

@wogsland
wogsland / SingleArrow.ipynb
Created August 23, 2019 15:45 — forked from vakila/SingleArrow.ipynb
Anjana Vakil, "The Universe in a Single Arrow", JSHeroes 2019
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wogsland
wogsland / pip
Last active February 4, 2017 17:27
// the "old" way
$ pip freeze > requirements.txt
// looks at imports in your codebase and only includes those in requirements
$ pipreqs
// find out what dependencies need updating
$ pip list --outdated
// why are these packages here?
import collections
import fileinput
import os
def find_files(path='.', ext='.py'):
for root, dirs, filenames in os.walk(path):
for filename in filenames:
if filename.endswith(ext):
yield(os.path.join(root, filename))
def is_line(line):
@wogsland
wogsland / background.js
Created May 31, 2016 20:51 — forked from omarstreak/background.js
Chrome API Extension
//oauth2 auth
chrome.identity.getAuthToken(
{'interactive': true},
function(){
//load Google's javascript client libraries
window.gapi_onload = authorize;
loadScript('https://apis.google.com/js/client.js');
}
);
@wogsland
wogsland / pre-commit
Created August 13, 2015 18:55
Git Pre-Commit Hook
#!/bin/sh
# Inside any git tracked repository...
# cp pre-commit path/to/project/.git/hooks/pre-commit
# chmod +x path/to/project/.git/hooks/pre-commit
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
@wogsland
wogsland / swagger_definition.json
Created June 21, 2015 17:32
Swagger Definition
"ApiResponse": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"success": {
"type": "boolean"
},
"message": {
@wogsland
wogsland / swagger_path.json
Last active August 29, 2015 14:23
Swagger Path
"/advertisers/create": {
"post": {
"tags": [
"advertisers"
],
"summary": "Creates an advertiser",
"description": "This endpoint is for the creation of an advertiser....",
"operationId": "create",
"produces": [
"application/json"
@wogsland
wogsland / swagger_high_level.json
Last active August 29, 2015 14:23
Swagger High Level
{
"swagger": "2.0",
"info": {
"description": "Enter your API key in the upper right and click on an endpoint below to start testing!",
"version": "v1",
"title": "API Documentation",
"termsOfService": "http://www.leadspedia.com/saas-subscription-agreement.html",
"contact": {
"email": "support@leadspedia.com"
}
@wogsland
wogsland / float.php
Last active August 29, 2015 14:22
PHP Floating Point Numbers Suck...
<?php
var_dump((31 - 18.6));
// float(12.4)
var_dump((31 - 18.6) > 12.4);
// bool(false)
var_dump((31 - 18.6) < 12.4);
// bool(true) WTF?!?!!?