Skip to content

Instantly share code, notes, and snippets.

@erickzanardo
erickzanardo / star-command.sh
Last active February 16, 2017 20:09
star-command
#!/bin/bash
function star-command {
if [ "$1" == "" ] || [ "$1" == "-h" ]; then
echo "star-command \"command to store on your favorites\""
echo "star-command -l \"list your favorites\""
elif [ "$1" == "-l" ]; then
cat ~/.star-commands
else
echo "$1" >> ~/.star-commands
@erickzanardo
erickzanardo / sourceable.sh
Last active February 6, 2017 13:27
Simple script to easy add env variables, or changing the path without having to always change the bash[rc,_profile,etc] file. Add these lines to your bash[rc,_profile,etc] file once and then just add files to the folder configured on the SOURCEABLE_DIR variable.
# Sourceables
SOURCEABLE_DIR=/home/erick/sourceable/
DIRS=($(ls $SOURCEABLE_DIR))
for dir in "${DIRS[@]}"; do
if [[ "$dir" != *.ignore ]]
then
source "$SOURCEABLE_DIR$dir"
fi
done
@erickzanardo
erickzanardo / angular-noconflict.js
Last active September 29, 2015 18:28
Angular stand alone test
(function() {
var existingAngular = window.angular;
require("angular");
var angular = window.angular;
window.angular = existingAngular || {};
module.exports = angular;
})();
@reu
reu / index.js
Created April 24, 2015 22:06
Node simple static file server.
var http = require("http");
var fs = require("fs");
var mime = require("mime-types");
var server = http.createServer(function(req, res) {
var path = "." + req.url;
fs.stat(path, function(error, stats) {
if (error) {
res.writeHead(404);
@reu
reu / gulp-self-enclosing.js
Created April 16, 2014 17:35
Self enclosing function for each file
var es = require("event-stream");
module.exports = function() {
return es.map(function(file, callback) {
file.contents = new Buffer("(function() {\n" + String(file.contents) + "\n})();");
callback(null, file);
});
};
@reu
reu / README.md
Created May 21, 2012 14:36
Ruby annotations

Imagine this case:

class Account < ActiveRecord::Base
  def transfer(other, quantity)
    tries = 0
    begin
      tries += 1
      transaction do
        self.quantity -= quantity
class String
def encrypt(options = {})
crypt :encrypt, options
end
def decrypt(options = {})
crypt :decrypt, options
end
private