Skip to content

Instantly share code, notes, and snippets.

View gringocl's full-sized avatar

Miles Starkenburg gringocl

View GitHub Profile
@gringocl
gringocl / agistfile1.md
Last active August 29, 2015 14:17
Farmers market in Chile

This was my trip to the market this morning. Every Friday we have a local market in the neighborhood. These happen everyday in multiple places every week. This was about 3 blocks from our place. Chilean peso has recently weakened in value!!! Good for me, it is now 640~ pesos to $1 USD, about 25 pesos more than in Dec. To convert price CLP/KILO to USD/LB divide CLP/1405. All of this is local, but not organic. Its only what is in season, so every couple of weeks it changes pretty drastically.

This is our bounty for the week. A nice score at $24 USD!!!

bounty

Apples, peaches, pears, apricots all at the same price, 25c/lb!!!

peaches

We bought some strawberries to make jam! These boxes were $7.75 a box, we got the same size box riper berries for $4.75 instead!

strawberries

@gringocl
gringocl / kexp_playlist.json
Created May 25, 2014 18:54
kexp top 100 artists by total plays 2001 - 2014
{"_id"=>nil, "total_plays"=>486721}
{"_id"=>"(Various Artists) ", "total_plays"=>5858}
{"_id"=>"Radiohead", "total_plays"=>5181}
{"_id"=>"Beck", "total_plays"=>3713}
{"_id"=>"Built to Spill", "total_plays"=>3439}
{"_id"=>"Pixies", "total_plays"=>3404}
{"_id"=>"Modest Mouse", "total_plays"=>3173}
{"_id"=>"Arcade Fire", "total_plays"=>3130}
{"_id"=>"Death Cab for Cutie", "total_plays"=>3033}
{"_id"=>"Wilco", "total_plays"=>3019}
@gringocl
gringocl / setting up minitest and rails.md
Last active August 29, 2015 14:01
Setting up a new rails project with minitest and capybara

#Setup new rails project with minitest and capybara for Behaviour Driven Development Introduction to Minitest.... We'll be setting up a new rails app with minitest and capybara so we can go over the steps to getting this going. We'll be using a rails 4.1+ in this example. Lets get started!

First thing create a new rails application, a git repository, and the first commit to the repo.

rails new awesomeapp
cd awesomeapp
git init
git add -A
@gringocl
gringocl / event.rb
Created March 7, 2014 04:27
attempt to refactor using arel_table
class Event < ActiveRecord::Base
#Existing scopes
scope :day, lambda {|day| where(" DATE(starts_at) = '#{day}%'
OR DATE(ends_at) = '#{day}%'
OR DATE('#{day}') BETWEEN DATE(starts_at) AND DATE(ends_at)") }
scope :between, lambda {|range_start, range_end| where(" DATE(starts_at) BETWEEN DATE('#{range_start}') AND DATE('#{range_end}')
OR DATE(ends_at) BETWEEN DATE('#{range_start}') AND DATE('#{range_end}')
@gringocl
gringocl / chains.rb
Created January 29, 2014 18:50
ActiveRecord query method chains
User.all.includes(:questions).map(&:question_ids).flatten.group_by { |n| n }.map { |k,v| [ k, v.size ] }.sort_by { |a| a.last }.each { |a| max = a.last if a.last > max }.select { |e| e.last == max }
User.all.map(&:question_ids).flatten.group_by { |n| n }.map { |k,v| [ k, v.size ] }.sort_by { |a| a.last }.each { |a| max = a.last if a.last > max }.select { |e| e.last == max }
@gringocl
gringocl / seeds.rb
Last active January 4, 2016 20:59
Ffaker gem Seeds for Q and A site
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
require 'ffaker'
def sample_text
@gringocl
gringocl / flash.html.erb
Created January 28, 2014 20:31
Rails flash message integration with zurb foundation snippet
<% flashes = {notice: 'success', alert: 'standard', error: 'alert', secondary: 'info'} %>
<% flashes.each do |key, value| %>
<% if flash[key] %>
<%= content_tag :div, :data => { :alert => '' }, :class => "alert-box #{value} radius" do %>
<%= flash[key] %>
<%= link_to '&times;'.html_safe, '#', :class => 'close'%>
<% end %>
<% end %>
<% end %>
Attempting to implement a mergesort algorithm, pry exited with the included error message. The corresponding algorithm is attached also.
@gringocl
gringocl / .railsrc
Last active January 3, 2016 23:09 — forked from ivanoats/.railsrc
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@gringocl
gringocl / gist:8480696
Last active August 11, 2020 09:33
*Usagage "rails new my_cool_app -m path/to/template.rb *My template.rb file for taking care of some of the boring basic configuration of a new rails app, create the repo and push it to Github. *Using mini-test / capybara / guard / spring / postgres.app
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
# template.rb
#add guard-minitest and spring to dev
gem_group :development do