Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
@ericelliott
ericelliott / gitclean.sh
Created January 31, 2016 04:57
gitclean.sh - cleans merged/stale branches from origin
git remote prune origin
git branch -r --merged master | egrep -iv '(master|develop)' | sed 's/origin\///g' | xargs -n 1 git push --delete origin
@becker1701
becker1701 / post.rb
Created November 19, 2015 18:54
Category slugify plugin for Jekyll 3.0.0: This plugin will slugify the categories listed in the YML frontmatter. Categories with multiple words will have the spaces replaced with dashes. Put this file in the _plugins directory.
module Jekyll
class Document
#Updated for Jekyll 3.0.0
# override post method in order to return categories names as slug
# instead of strings
#
# An url for a post with category "category with space" will be in
@henrik
henrik / half_open_struct.rb
Last active March 29, 2019 09:35
HalfOpenStruct for #ruby. Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil). Also see my RecursiveClosedStruct: https://gist.github.com/henrik/5098550
# Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil).
# This avoids issues where you read the wrong value due to a typo and don't notice.
class HalfOpenStruct
def initialize(hash = {})
@hash = hash
end
def include?(name)
@hash.include?(name)
@tenderlove
tenderlove / h2_puma.rb
Last active August 14, 2024 06:10
Demo HTTP/2 server with Puma
require 'socket'
require 'openssl'
require 'puma/server'
require 'ds9'
class Server < DS9::Server
def initialize socket, app
@app = app
@read_streams = {}
@write_streams = {}
@nmabhinandan
nmabhinandan / .travis.yml
Last active April 28, 2017 15:45
Testing ES6 using Mocha by transpiling (using babel) into AMD(RequireJS) on PhantomJS.
language: node_js
node_js:
- '0.10'
- '0.11'
- '0.12'
- 'iojs-v1.7.1'
matrix:
allow_failures:
@henrik
henrik / images_helper.rb
Created February 11, 2015 07:57
Rails image_set_tag_3x helper for srcset.
module ImagesHelper
# Example usage:
#
# image_set_tag_3x "foo_1x.png", alt: "foo"
#
# Will assume there is a 2x and 3x version and provide those automagically.
#
# Based on https://gist.github.com/mrreynolds/4fc71c8d09646567111f
def image_set_tag_3x(source, options = {})
srcset = [ 2, 3 ].map { |num|
@sameersbn
sameersbn / gitlab.conf
Created February 6, 2015 09:53
Nginx reverse proxy configuration for GitLab
upstream gitlab {
server 172.17.42.1:10080 fail_timeout=0;
}
# let gitlab deal with the redirection
server {
listen 80;
server_name git.example.com;
server_tokens off;
root /dev/null;
@treble37
treble37 / step3-testing-elasticsearch-posts_spec.rb
Created February 3, 2015 05:57
Step 3 - Testing ElasticSearch - posts_spec.rb
require 'spec_helper'
require 'rake'
RSpec.describe Api::V1::PostsController, :vcr, record: :new_episodes, :type => :api do
context "elastic search test", elasticsearch: true, commit: true do
before do
@post = FactoryGirl.create(:post, first_name: "August", last_name: "Rush", email: "[email protected]", event: "Rock Concert")
end
@treble37
treble37 / step2-testing-elasticsearch-database_cleaner.rb
Created February 3, 2015 05:51
Step 2 - Testing ElasticSearch - database_cleaner.rb
RSpec.configure do |config|
#config.before(:suite) do
# DatabaseCleaner.clean_with(:truncation)
#end
#config.before(:each) do
# DatabaseCleaner.strategy = :transaction
#end
@treble37
treble37 / step1-testing-elasticsearch.rb
Created February 3, 2015 05:46
Step 1 - Testing ElasticSearch - spec_helper.rb
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs