Skip to content

Instantly share code, notes, and snippets.

@sweemeng
sweemeng / ssd1306_test.py
Created July 23, 2016 11:12
micropython ssd1306 test using library build into micropython
import ssd1306
from machine import I2C, Pin
import math
i2c = I2C(sda=Pin(4), scl=Pin(5))
display = ssd1306.SSD1306_I2C(64, 48, i2c, 60)
display.fill(0)
display.show()
for x in range(0, 96):
display.pixel(x, 16+int(math.sin(x/32*math.pi)*7 + 8), 1)
display.show()
@sweemeng
sweemeng / README.md
Last active June 22, 2016 02:20
Just a script to show system hostname and ip on piface 2. Works well if have .local domain setup properly
  • install python wireless module
sudo pip install wireless
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
.link {
stroke: #aaa;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<script>
var data = {
import json
class DataMerger(object):
def __init__(self):
self.data = {}
# Run this several time with different file
def add_data(self, filename):
f = open(filename)
for line in f:
@sweemeng
sweemeng / reader.py
Created March 20, 2014 13:07
Xively demo with tgs2600
#!/usr/bin/python/
# Get xively library in https://github.com/xively/xively-python
import xively
import datetime
def main():
now = datetime.datetime.utcnow()
earliest = now - datetime.timedelta(minutes=30)
api = xively.XivelyAPIClient("SL2N1SZTVFZHxb2p2DXq1GdtaKInCpv521mFtOxwmkrrBvsL")
feed = api.feeds.get("1068165020")
@sweemeng
sweemeng / ircbot.py
Created February 26, 2014 13:46
Beginning of a IRC bot
#!/usr/bin/python
import socket
HOST="irc.freenode.net"
PORT=6667
BOTNAME="sweemengs_bot"
CHANNEL="#myoss"
class Bot(object):
# Running tests:
Basics#test_site_can_be_deleted_and_fixture_loaded = info: started at: Thu Jan 09 2014 11:42:15 GMT+0000 (UTC)
info: PopIt hosting and instance apps started: http://www.127.0.0.1.xip.io:3100
45.76 s = E
DateEditingTests#test_date_editing = 45.40 s = E
HostingDocsTests#test_hosting_site_docs = 45.40 s = E
HostingTests#test_404_page = 45.37 s = E
HostingTests#test_create_instance = 45.41 s = E
HostingTests#test_hosting_site_homepage = 45.38 s = E
@sweemeng
sweemeng / Development.js
Created January 4, 2014 13:04
sweemengs popit config in popit/configs/development.js
/* Example development configuration file
*/
var path = require('path'); [0/23]
module.exports = {
// Don't use minified assets - makes dev easier as no js rebuild required
public_dir: 'public',
@sweemeng
sweemeng / Sudokusolver.py
Last active April 10, 2019 02:14
Sudoku solver
"""
In the book a game state is
struct {
int x;
int y;
} move
Essentially this represent value,
struct {
int board[DIMENSION+1][DIMENSION+1];
int freecount;