Skip to content

Instantly share code, notes, and snippets.

View Mak0's full-sized avatar

Maksym Kolotilkin Mak0

View GitHub Profile
@patmcnally
patmcnally / .irbrc
Created March 30, 2011 03:54
.irbrc file that incorporates wirble, hirb, rails 3, and awesome print
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@coderberry
coderberry / Ruby.sublime-settings
Created October 17, 2011 16:34
Ruby.sublime-settings
{
// The number of spaces a tab is considered equal to
"tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
"font_face": "Droid Sans Mono",
"font_size": 15,
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active December 10, 2022 13:34
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@g3d
g3d / gist:2709563
Last active January 9, 2025 17:35 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
@benkitzelman
benkitzelman / country_codes.rb
Created February 24, 2013 12:36
ISO_3166-1 country codes 2 char to 3 char mapping
module CountryCodes
class << self
def two_char_code_for(three_char_country_code)
if country = CODES[three_char_country_code.to_sym]
country[:two_char_code]
end
end
def three_char_code_for(two_char_country_code)
CODES.select {|k,v| v[:two_char_code].to_sym == two_char_country_code.upcase.to_sym}.keys.first
@miguelgrinberg
miguelgrinberg / rest-server.py
Last active February 12, 2025 21:09
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@tonyklawrence
tonyklawrence / teamcity.coffee
Last active December 29, 2015 01:59
Dashing Teamcity Widget
class Dashing.Teamcity extends Dashing.Widget
@accessor 'state', Dashing.AnimatedValue
onData: (data) ->
if data.status
$(@get('node')).attr 'class', (i,c) -> c.replace /\bstatus-\S+/g, ''
$(@get('node')).addClass "status-#{data.status}"
@pcreux
pcreux / Gemfile
Last active December 11, 2023 20:24
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@hfreire
hfreire / qemu_osx_rpi_raspbian_jessie.sh
Last active February 4, 2025 00:47
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location