Skip to content

Instantly share code, notes, and snippets.

@istro
istro / pre-commit
Created November 13, 2012 18:49 — forked from hc5duke/pre-commit
pre-commit hook
#!/usr/bin/env ruby
# copy or symlink this file to .git/hooks/
# automatically strip spaces from the end of lines and add newlines to the end of files as necessary
filetypes = %w(
builder
conf
css
erb
haml
@istro
istro / gist:4173321
Created November 30, 2012 02:06
blah
if (condition1) {
alert(1);
}else if (condition2) {
alert(2);
reset();
}else if (condition3) {
alert(3);
reset();
}else{
return true;
gemf_a=`md5 Gemfile`
mig_a=`ls -l ./db/migrate | wc -l`
git pull tapjoy master
gemf_b=`md5 Gemfile`
mig_b=`ls -l ./db/migrate | wc -l`
if [ $mig_a -eq $mig_b ]; then
echo '...your db seems up to date'
fi
@istro
istro / foobar
Created January 29, 2013 19:32
for(var i = 1; i < number_of_banners; i++ ){
var banner = creativeList[i];
if(Math.abs((client.height+client.width)-(banner.height+banner.width)) < Math.abs((client.height+client.width)-(chosen_banner.height+chosen_banner.width)) && Math.abs(banner.ratio-client.optimal_ratio) < 0.3 ){
chosen_banner = banner;
}
}
/*
* Outputs a float representing the iOS version if user is using an iOS browser i.e. iPhone, iPad
* Possible values include:
* 3 - v3.0
* 4.0 - v4.0
* 4.14 - v4.1.4
* false - Not iOS
*/
var iOS = parseFloat(
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
require 'rspec/core/formatters/progress_formatter'
# Custom RSpec formatter that speaks aloud using the say command, if available.
# Not to be taken too seriously, but fun for annoying your coworkers.
# Usage: bundle exec rspec -r ./say_formatter.rb -f SayFormatter spec
class SayFormatter < RSpec::Core::Formatters::ProgressFormatter
VOICES = %w[Agnes Albert Alex Bad\ News Bahh Bells Boing Bruce Bubbles Cellos
Deranged Fred Good\ News Hysterical Junior Kathy Pipe\ Organ
Princess Ralph Trinoids Vicki Victoria Whisper Zarvox]
@istro
istro / gist:5973617
Last active December 19, 2015 14:59
The challenge: Given an array of integers, find the largest possible sum of consecutive elements of that array. Example: For array [3, -4, 8, -2, -1, 20] the output should be 25, because 8+(-2)+(-1)+20 Live version can be found on codepen - http://codepen.io/istro/pen/qEesB
// To break down the problem for myself better, I like to write some tests.
var test = function(){
// Array contains only negative integers -> result is the single largest element
if(findSum([-14, -5, -22]) != -5 && findSum([-3, -23, -1]) != -1){
alert('First test case fails.');
return false;
}
// Array contains only positive integers -> result is the sum of all elements
if(findSum([1, 2, 3]) != 6 && findSum([5, 6]) != 11){
@istro
istro / gist:6891815
Last active December 25, 2015 00:59
RSA authorization setup instructions

Generate a key pair:

ssh-keygen -t rsa

Press enter when it prompts for file location Enter a passphrase (simple one will do - it's only ever important if your private key (the one on your machine) gets compromised)

This will create a .ssh/ folder with two files - id_rsa and id_rsa.pub in your home directory.

Copy your public key to the server,

@istro
istro / Guardfile
Last active December 25, 2015 15:39
Guardfile.
notification :growl_notify
group :website do
guard 'remote-sync',
source: '1bog/website',
destination: 'public_html/buildtop',
user: 'ivans',
remote_address: '1bogtest.org',
exclude: "/website/init_personal.php",
exclude_from: '',