Skip to content

Instantly share code, notes, and snippets.

var myData = {};
@chriscummings
chriscummings / JavaScript New Issue
Created May 30, 2011 05:15
Dealing with new not being used when calling constructors in JS
// Quietly just handle the issue - but requires remembering to write the constructor name in the check!
// =====================================================================================================
function Foo(){
// if user accidentally omits the new keyword, this will silently correct the problem...
if ( !(this instanceof Foo) ){
return new Foo();
}
// constructor logic follows...
}
@chriscummings
chriscummings / python sendmail
Created June 30, 2011 10:40
python sendmail
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
class sendEmail(object):
def send(self,intext,user,password,subject,recipient):
@chriscummings
chriscummings / New Mac Setup.md
Created August 31, 2011 15:57
Setup instructions for a new mac
@chriscummings
chriscummings / link_to.rb
Created September 6, 2011 00:37 — forked from emk/link_to.rb
A link_to helper method for Sinatra
@chriscummings
chriscummings / WE ARE ALL GOING TO JAIL
Created May 9, 2012 08:55
WE ARE ALL GOING TO JAIL
              ∧∧
             ( ゚∀゚) ~WE ARE ALL GOING TO JAIL
             ⊂  つ
             (つ ノ
              (ノ
     \      ☆
             |     ☆
          (⌒ ⌒ヽ   /
    \  (´⌒  ⌒  ⌒ヾ   /
      ('⌒ ; ⌒   ::⌒  )
@chriscummings
chriscummings / Hotlink bomb
Created March 14, 2013 02:02
Prevent JS hot linking.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
Serial.println("Hello");
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
import sys
import os
import RPi.GPIO as GPIO
import subprocess
from glob import glob
import time
path_to_arduino_cli = "/home/chris/bin/arduino-cli"
path_to_avrdude = "/home/chris/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude"
import os
import paramiko
from dotenv import load_dotenv
# Sketch params:
sketch_destination = "/home/chris/demeter"
sketch_files = [
"demeter.ino",
"demeter.h",
"demeter.py",