Skip to content

Instantly share code, notes, and snippets.

@pzula
pzula / sensor-code.py
Created March 12, 2016 21:04
Ultrasonic sensor
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
timeout = 0.020
while 1:
GPIO.setup(11, GPIO.OUT)
#cleanup output
#!/usr/bin/env bash -x
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.28/VirtualBox-4.3.28-100309-OSX.dmg"
VIRTUALBOX_DOWNLOAD_PATH="/Users/$USER/Downloads/virtualbox.dmg"
VIRTUALBOX_INSTALLER_PKG="/Volumes/VirtualBox/VirtualBox.pkg"
VIRTUALBOX_INSTALLER_TARGET=/Volumes/Macintosh\ HD
DOCKER_DOWNLOAD_URL="https://get.docker.com/builds/Darwin/x86_64/docker-latest"
DOCKER_DOWNLOAD_PATH="/usr/local/bin/docker"
DOCKER_MACHINE_DOWNLOAD_URL="https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_darwin-amd64"
DOCKER_MACHINE_DOWNLOAD_PATH="/usr/local/bin/docker-machine"
@pzula
pzula / sql.txt
Last active August 29, 2015 14:17 — forked from rewinfrey/sql.txt
SELECT organizations.name,
organizations.id,
organizations.ancestry,
tmp.average_activated_time_of_children from organizations
JOIN (
SELECT org.ancestry,
AVG(org.updated_at - org.created_at) as average_activated_time_of_children,
CAST(substring(org.ancestry from '\d+(?!\/)$') as integer) as organization_id
FROM organizations org
INNER JOIN accounts acc ON acc.organization_id=org.id
@pzula
pzula / another.js
Last active August 29, 2015 14:16
React router
var React = require('react')
var Router = require('react-router')
var { Route, RouteHandler, Link,
DefaultRoute, NotFoundRoute, Redirect } = Router
var App = React.createClass({
render() {
return (
<div>
<h1>
@pzula
pzula / README.md
Created September 9, 2014 14:29
battleship_instructions

Battleship Battleship is a classic game where players compete head-to-head shooting guns and sinking ships. Wikipedia

It is not this:

battleship the movie

Pre-Game Layout Each player has a 10x10 grid and can position each of their ships either vertically or horizontally The columns are labeled A-L and the rows 1-10. A1 is the top left square and L10 the bottom right.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.078821629285812378</real>
<key>Green Component</key>
<real>0.07883714884519577</real>
@pzula
pzula / gist:9484560
Created March 11, 2014 12:23
Makefile
pzula checkerboard (master) ✨ cat /Users/pzula/.rvm/src/ruby-2.1.1/ext/psych/Makefile
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@:)
ECHO = $(ECHO1:0=@echo)
@pzula
pzula / gist:9484545
Created March 11, 2014 12:22
mkmf.log
pzula checkerboard (master) ✨ cat /Users/pzula/.rvm/src/ruby-2.1.1/ext/psych/mkmf.log
find_header: checking for yaml.h... -------------------- yes
"/usr/bin/clang -E -I../../.ext/include/x86_64-darwin13.0 -I../.././include -I../.././ext/psych -I/usr/local/Cellar/libyaml/0.1.5/include -I/usr/local/Cellar/readline/6.2.4/include -I/usr/local/Cellar/libksba/1.3.0/include -I/usr/local/Cellar/openssl/1.0.1f/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wextra-tokens -fno-common -pipe conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <yaml.h>
/* end */
@pzula
pzula / gist:9484355
Created March 11, 2014 12:08
psych-bundle
pzula checkerboard (master) ✨ otool -L /Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
/Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle:
/Users/pzula/.rvm/rubies/ruby-2.1.1/lib/libruby.2.1.0.dylib (compatibility version 2.1.0, current version 2.1.0)
/usr/local/lib/libyaml-0.2.dylib (compatibility version 3.0.0, current version 3.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
pzula checkerboard (master) ✨ find /usr/local -name libyaml*.dylib
/usr/local/Cellar/libyaml/0.1.4/lib/libyaml-0.2.dylib
/usr/local/Cellar/libyaml/0.1.4/lib/libyaml.dylib
/usr/local/Cellar/libyaml/0.1.5/lib/libyaml-0.2.dylib
@pzula
pzula / gem-install-output
Created March 11, 2014 00:03
gem-install-output
pzula checkerboard (master) ✨ rvm use 2.1.1 ; ruby -wdS gem install minitest
Using /Users/pzula/.rvm/gems/ruby-2.1.1
/Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:4:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
Reason: image not found - /Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
from /Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/pzula/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:1:in `<top (required)>'