Skip to content

Instantly share code, notes, and snippets.

# Scroll to bottom for python code
# most of this is json data
items = [
{
"name" : {
"japanese" : "マスターボール",
"english" : "Master Ball",
"chinese" : "大师球"
},
# https://probablydance.com/2016/02/27/functional-programming-is-not-popular-because-it-is-weird/
# Banana Cake recipe
# source: http://allrecipes.com/Recipe/A-Number-1-Banana-Cake/
#
# 1. Preheat oven to 175 degrees C. Grease and flour 2 – 8 inch round pans.
# In a small bowl, whisk together flour, baking soda and salt; set aside.
#
# 2. In a large bowl, cream butter, white sugar and brown sugar until light and fluffy.
# Beat in eggs, one at a time. Mix in the bananas. Add flour mixture alternately
@classmember
classmember / commands.md
Last active September 16, 2019 13:17
commands

Node

Environment

Install latest nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

Install latest npm

nvm install node --reinstall-packages-from=node
#!/usr/bin/env python
'''
imports user from csv in format:
<email address>, <first name>, <last name>
'''
import csv
from subprocess import call as run
FILE='example.csv'
@classmember
classmember / brython example
Created July 1, 2019 13:18
Python in the browser
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.3/brython.min.js"> </script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.3/brython_stdlib.js"></script>
</head>
<body onload="brython()">
<script type="text/python">
from browser import document, alert
def echo(event):

Watching all layers of Python code

We're going to dive into how languages interact as a stack. First, we'll download the a copy of Python and compile with GNU debugging tags enabled. I hope you're ready to watch registers in the processor flutter and C code scroll. We start by opening our favorite terminal.

Compile a debugging build of Python

Go to the directory the debugging build will be installed in

cd /opt/
upstream php {
server unix:/var/run/php/php7.2-fpm.sock;
server 127.0.0.1:9000;
}
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
'''
dive
open a gdb session targeting a python compiled with gdb debugging enabled
alias dive='gdb -iex '\''add-auto-load-safe-path .'\'' /opt/cpython/python'
in gdb:
b 1
r
s
#!/bin/sh
FORMAT="{
\"name\": \"%n\",
\"access\": \"%A\",
\"size\": \"%s\"
},
"
printf "$(stat --printf="${FORMAT}" $*)"
printf "\b"
const { map, filter, reduce } = require('lodash');
// array from 0 to 9
const data = [0,1,2,3,4,5,6,7,8,9];
// helper functions
const doubled = val => val * 2;
const isEven = val => val % 2;
const isOverTen = val => val >= 10;