Skip to content

Instantly share code, notes, and snippets.

# A class is a cookie cutter that can be used to stamp out instances
# This class models a farm (well one with animals on it, at least)
# This class inherits from "object"
class Farm(object):
def __init__(self, length, width, sheep, cattle, pigs, poultry):
self.length = length
self.width = width
self.sheep = sheep
self.cattle = cattle
cd ~/programs
# not a repository
git status
# so init a repository
git init
# note the __pycache__ folder
# we don't want to version that
@lucsmall
lucsmall / modules_and_packages.py
Created February 7, 2017 03:19
An example of using modules and packages in python
### BASIC SETUP
# set pleasant tab stops
cat <<EOF >~/.nanorc
set tabsize 4
set tabstospaces
EOF
# dir for all python command line programs
mkdir ~/programs
@lucsmall
lucsmall / init.lua
Created October 23, 2015 01:57
Using Nodemcu to drive B7971 nixie tubes via 74HC595 shift registers
-- lookup table mapping characters to bit representations
lookup = {
["A"] = 0x0e9c,
["B"] = 0x8ee0,
["C"] = 0x00cc,
["D"] = 0x8ce0,
["E"] = 0x00dc,
["F"] = 0x009c,
["G"] = 0x06cc,
["H"] = 0x0e1c,
@lucsmall
lucsmall / init.lua
Created September 28, 2015 07:02
Using Nodemcu to drive a 74HC595 shift register
latch_pin = 2
gpio.mode(latch_pin, gpio.OUTPUT)
gpio.write(latch_pin, gpio.LOW)
result = spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_LOW, spi.DATABITS_8, 0)
print(result)
while true do
for i=1,255,1 do
print(i)
@lucsmall
lucsmall / instructiosn
Created July 22, 2014 02:12
Refine Recipe
"http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" + escape(value + ", New South Wales", "url")
parseJson(value).results[0].geometry.location.lat
parseJson(value).results[0].geometry.location.lng
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "UWS-Parramatta"
},
"geometry": {
"type": "Polygon",
@lucsmall
lucsmall / raspi.sh
Created September 21, 2012 04:20
Commands to measure Raspberry Pi temperature and CPU scaling frequency
# Measure current temp
/opt/vc/bin/vcgencmd measure_temp
# Read CPU scaling frequency
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
@lucsmall
lucsmall / ifup
Created September 20, 2012 06:49
Ralink RT5370 Configuration - Bringing the network interface up
# sudo ifup wlan0
# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr aa:bb:cc:dd:ee:ff
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16143 errors:0 dropped:0 overruns:0 frame:0
TX packets:1982 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2970692 (2.8 MiB) TX bytes:121265 (118.4 KiB)
@lucsmall
lucsmall / lsusb
Created September 20, 2012 06:42
Ralink RT5370 Configuration - Output of lsusb and lsmod
# lsusb | grep Ralink
Bus 001 Device 007: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
# lsmod | grep rt2
rt2800usb 12069 0
rt2800lib 47242 1 rt2800usb
rt2x00usb 11075 1 rt2800usb
rt2x00lib 41057 3 rt2x00usb,rt2800lib,rt2800usb
mac80211 236178 3 rt2x00lib,rt2x00usb,rt2800lib
cfg80211 171957 2 mac80211,rt2x00lib