Skip to content

Instantly share code, notes, and snippets.

@nrocy
nrocy / cog.scad
Created August 24, 2014 20:26
Roller-blind Cog Design
$fn = 100;
ballDiameter = 4.4;
ropeDiameter = 7.5;
numBalls = 12;
circumference = numBalls * (ballDiameter + ropeDiameter);
diameter = circumference / PI;
ballRadius = ballDiameter / 2;
outerHeight = 1;
~/src/phpspec develop$ git log -1
commit 69c34b3a257126200eb7097a0720581643931f29
Author: Marcello Duarte <marcello.duarte@gmail.com>
Date: Tue Nov 29 20:38:01 2011 +0000
Deprecated setFormatter, as the internal structure needs an array
~/src/phpspec develop$ php scripts/phpspec.php --bootstrap spec/SpecHelper.php spec
phpspec: Invalid option bootstrap
@nrocy
nrocy / specTotallyWorksSpec.php
Created November 30, 2011 09:39
PHPSpec Custom Matcher Confusion
<?php
require_once "PHPSpec/Matcher/Functions.php";
// Used http://www.slideshare.net/marcello.duarte/bdd-for-zend-framework-with-php-spec
// Slide 56 as reference.
\PHPSpec\Matcher\define("totallyEqualMan", function($match) {
return array(
"match" => function($actual) use ($match) {
@nrocy
nrocy / gist:1186377
Created September 1, 2011 15:12
Why doesn't this work?
# this doesn't work
find . -type f -iname '*rhtml' -exec echo git mv {} `echo {} | sed 's/rhtml$/html.erb/i'` \;
# output
..
git mv ./pictures/_form.rhtml ./pictures/_form.rhtml
..
# but this works
find . -type f -iname '*rhtml' | while read i; do echo git mv $i `echo $i | sed 's/rhtml$/html.erb/i'`; done
@nrocy
nrocy / .vimrc
Created July 22, 2011 02:20
useful vim settings
Plugins
Definitely take a look at pathogen, it's pretty straightforward to setup. Once installed you can
keep each plugin in its own dir (and use git submodules to keep 'em up to date/auto-install etc)
https://github.com/tpope/vim-pathogen
.vimrc
Few things you may want to look into, ':h options' to look at what 'set'tings do. Most of the below I use a *lot* :)
class AppServer
attr_accessor :admin_password, :port
end
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def app_server
if block_given?
@nrocy
nrocy / gist:907467
Created April 7, 2011 10:01
ruby stuff
def counter(start=0, increment=1)
total = start - increment
lambda do
total += increment
end
end
result = counter(10,2)
puts result.call
@nrocy
nrocy / wtf.sql
Created January 25, 2011 16:15
is this 'normal' mysql behaviour? how didn't i notice this before?
mysql> create table wtf ( id int not null auto_increment primary key, expletive varchar(64) not null, incredulity_level int not null, nullable int null );
Query OK, 0 rows affected (0.01 sec)
mysql> show create table wtf;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| wtf | CRE
@nrocy
nrocy / gist:646146
Created October 26, 2010 01:26
ExtractConstant Bug
# 1. Save this all as a file somewhere, open in Vim
# 2. Move the cursor to inside the string below, and cast this spell (followed by <CR>): "ayiW@a
13jf3viw,recTHREE
class AboutArrays < EdgeCase::Koan
def test_creating_arrays
empty_array = Array.new
assert_equal Array, empty_array.class
assert_equal 0, empty_array.size
end
@nrocy
nrocy / .zshrc
Created October 25, 2010 11:43
Just some .zshrc stuff I've been playing around with
# history
HISTFILE=~/.zsh_history
HISTSIZE=5000
SAVEHIST=1000
# shared history between sessions
setopt share_history
# ignore dupes in history
setopt hist_ignore_dups
# settings