Skip to content

Instantly share code, notes, and snippets.

View kivanio's full-sized avatar
🏠
Working from home

Kivanio Barbosa kivanio

🏠
Working from home
View GitHub Profile
@kivanio
kivanio / fail2ban.rb
Last active August 29, 2015 14:11 — forked from ktheory/fail2ban.rb
# First blacklist checks for /etc/password, and counts hits in cache
blacklist 'etc/password' do
if req.query_string =~ %r{/etc/passwd}
Fail2Ban.fail('etc_password', req.ip, limit: 3, period: 24.hours, ban_for: 24.hours)
end
end
# 2nd blacklist checks for banned IPs in cache
blacklist 'banned_ips' do
Fail2Ban.banned?(req.ip)
# Timezone extension to Sidetiq
Sidetiq::Schedulable::ClassMethods.class_eval do
# Sets the time zone for the recurrence rules.
#
# Example:
#
# class MyWorker
# include Sidekiq::Worker
# include Sidetiq::Schedulable
#
@kivanio
kivanio / API.md
Last active August 29, 2015 14:07 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@kivanio
kivanio / doorkeeper.rb
Last active August 29, 2015 14:07 — forked from kenn/doorkeeper.rb
# config/initializers/doorkeeper.rb
Doorkeeper.configure do
client_credentials :from_obfuscated_params
end
module Doorkeeper
module OAuth
class Client
module Methods
def from_obfuscated_params(request)
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
### pfx to pem, complete edition:
$ openssl pkcs12 -in filename.pfx -nocerts -out key.pem
$ openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem
$ openssl pkcs12 -in filename.pfx -cacerts -out ca_cert.pem
// turbolinks addthis
var initAdthis;
initAdthis = function(){
// Remove all global properties set by addthis, otherwise it won't reinitialize
for (var i in window) {
if (/^addthis/.test(i) || /^_at/.test(i)) {
delete window[i];
}
}
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
Rails as it has never been before :)