Skip to content

Instantly share code, notes, and snippets.

View groteck's full-sized avatar
:octocat:

Juan Fraire groteck

:octocat:
View GitHub Profile
@groteck
groteck / test.thor
Created August 19, 2014 15:21
run protactor and middleman server
require 'net/http'
require 'thor/group'
require './lib/daemon'
class Test < Thor
include Thor::Actions
include Thor::Daemon
desc "start", "running test servers"
def start
@groteck
groteck / soft_deletable.rb
Last active August 29, 2015 14:19
soft deleted if model has associations
module SoftDeletable
extend ActiveSupport::Concern
class ModelHasAssignedValues < StandardError; end
included do
scope :deleted, ->{ where.not(deleted: true) }
scope :without_deleted, ->{ where(deleted: false) }
scope :with_deleted, ->{ unscope(where: :deleted) }
default_scope { without_deleted }
@groteck
groteck / .zshrc
Last active August 29, 2015 14:19
my zsh config file
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="pygmalion"
# Uncomment the following line to use case-sensitive completion.
@groteck
groteck / csv_with_semicolons_or_colons_parser.rb
Last active January 19, 2021 03:31
Parse CSV file for colons or semicolons
# CSV.parse(csv_header, col_sep: ColSepSniffer.find(csv_header))
# returns a CSV::Table object
p CSV.parse(csv_file,
headers: true,
col_sep: ColSepSniffer.find(csv_headers)).map(&:to_hash)
#!/usr/bin/env ruby
# encoding: utf-8
require "csv"
@groteck
groteck / boot.rb
Last active February 3, 2016 22:08
Access to rails in docker from outside
require 'rails/commands/server'
module Rails
class Server
def default_options
super.merge(Host: '0.0.0.0', Port: 3000)
end
end
end
@groteck
groteck / blocks
Last active April 11, 2016 17:48
Blocks with "do" are different to Blocks with "{}"
#!/usr/bin/env ruby
puts "Count with {}"
puts [[1,1],[2],[3],[4,3]].count { |elements| !elements.all? { |element| element == elements.first } or elements.size == 1 }
puts "----------------------"
# Response:
# Count with {}
# 3
# ----------------------
@groteck
groteck / Spelling.elm
Last active February 20, 2020 18:01 — forked from evancz/Spelling.elm
Remove unused import
port module Spelling exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
import String
main =
program
{ init = init
@groteck
groteck / Facebook.elm
Last active November 2, 2018 22:10
elm facebook integration test
port module Facebook exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
import Debug
main =
@groteck
groteck / css-svg-spinner.markdown
Created September 25, 2017 00:33
css svg spinner