Skip to content

Instantly share code, notes, and snippets.

View srt32's full-sized avatar
πŸ’­
wahoo

Simon Taranto srt32

πŸ’­
wahoo
  • GitHub
  • WORLD
  • 05:06 (UTC -04:00)
View GitHub Profile
@srt32
srt32 / gist:04b27dde11f99f68a3bf
Created September 10, 2014 15:35
golang: ambiguous selector when embedding structs with conflicting method names
package main
func main() {
>> car{}.Model()
}
type car struct {
vehicle
boat
}
class SearchesController < ApplicationController
def index
@tools = Tool.search do
keywords params[:query]
end.results
@inventories = Inventory.search do
keywords params[:query]
end.results
@srt32
srt32 / install.md
Last active July 18, 2021 23:43
installing PostGIS on OSX

Installing the Postgres PostGIS extension on OSX

For reference: http://postgis.net/install

If you don’t already have PG installed

The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations. Select the extension when prompted.

If you already have PG installed

@srt32
srt32 / benchmark_funds.rake
Created April 14, 2014 22:28
benchmarks for map/inject vs SQL sum. See the sample app here: https://github.com/srt32/benchmarks_example
desc 'Benchmark funds_raised methods'
ITERATIONS = 1000
task benchmark_sql: :environment do
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('sql') do
ITERATIONS.times do
@srt32
srt32 / benchmark_funds.rake
Last active August 29, 2015 13:59
benchmark_funds.rake_v0
desc 'Benchmark funds_raised methods'
ITERATIONS = 100_000
task benchmark_sql: :environment do
GC.disable
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('sql') do
@srt32
srt32 / gist:9791005
Created March 26, 2014 19:14
sample_output updated
title: Filters
output: basic.html
controls: true
--
# Filters
## Controllers
--
@srt32
srt32 / gist:8673881
Last active January 4, 2016 20:29
writing code in a notepad :(
"1001" + "11" ---> "1100"
"1" + "1" ---> "10"
def add(number_one, number_two)
# "1011"
# "1111"
# 1110"
ones_digit = number_one[-1]
result = ""
@srt32
srt32 / fizzbuzz.rb
Created January 22, 2014 03:52
Fizzbuzz with no ifs
class Fizzbuzz < Struct.new(:max)
MUTATIONS = {
'fizzbuzz' => ->(i) {i % 3 == 0 && i % 5 == 0},
'fizz' => ->(i) {i % 3 == 0},
'buzz' => ->(i) {i % 5 == 0}
}
def fizzle
1.upto(max).map do |i|
mutations.find(-> {[i]}) do |k, v|
@srt32
srt32 / gist:8535548
Created January 21, 2014 06:59
nginx.conf file for running multiple apps using passenger
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@srt32
srt32 / gist:8031051
Created December 18, 2013 22:34
fourthmeal#transactions_controller refactor process Blog post about it: http://www.simontaranto.com/2013/12/11/it-all-comes-together-ruby-js-and-functional-programming.html
Before:
def create
@transaction = current_order.build_transaction(transaction_params)
@transaction.update(:order_id => current_order.id)
if @transaction.save
@transaction.pay!
if current_user
current_order.update(:user_id => current_user.id, :status => "paid")
else
current_order.update(:status => "paid")