This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is an example implementation of a Mongo database driver built | |
* on the native C# driver. It acts as a singleton. | |
* | |
* Note that this is _not_ in any way a production-ready driver and is | |
* not meant to be used in the real world. It's simply example code | |
* that accesses a Mongo server and queries for data. | |
*/ | |
using System; | |
using System.Collections.Generic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Minimum distance before activating the warning light (in inches) | |
const int distanceMin = 6; | |
// Stop light blink interval | |
const int interval = 100; | |
// Pin setup | |
const int pinGo = 7; | |
const int pinStop = 8; | |
const int pingSig = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Playlists | |
Quick and simple M3U and PLS playlist parser. Returns a list of media | |
elements. | |
''' | |
import configparser | |
def parse(contents): | |
if contents.split('\n', 1)[0] == '[playlist]': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
def led_callback(pin): | |
mode = GPIO.input(pin) | |
GPIO.output(led, mode) | |
if __name__ == '__main__': | |
led = 22 | |
button = 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import math | |
from PIL import Image, ImageDraw | |
if len(sys.argv) > 1: | |
f = sys.argv[1] | |
else: | |
print('Usage: python histo.py <image filename>') | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
#define delay(x) _delay_ms(x) | |
#define delayMicroseconds(x) _delay_us(x) | |
static void pinMode(int pin, int setting) { | |
if (pin >= 0 && pin <= 7) { | |
if (setting > 0) { // Set to OUTPUT | |
DDRD |= (1<<pin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ADAFRUIT RETROGAME UTILITY: remaps buttons on Raspberry Pi GPIO header | |
to virtual USB keyboard presses. Great for classic game emulators! | |
Retrogame is interrupt-driven and efficient (usually under 0.3% CPU use) | |
and debounces inputs for glitch-free gaming. | |
Connect one side of button(s) to GND pin (there are several on the GPIO | |
header, but see later notes) and the other side to GPIO pin of interest. | |
Internal pullups are used; no resistors required. Avoid pins 8 and 10; | |
these are configured as a serial port by default on most systems (this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NES='fceu' | |
PS3='Choose a game: ' | |
options=("Cave Story" "Legend of Zelda" "Zelda II: The Adventure of Link" "Super Dodge Ball" "Excitebike" "Super Mario Bros." "Super Mario Bros. 2" "Super Mario Bros. 3" "Mega Man" "Kirby's Adventure" "pokemans" "Quit") | |
select opt in "${options[@]}" | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RPLStack: | |
def __init__(self): | |
self._s = [] | |
def ENTER(self, *n): | |
for i in n: | |
if isinstance(i, (int, float)): | |
self._s.append(i) | |
def DEPTH(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 567 | |
b = 174 | |
r = 0 | |
p = 0 | |
while a > 0: | |
d = (a % 10) * 10**p | |
r += b * d | |
a //= 10 | |
p += 1 |
OlderNewer