Skip to content

Instantly share code, notes, and snippets.

View danielnegri's full-sized avatar
Coffee first.

Daniel Negri danielnegri

Coffee first.
View GitHub Profile
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@danielnegri
danielnegri / Rsync
Created May 25, 2013 23:50
Unix Commands
rsync -aHvz /path/to/sfolder name@remote.server:/path/to/remote/dfolder

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.deb
sudo dpkg -i elasticsearch-0.90.0.deb
@danielnegri
danielnegri / run-khan-exercises.sh
Created July 19, 2013 21:04
Run Khan Academy Exercises with SimpleHTTPServer
#!/bin/bash
NAME=khan-exercises
PID_FILE=khan-exercises.pid
COMMAND="python -m SimpleHTTPServer"
#
# Functions
#
do_run() {

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@danielnegri
danielnegri / gowatcher-md5.sh
Created October 12, 2013 04:10
This a md5 implementation of the nickjj/gowatcher script. The reason that I've decided to use md5sum instead inotify-tools it's because I'm using sync folder through Vagrant.
#!/bin/bash
# go $1 $2 &
sum="0"
while true;
do
tmp=`find . -type f -name "*.go" -exec md5sum {} + | awk '{print $1}' | sort | md5sum | awk '{print $1}'`
if [ "$sum" != "$tmp" ]
then
@danielnegri
danielnegri / converter.rb
Created January 31, 2014 20:00
Migrate Jasper XML to Sqlite3
require 'nokogiri'
require 'sqlite3'
class Converter
def initialize(file, database_name = "flashcards")
@file = file
@database_name = database_name
@database = open_database()
end
@danielnegri
danielnegri / publigrations_controller.rb
Created February 19, 2014 00:18
Sample: Publish and Migrate
class PubligrationsController < ApplicationController
before_filter :admin_required
def index
render widget: Views::Publigrations::Index, user: current_user
end
def publish
messages = []
unless subtrack = Subtrack.find_by_id(params[:subtrack_id], include: {question_sets: :questions})