Skip to content

Instantly share code, notes, and snippets.

View adimircolen's full-sized avatar

Adimir Colen adimircolen

View GitHub Profile
@jcberthon
jcberthon / update-docker-compose.sh
Last active December 20, 2021 02:56
Downloading and installing/updating latest Docker Compose (command line)
#!/bin/bash
# Copyright 2017-2018 Jean-Christophe Berthon
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@jgillman
jgillman / restore.sh
Last active March 8, 2024 17:51
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@pauloschiavon
pauloschiavon / 2015-06-08-post-01.md
Last active August 29, 2015 14:22
Alternativa para criação de modelos/tabelas de domínio

Motivação

Sempre torci o nariz para criação de modelos de domínios (status.rb, genero.rb, tipo.rb, ...), principalmente quando o usuário não terá acesso para adicionar ou editar estes dados. Uma alternativa para isto é criar um modulo onde os domínios serão hashs:

# app/utilities/data_base.rb
module DataBase
  def self.gender
    { "Male"    => 1, 
      "Female"  => 2
 }
@hiasinho
hiasinho / factory_girl_strategy_find_or_create.rb
Last active May 27, 2020 18:31
FactoryGirl strategy for adding find & find_or_create
## http://stackoverflow.com/questions/7145256
module FactoryGirl
module Strategy
class Find
def association(runner)
runner.run
end
def result(evaluation)
build_class(evaluation).where(get_overrides(evaluation)).first
@wojtha
wojtha / gist:e9ed6f355e2222875a50
Created November 12, 2014 15:03
xdotool - scripting X11 from command line
# Absolute switching
xdotool set_desktop 0
xdotool set_desktop 1
xdotool set_desktop 2
xdotool set_desktop 3
# Relative switching
xdotool set_desktop $(echo $(($(xdotool get_desktop) + 1)))
xdotool set_desktop $(echo $(($(xdotool get_desktop) - 1)))
@everaldo
everaldo / unicorn-app.sh
Created March 21, 2014 14:29
Gist /etc/init.d script do Unicorn
################################################################################
# unicorn.sh
################################################################################
#!/usr/bin/env bash
set -e
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
AS_USER="USER_NAME"
@emad-elsaid
emad-elsaid / worm.rb
Created March 19, 2014 12:15
Worm game in under 50 line of code in ruby
#!/usr/bin/env ruby
require 'gosu' # gem install gosu --no-document
include Gosu
$dimension, $splits = 200, 20
$size = $dimension.to_f / $splits.to_f
class Worm
attr_writer :dir
def initialize() reset end
@maxim
maxim / rails_load_path_tips.md
Last active April 13, 2023 13:28
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@sowawa
sowawa / .recipe
Created April 28, 2012 03:45
Installing rails 4.0.0 beta
thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg
video: http://www.youtube.com/watch?v=UE27t_LJpx0
@DAddYE
DAddYE / hack.sh
Created March 19, 2012 11:31
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions: