Skip to content

Instantly share code, notes, and snippets.

@lucidguppy
lucidguppy / tables.py
Created March 1, 2013 02:38
Create an sql table
from sqlalchemy import *
from datetime import datetime
metadata = MetaData('postgres://blah blah blah')
temperature_table = Table(
'tf_temperatures', metadata,
Column('id', Integer, primary_key=True),
Column('temperature', Float, nullable=False),
Column('datetime',DateTime, default=datetime.now))
@lucidguppy
lucidguppy / app.py
Created March 1, 2013 02:46
Access a sqlalchemy database through importing it.
from flask import Flask
from flask import render_template
from random import randrange
#create the app object
app = Flask(__name__)
#get the database
import tables as t
..blah blah blah...
from flask import render_template
from random import randrange
#create the app object
app = Flask(__name__)
#get the database
from tables import engine, temperature_table
@app.before_request
def before_request():
@lucidguppy
lucidguppy / writing python well
Created April 2, 2013 23:16
Writing python well
Getting docstrings right:
http://www.python.org/dev/peps/pep-0257/
Getting syntastic to work on windows:
http://www.reddit.com/r/learnpython/comments/1bjq2g/if_you_use_vim_and_youre_using_python_or_learning/
@lucidguppy
lucidguppy / install pip log
Created March 1, 2014 14:27
Installing cryptography 0.2.1 on lubuntu
------------------------------------------------------------
/usr/bin/pip3 run on Sat Mar 1 09:10:17 2014
Downloading/unpacking cryptography
Getting page https://pypi.python.org/simple/cryptography/
URLs to search for versions for cryptography:
* https://pypi.python.org/simple/cryptography/
Analyzing links from page https://pypi.python.org/simple/cryptography/
Skipping link https://pypi.python.org/packages/cp26/c/cryptography/cryptography-0.2-cp26-none-win32.whl#md5=13e5c4b19520e7dc6f07c6502b3f74e2 (from https://pypi.python.org/simple/cryptography/); unknown archive format: .whl
Skipping link https://pypi.python.org/packages/cp26/c/cryptography/cryptography-0.2.1-cp26-none-win32.whl#md5=00e733648ee5cdb9e58876238b1328f8 (from https://pypi.python.org/simple/cryptography/); unknown archive format: .whl
@lucidguppy
lucidguppy / Type check
Created March 8, 2014 12:41
Bare bones type checking for function
from functools import wraps
class Boat(object):
def __init__(self,color):
self.color = color
def hello(self):
print("I'm a {} boat".format(self.color))
@lucidguppy
lucidguppy / helloworld.nim
Created May 17, 2014 23:24
Print hello world to the stdout in nimrod
#simple hello world in nimrod
echo("Hello World!")
@lucidguppy
lucidguppy / interpolate.nim
Last active August 29, 2015 14:01
Output hello 10 times with counter
#string interpolation is similar to python - be sure to import string utils
import strutils
var output = "a $1 parrot" % ["dead"]
echo(output)
for time in countUp(1,10):
echo("I like traffic lights $time" % ["time", intToStr(time)])
echo("But only when they're green")
#!/usr/bin/env python3
from csv import reader
letter_template = """
<html>
<body>
<p>{0} {1}</p>
<p>Hi,</p>
@lucidguppy
lucidguppy / CMakeLists.txt
Created August 17, 2014 18:20
Create a chaiscript shared module and use it in the chaiscript repl
cmake_minimum_required (VERSION 2.8)
add_definitions(-std=c++11)
project (ChaiTutorial)
add_library(myModule SHARED myModule.cpp)
list(APPEND LIBS ${READLINE_LIB})
include_directories(/usr/local/include)
install(TARGETS myModule DESTINATION /usr/local/lib/chaiscript)