Skip to content

Instantly share code, notes, and snippets.

@fsaravia
fsaravia / What's My IP.md
Last active December 15, 2023 14:49
What's My IP for AWS (Golang)

What's My IP for AWS Lambda

This is a Go script that can be deployed to AWS Lambda and returns the caller's IP address formatted in JSON.

@fsaravia
fsaravia / slack-post.go
Last active March 21, 2016 16:36
Post random text to Slack using Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
#! /usr/bin/env bash
export PROTEST_REPORT=summary
export PROTEST_FAIL_EARLY=true
find_command() {
find ./test -name "*.rb" -mindepth 2
}
NUMBER_OF_FILES=$(echo `find_command | wc -l`)
@fsaravia
fsaravia / randomizer.rb
Created February 27, 2015 23:58
Random strings in Ruby
module Randomizer
PATTERNS = {
lowercase: Array("a".."z"),
uppercase: Array("A".."Z"),
numbers: Array(0..9),
special: %w(- _ .)
}
module_function
def configure(options)

Keybase proof

I hereby claim:

  • I am fsaravia on github.
  • I am fedesaravia (https://keybase.io/fedesaravia) on keybase.
  • I have a public key whose fingerprint is 17AC 1D9C 4AC2 F27B 4833 9C85 1418 10C1 2437 B1FD

To claim this, I am signing this object:

ENV['CPUPROFILE_REALTIME'] = 1
require 'perftools'
require 'rspec'
dirs = []
dirs.concat Dir["./spec/models/*.rb"]
dirs.concat Dir["./spec/routes/*.rb"]
dirs.concat Dir["./spec/helpers/*.rb"]
dirs.concat Dir["./spec/script/*.rb"]
@fsaravia
fsaravia / zoned_times.rb
Created December 19, 2013 16:31
DataMapper timzone enabled methods
module ZonedTimes
@@zoned_methods = []
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
@fsaravia
fsaravia / fake_unique.rb
Created November 28, 2013 22:07
Fake unique property with Faker (https://github.com/stympy/faker)
# ActiveRecord edition
# For use with DataMapper replace line 7 with the following line
# if model.first(property.to_sym => result).nil?
def fake_unique(model, property, method_module, method)
result = method_module.send(method.to_sym)
if model.where(property.to_sym => result).first.nil?
result
else
fake_unique(model, property, method_module, method)