Skip to content

Instantly share code, notes, and snippets.

View costa's full-sized avatar

Costa Shapiro costa

View GitHub Profile
A thought on specs (no reality check has been done yet):
Specs in ruby are so nice that they may actually serve a formal basis for PM-R&D-QA communication.
One idea on one aspect along those lines follows.
Sometimes the specs are incomplete (putting it nicely), but sometimes they are inherently incomplete
(like missing required functionality description whatsoever) which is grave bad, and
sometimes a partial (wordy) description for a certain function is present – lacking a formal example.
I am dealing with the latter case of course, which may just be more than popular in UI-oriented apps.
[ "`pwd`" != "$HOME" ] && [ -r .bashrc ] && . .bashrc
@costa
costa / pd.bashrc.sh
Created October 14, 2009 13:45
petter cd
# Unfortunately, some tools, e.g. rvm (https://beginrescueend.com/), hook to cd, but not to pushd/popd. Not a problem!
pushd() { builtin pushd "$@" && cd .; }
popd() { builtin popd "$@" && cd .; }
pd() {
if [ "$#" -eq "0" ]
then if popd &> /dev/null && pwd > ~/.pd; then :; else pd "`cat ~/.pd`"; fi
else pushd "$1" &> /dev/null && pwd > ~/.pd
fi
}
#!/bin/bash
#lslD() { # It's like... ls -ld for all path elements
for node in "$@"
do [ "${node##/*}" ] && node="$PWD/$node"
while [[ "${node%/}" != "$node" || "${node##*/}" == "." ]]
do node="${node%/}"
node="${node%/.}"
done
while [ "$node" ]
do ls -ld "$node"
var _timeBuffer = (function() {
var tos = {};
return function(act, func, min, max) {
function _doFunc() {
var to = tos[act]; tos[act] = null;
if (to) { clearTimeout(to.max); clearTimeout(to.min); }
func();
}
var to = tos[act];
if (to) { clearTimeout(to.min) }
@costa
costa / gist:2287752
Created April 2, 2012 22:46
put this in your rails project's ./config/environments/development.rb (or equivalent); see http://mines.mouldwarp.com/2012/04/pow-guard-and-rdebug-staying-in-web-app.html
if ENV['RUBY_DEBUG_PORT']
Debugger.start_remote nil, ENV['RUBY_DEBUG_PORT'].to_i
else # optional
Debugger.start_remote
end
@costa
costa / jquery.mobile-1.1.0-custom.css
Created May 15, 2012 10:55
a custom version of jquery mobile's css (1.1.0) including the RED f (for fire) swatch
/*
* jQuery Mobile Framework 1.1.0 db342b1f315c282692791aa870455901fdb46a55
* http://jquerymobile.com
*
* Copyright 2011 (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
*/
/* Swatches */
@costa
costa / landscape.sass
Created November 22, 2012 12:19
sass 3.1.21 bug demo
/* from https://developer.mozilla.org/media/uploads/demos/m/i/minase8888/2550eea731b01e0eb8f4997b1af4ef05/orientation-indicato_1327269188_demo_package/instructions.txt
/* LANDSCAPE CSS
#orientation-message
/* this is to hide the message from browsers that don't recognise orientation
display: none
@media screen and (orientation:portrait)
#orientation-message
/* this is the black base of the message itself, containing all other elements of the message
@costa
costa / accessible_attributes.rb
Last active December 11, 2015 10:48
a model object's attributes stripper (for use in Rails 3.2+ controller specs), a place to put this: spec/support/accessible_attributes.rb
def accessible_attributes(obj, role = :default)
HashWithIndifferentAccess.new(obj.attributes.slice(*obj.class.attr_accessible[role].to_a))
end
@costa
costa / .rvmrc
Created December 29, 2013 12:39
the best RVM setup, currently
rvm use `cat .ruby-version`
source .rvmenv