Skip to content

Instantly share code, notes, and snippets.

@boxysean
boxysean / 787.py
Created December 22, 2016 15:43
To get you started with B...
import fileinput
def solve(sequence):
pass
def main():
sequence = []
for line in fileinput.input():
for word in line.split():
@boxysean
boxysean / 100.py
Created December 22, 2016 15:31
To get you started with problem A...
import fileinput
def main():
for line in fileinput.input():
i, j = [int(x) for x in line.split()]
# beware the min and max!
low = min(i, j)
high = max(i, j)
print('%d %d %d' % (i, j, solve(low, high)))
@boxysean
boxysean / slack.py
Last active December 4, 2020 18:47
PythonSlackOperator -- how I've integrated notifications into my PythonOperators
# airflow/plugins/slack.py
import logging
from airflow.operators.python_operator import PythonOperator
from airflow.plugins_manager import AirflowPlugin
from slackclient import SlackClient
from titan.utils import config
@boxysean
boxysean / airflow.cfg
Created December 17, 2015 16:33
DAG that crashes Airflow scheduler quickly
# airflow.cfg
[core]
airflow_home = /opt/titan/airflow
dags_folder = /opt/titan/airflow/dags
s3_log_folder = None
executor = CeleryExecutor
sql_alchemy_conn = mysql://airflow:airflow@mysql/airflow
parallelism = 32
dag_concurrency = 16
@boxysean
boxysean / photo2.sh
Created August 19, 2014 17:05
Raspberry Pi cannot see the Canon 5D Mark II (firmware v 2.1.2) it is connected to
pi@gifbooth ~/GIFBooth $ gphoto2 --list-ports
Devices found: 2
Path Description
--------------------------------------------------------------
ptpip: PTP/IP Connection
usb:001,003 Universal Serial Bus
pi@gifbooth ~/GIFBooth $ gphoto2 --auto-detect
Model Port
----------------------------------------------------------
pi@gifbooth ~/GIFBooth $ gphoto2 --capture-image-and-download
@boxysean
boxysean / avr-programming.sh
Created June 4, 2014 16:27
"Good looking" run of the make commands for Waterfall Swing
boxysean-mbpr:solenoid-controller boxysean$ avrdude -p m128 -B 50 -P usb -c dragon_isp
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.16s
avrdude: Device signature = 0x1e9702
avrdude: safemode: Fuses OK (E:FD, H:99, L:DE)
#include "ofApp.h"
void ofApp::writejacks(int jacks) {
ofFile file(ofToDataPath("DocumentRoot/jumpingjacks.tmp"), ofFile::WriteOnly);
file << jacks/2;
file.close();
ofFile::moveFromTo(ofToDataPath("DocumentRoot/jumpingjacks.tmp"),ofToDataPath("DocumentRoot/jumpingjacks"), true, true);
}
void ofApp::writecalibrated(int calibrated) {
@boxysean
boxysean / TriacBlocDiagnostic.ino
Created December 11, 2013 17:19
Arduino code to control Mic's Triac Bloc, which Mic documented here: http://wemakethings.net/2013/10/27/triac-bloc/
/**
* Arduino code to control Mic's Triac Bloc, which Mic documented here:
* http://wemakethings.net/2013/10/27/triac-bloc/
*
* by boxysean, Dec 11 2013 -- Dash 7 Design
*/
#include <Wire.h>
#define COMMAND_CALIBRATE 'c'
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetVerticalSync(true);
bSendSerialMessage = false;
ofBackground(255);
ofSetLogLevel(OF_LOG_ERROR);
@boxysean
boxysean / pwm_sketch.ino
Created December 4, 2013 19:52
why don't i get better resolution when i pwm?
#define PWM_PIN 2
#define BIT_RESOLUTION_READ 12
#define BIT_RESOLUTION_WRITE 12
void setup() {
pinMode(PWM_PIN, OUTPUT);
analogWriteResolution(BIT_RESOLUTION_WRITE);
analogReadResolution(BIT_RESOLUTION_READ);
Serial.begin(9600);