Skip to content

Instantly share code, notes, and snippets.

@aparrish
aparrish / understanding-word-vectors.ipynb
Last active Aug 14, 2020
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
View understanding-word-vectors.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@floehopper
floehopper / install.md
Last active Aug 7, 2020
Install rtl-sdr on Raspian on Raspberry Pi
View install.md
jamesmead@floehopper.local:~$ sudo dd bs=1m if=/Users/jamesmead/Downloads/2015-02-16-raspbian-wheezy.img of=/dev/disk2
pi@raspberrypi ~ $ sudo raspi-config
# Choose option 1 to "Expand Filesystem" - Ensures that all of the SD card storage is available to the OS
# Choose Finish & reboot

pi@raspberrypi ~ $ sudo apt-get update
@koistya
koistya / ReactJS-Server-Side-Rendering.md
Last active Jul 29, 2019
Server-side Rendering (SSR) for ReactJS / Flux Applications. Setting document.title
View ReactJS-Server-Side-Rendering.md

Files

The basic structure of a React+Flux application (see other examples)

 - /src/actions/AppActions.js     - Action creators (Flux)
 - /src/components/Application.js - The top-level React component
 - /src/constants/ActionTypes.js  - Action types (Flux)
 - /src/core/Dispatcher.js        - Dispatcher (Flux)
 - /src/stores/AppStore.js        - The main store (Flux)
View avatar.py
# -*-encoding: utf-8 -*-
import argparse
import sys
from hashlib import md5
from PIL import Image, ImageDraw
def main():
# hash the input text until enough length we want
@kracekumar
kracekumar / Writing better python code.md
Last active Nov 29, 2019
Talk I gave at June bangpypers meetup.
View Writing better python code.md

Writing better python code


Swapping variables

Bad code

@KhodeN
KhodeN / nginx_codes_stat.py
Last active Apr 27, 2019
HTTP-status code statistic from nginx access log
View nginx_codes_stat.py
#! /usr/bin/env python
import argparse
import sys
import re
import time
line_nginx_full = re.compile(r"""(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])""",
re.IGNORECASE)
line_nginx_onlyStatus = re.compile(r'.+HTTP\/1\.1" (?P<statuscode>\d{3})')
@wm
wm / Powerline.md
Last active Aug 12, 2020
Installing powerline on Mac OSX. The following was done in version Version 10.8.2
View Powerline.md

Install dependencies

brew install cmake
brew install python
sudo easy_install pip

Add powerline bin to your path. In your zshrc file (or the paths files sourced in zshrc) add the following line

PATH="/usr/local/share/python/:$PATH"

Reinstall MacVim with brew

@defunctzombie
defunctzombie / browser.md
Last active Jan 29, 2020
browser field spec for package.json
View browser.md
@oubiwann
oubiwann / 01-deferred-list.py
Created Oct 13, 2012
Async Batching with Twisted: A Walkthrough
View 01-deferred-list.py
from twisted.internet import defer, reactor
from twisted.web.client import getPage
def listCallback(results):
print results
def finish(ign):
reactor.stop()
def test():
View gist:3172633
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import time
import sys
import time
devices = os.popen('adb devices').read().strip().split('\n')[1:]
device1 = MonkeyRunner.waitForConnection( devices[0].split('\t')[0])
package = 'com.android.browser'
You can’t perform that action at this time.