Skip to content

Instantly share code, notes, and snippets.

classmember

Block or report user

Report or block classmember

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DictQuery.py
class DictQuery(dict):
'''
source:
https://www.haykranen.nl/2016/02/13/handling-complex-nested-dicts-in-python/?fbclid=IwAR1QG8j1zzjTraJKQsFqf6wrvW1hV622GtWSsEOlfWCwzEZI_NBmyp9IOmk
Usage:
>>> # Complex Dictionary
>>> animals = [
{
"animal" : {
"type" : "bunny"
View pokemon_items_functional.py
# Scroll to bottom for python code
# most of this is json data
items = [
{
"name" : {
"japanese" : "マスターボール",
"english" : "Master Ball",
"chinese" : "大师球"
},
View fp-cake-recipe.py
# 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
View commands.md

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
View wp_user_import.py
#!/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 Jul 1, 2019
Python in the browser
View brython example
<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):
View python-is-like-an-onion.md

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/
View example-wordpress-nginx-configuration
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;
View dive
'''
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
View stat-to-json.sh
#!/bin/sh
FORMAT="{
\"name\": \"%n\",
\"access\": \"%A\",
\"size\": \"%s\"
},
"
printf "$(stat --printf="${FORMAT}" $*)"
printf "\b"
You can’t perform that action at this time.