Skip to content

Instantly share code, notes, and snippets.

@domgiles
domgiles / OLED_merge.cpp
Created January 31, 2014 19:45
Support for Adafruit_CharacterOLED on the Spark Core. Merge of existing cpp and headers.
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
// OLED hardware versions
#define OLED_V1 0x01
#define OLED_V2 0x02
// commands
#define LCD_CLEARDISPLAY 0x01
@micheller
micheller / bit-converter
Created July 17, 2015 08:57
My colleague asked me to write function written to convert selected binary constants (ex. 0b11101) to decimal view and back.
;; The fist version. Tricky and workarounded.
;; you can test it on this:
;; var BITS = ( 29, 0, 63, 85, 34 )
(defun bit-compact (start end)
(interactive "r")
(defun int-to-binary-string (i)
"convert an integer into it's binary representation in string format"
@mvasilkov
mvasilkov / restful.py
Created January 27, 2012 12:31
RestfulView from libanimuchan
from django.shortcuts import render
class RestfulView(object):
allowed_methods = ["GET", "POST"]
def __call__(self, request, *args, **kwargs):
if request.method not in self.allowed_methods or not hasattr(self, request.method):
return self.method_not_allowed(request)
return getattr(self, request.method)(request, *args, **kwargs)
@k0001
k0001 / microformats.py
Created May 4, 2011 11:48 — forked from scoffey/microformats.py
Python microformats parser that supports hCard, hCalendar, hResume and rel-tag and provides an extensible model for other microformats.
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
Model for microformat properties and parsers. A microformat parser can
parse an HTML element into a dictionary of properties, whose keys are
strings and whose values are strings or other dictionary of properties.
As an example, the main program of this script parses an hResume from
given URL.
anonymous
anonymous / private.xml
Created February 18, 2016 09:22
<?xml version="1.0"?>
<root>
<item>
<name>Remap ShiftL + F19 to Caps Lock</name>
<appendix>(ShiftL + F19 to Caps Lock)</appendix>
<identifier>usercustom.f19_shift_l_to_caps</identifier>
<autogen>
@hartsock
hartsock / hosts_listing.py
Created December 22, 2014 22:08
A quick and dirty script to get all the hosts in a vCenter.
#!/usr/bin/env python
from __future__ import print_function
from pyVim import connect
from pyVmomi import vim
si = connect.SmartConnect(host='vcsa', user='my_user', pwd='my_password')
content = si.RetrieveContent()
@jiahuang
jiahuang / watchdog.c
Created November 30, 2012 05:55
ATTiny watchdog setting
uint8_t watchdog_count = 0;
ISR(WDT_vect) {
// This vector is for the watchdog timer
PORTA = PORTA | (1 << LED ); // The LED never goes on
++watchdog_count;
}
ISR(PCINT0_vect)
{
@RaD
RaD / middleware.py
Created August 6, 2012 21:20
Keep user sorting and filtering settings of models with Django's admin site
# -*- coding: utf-8 -*-
import re
from django.shortcuts import redirect
PREF_VAR = 'ADMIN_PER_USER_PREF'
ORDER_VAR = 'o'
FILTER_TAIL = '__exact'
PATH = '/admin/storage/'
@plexus
plexus / svn_short_log
Created December 16, 2011 09:01
svn log, one line per commit
#!/usr/bin/awk -f
# Convert the "svn log" output into a one liner format, which is easier to grep
# or use in scripts. Pipe "svn log" into this script
# When we get a line that starts with a revision number, put the data in variables
/^r[0-9]+/ {
rev=$1
user=$3
date=$5
@NetAngels
NetAngels / runner.py
Created June 24, 2011 04:21
Extremely fast Django test runner
# -*- coding: utf-8 -*-
"""
Extremely fast Django test runner, based on the idea that your database schema
and fixtures are changed much more seldom that your code and tests. All you
need is to make sure that your "quickstart.sqlite" database file is always up
to date.
BEWARE: Don't run this test runner on production server. It assumes that you
use only one database configured as "default", and its db engine is SQLite.
Otherwise your tests can eat your data!