Skip to content

Instantly share code, notes, and snippets.

View alexandreprates's full-sized avatar
💻

Alexandre Prates alexandreprates

💻
View GitHub Profile
#!/usr/bin/env sh
echo Checking if the service port is available
until nc -z <service> <port>; do
printf '.'
sleep 5
done
echo Service available starting app
exec $@
@alexandreprates
alexandreprates / poke
Last active April 4, 2018 14:17
Force touch on docker-machine shared volume when file is changed
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Missing container name parameter"
echo " Using:"
echo " poke <running_container_name>"
exit(1)
fi
CONTAINER_NAME=$1
@alexandreprates
alexandreprates / autotest.sh
Last active April 2, 2018 09:31
Automatic run your tests
#!/usr/bin/env sh
# Everytime that you save your code _Autotest_ run the tests for you
# MAC VERSION - needs fswatch
# by Alexandre Prates <ajfprates@gmail.com>
# mar/2018
# set -x
if [ -z "$1" ]; then
{"configs":
[
{"filename": "./foo.conf", "content": "FOO=bar"}
]
}
@alexandreprates
alexandreprates / youtube_popup
Last active September 14, 2016 13:34
Youtube floating popout for i3
#!/bin/bash
tempfile="/tmp/$(date +%s).html"
cat <<EOS > $tempfile
<html>
<head><meta charset="UTF-8"><title>Youtube Pop-up</title></head>
<body><iframe width="640" height="360" src="$1" frameborder="0" allowfullscreen></iframe></body>
</html>
EOS
require 'gosu'
class Map
FLOOR_PERCENT = 55
attr_reader :content, :width, :height
def initialize(width, height, random = Random.new)
@width = width
@height = height
@alexandreprates
alexandreprates / user.rb
Last active May 9, 2016 19:51
Model User
require 'digest/sha2'
class User < ActiveRecord::Base
cattr_accessor :current
attr_accessor :password, :accept_terms
class << self
def authenticate(authentication_hash = {})
user = User.find_by_email(authentication_hash[:email])
user if user and user.password_match?(authentication_hash[:password])
@alexandreprates
alexandreprates / build
Last active May 4, 2016 18:51
Start Jenkins build on command line
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'yaml'
def http_get(url)
url = URI.parse url
response = Net::HTTP.get_response(url)
case response.code
@alexandreprates
alexandreprates / lost.zsh-theme
Created January 18, 2016 13:01
OhMyZsh lost theme
# Theme by ajfprates at gmail dot com
local current_dir='${PWD/#$HOME/~}'
local git_info='$(git_prompt_info)'
local ruby_env=' $(ruby -v | cut -d " " -f 2)'
PROMPT="%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(hostname)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}with ruby%{$fg[red]%}${ruby_env}%{$reset_color%}
>: "
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}"
@alexandreprates
alexandreprates / .rubocop.yml
Last active August 29, 2015 14:19
Ruby project guide
require:
- rubocop-rspec
Style/AlignHash:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
Style/AlignParameters:
EnforcedStyle: with_first_parameter