Skip to content

Instantly share code, notes, and snippets.

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

Jônatas Davi Paganini jonatas

🏠
Working from home
View GitHub Profile
# it is forked from https://github.com/xijo/reverse-markdown/blob/master/reverse_markdown.rb
require 'rexml/document'
require 'benchmark'
include REXML
include Benchmark
class ReverseMarkdown
# set basic variables:
# - @li_counter: numbering list item (li) tags in an ordered list (ol)
@mateusg
mateusg / inflections.rb
Created April 17, 2011 23:03
pt-BR inflections file for Ruby on Rails applications
# encoding: utf-8
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
@josevalim
josevalim / 0_README.markdown
Created January 9, 2012 13:07
Hello world of Sinatra-like libraries on Elixir, Ruby and Node.js
@chrisle
chrisle / gist:2252209
Created March 30, 2012 15:15
CURL as GoogleBot 2.1
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@
@pirj
pirj / Gemfile
Created August 17, 2012 10:13
Sinatra streaming + Redis PubSub
source 'https://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib', require: 'sinatra/streaming'
group :development do
gem 'thin'
gem 'pry-rails'
end
@jeffreykegler
jeffreykegler / gist:4480523
Last active June 20, 2017 06:20
Example for "DSL's made even simpler" blog post
#!perl
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@leods92
leods92 / group_date.rb
Last active December 26, 2015 14:18
Adds time zone aware data grouping method to ActiveRecord. If you want to group a large set of database rows by date using a timestamp as reference, the optimal way is to do it right in the database. When doing it though there are some issues with time zones that #group_date solves. For example, if a UTC timestamp is set to 2013-12-01 01:00 and …
module ActiveRecord
module Querying
delegate :group_date, :to => :scoped
end
module QueryMethods
def group_date(column_name = nil)
return self if column_name.blank?
# Rails uses a non standard time zone naming.
# Elixir v1.0
defmodule Rules do
defmacro __using__(_) do
quote do
import unquote(__MODULE__)
@before_compile unquote(__MODULE__)
@rules []
end
end
@mumoshu
mumoshu / description.md
Last active October 13, 2017 23:59
goroutines in Ruby

GoroutineでもCoroutineでもないコルーチン的なもの、 「Koroutine」(造語です)を実装してみます。

KoroutineはThreadより軽量で並行動作可能な処理です。 各KoroutineやメインスレッドはChannelを通して通信します。

以下が実行例です。 スレッド 1...1 KoroutineSystem 1...2 Koroutine 1...1 Fiber の関係性で1スレッドで複数のKoroutineが実行される様子がわかります。

@leandroh
leandroh / rtc
Last active August 29, 2015 13:57
real time clock in linux
# Real Time Clock (RTC) Drivers for Linux: https://www.kernel.org/doc/Documentation/rtc.txt
cat /proc/driver/rtc
# ----------------------------------------x----------------------------------------
echo rtc-pcf8563 0x51 /sys/class/i2c-adapter/i2c-1/new_device
# ----------------------------------------x----------------------------------------