Skip to content

Instantly share code, notes, and snippets.

View epistrephein's full-sized avatar

Tommaso Barbato epistrephein

View GitHub Profile
@danilop
danilop / gist:d4ff43835e469043e95e
Last active August 7, 2020 09:29
Amazon S3 redirection rule to send every "miss" (HTTP 404) to the domain root
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>danilop.net</HostName>
<ReplaceKeyWith/>
</Redirect>
</RoutingRule>
@sauloperez
sauloperez / signal_catching.rb
Last active November 11, 2020 11:25
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@nakajima
nakajima / sinatra-auth.rb
Created October 13, 2008 01:12
Easy basic auth for Sinatra actions
=begin
Easy Basic Authentication for Sinatra actions.
USAGE
require 'rubygems'
require 'sinatra'
require 'sinatra-auth'
@CansecoDev
CansecoDev / vmangos.sh
Created November 22, 2018 00:31
VMaNGOS deploy script for Ubuntu 16.04
#!/bin/bash
#============================================================================
#title :vmangos.sh
#description :VMaNGOS deploy script for Ubuntu 16.04
#author :canseco.me
#date :20181122
#version :0.8.1
#============================================================================
## Utilities
@zeroasterisk
zeroasterisk / .zshrc
Created August 23, 2011 18:09
~/.zshrc for Oh My ZSH (alan)
# Path to your oh-my-zsh configuration.
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="alanpeabody"
#ZSH_THEME="dieter"
#ZSH_THEME="eastwood"
@szabcsee
szabcsee / data2csv-data2json-data2arr.rb
Last active December 1, 2020 00:10
Sinatra delivers data as json and deliver data in csv as attachment
require 'sinatra'
require 'json'
require 'csv'
# Serve data as JSON
get '/hi/:name' do
name = params[:name]
content_type :json
{ :message => name }.to_json
end
@burke
burke / genkey.rb
Created October 12, 2016 14:34
Create an Elliptic Curve keypair in ruby
require 'openssl'
k = OpenSSL::PKey::EC.new('secp384r1').generate_key
p = OpenSSL::PKey::EC.new(k.public_key.group)
p.public_key = k.public_key
puts k.to_pem, p.to_pem
#!/bin/sh
PRINT=true
LOGGER=false
warning_days=30
certs_to_check='example.com:443
mail.example.com:25
wiki.example.org:443
'

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@pawelztef
pawelztef / _flash.html.erb
Last active August 9, 2021 02:16
rails flash messages with bootstrap 4
<div class="container">
<% flash.each do |type, msg| %>
<div class="alert <%= bootstrap_class_for_flash(type) %> alert-dismissable fade show">
<%= msg %>
<button class="close" data-dismiss="alert">x</button>
</div>
<% end %>
</div>