Skip to content

Instantly share code, notes, and snippets.

View djds23's full-sized avatar

Dean Silfen djds23

View GitHub Profile
@djds23
djds23 / notes.jsx
Last active April 3, 2016 08:19
error on line 5, this.props.onAnswerChange(answer);
var AnswerClass = React.createClass({
handleChange: function (e) {
e.preventDefault();
var answer = React.findDOMNode(this.refs.answer).value.trim();
// this.props has an attr of onAnswerChange, however its value is undefined here,
// causing a Uncaught TypeError: undefined is not a function
this.props.onAnswerChange(answer);
},
render: function () {
return (
@djds23
djds23 / alphavid.py
Created April 17, 2015 12:52
concat all videos in a directory alphabetically
import os
import subprocess
FILES = os.listdir('.') # ~/path/to/vids
TEMPLATE_PREFIX = 'file '
OUTPUT_LIST = []
for file_name in sorted(FILES):
full_file_path = os.path.abspath(file_name)
OUTPUT_LIST.append(TEMPLATE_PREFIX + full_file_path)
@djds23
djds23 / cleanscreen
Created April 20, 2015 13:40
I take way too many screenshots every day. I like that they goto my desktop, but I want to archive old ones after my screen gets cluttered. This cleans my screen for me when things start going a bit over the top!
#! /usr/bin/env python
import os
import shutil
HOME = os.path.expanduser('~')
DESKTOP = os.path.join(HOME, 'Desktop')
DESKTOP_FILES = os.listdir(DESKTOP)
SCREEN_SHOT_DIR = os.path.join(HOME, 'Pictures', 'Screenshots')
SCREEN_SHOTS = filter(lambda f: f.startswith('Screen Shot'), DESKTOP_FILES)
class KeyNotFoundException(Exception):
pass
class NotANodeError(TypeError):
pass
class Node(object):
def __init__(self, value, next=None):
self.__value__ = value
@djds23
djds23 / export.rake
Created December 26, 2015 04:53
A Rake task to print out existing data in a form that can be copied into a db/seeds.rb
namespace :export do
desc "Prints code for seed files"
task :seeds_format, [:limit] => :environment do |t, args|
limit = args.limit.to_i
raise "Please provide a limit" if limit.zero?
models.each do |model|
model.all.limit(limit).each do |country|
puts "#{model.to_s}.create(#{country.serializable_hash.delete_if {|key, value| ['created_at','updated_at','id'].include?(key)}.to_s.gsub(/[{}]/,'')})"
end
@djds23
djds23 / provision.sh
Last active July 31, 2016 15:31
Provision a digital ocean box
apt-get install -y git
apt-get install -y build-essential
# Install node 4.X line
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
apt-get install -y nodejs
# Install RVM
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
@djds23
djds23 / react-static-srv.sh
Created July 31, 2016 17:57
React build static file
echo "Pulling branch master"
git pull origin master
echo "Building static site"
node ./scripts/build.js
echo "Moving build to /srv/"
cp -R ./build /srv/
echo "Kicking over NGINX"
@djds23
djds23 / toucan.txt
Last active December 1, 2016 17:55
this is a toucan
_ _.-''''''--._
.` `. ...------.\
/ |O :-` _,.,---'
' \ ;--''
| _.' (
,' _,' `-.
: / '.
\ \ '
`.| `.
`-._ \
@djds23
djds23 / led-server.ino
Created July 18, 2017 15:49
WiFi Server with nodeMCU module
#include <Arduino.h>
#include <ESP8266WiFi.h>
/////////////////////////////////
// WiFi Network Name: LED FLIP //
////////////////////////////////
/////////////////////////////
// IP Address: 192.168.4.1 //
////////////////////////////
@djds23
djds23 / led-server.ino
Created July 18, 2017 15:49
WiFi Server with nodeMCU module
#include <Arduino.h>
#include <ESP8266WiFi.h>
/////////////////////////////////
// WiFi Network Name: LED FLIP //
////////////////////////////////
/////////////////////////////
// IP Address: 192.168.4.1 //
////////////////////////////