Skip to content

Instantly share code, notes, and snippets.

View ArnisL's full-sized avatar
🦊

Arnis Lapsa ArnisL

🦊
View GitHub Profile
@ArnisL
ArnisL / after.cs
Created October 19, 2011 22:02
refactoring == joy
namespace Interreg.App.Audit.Application{
using Domain.Model.Applications;
public class ApplicationAudit:Audit{
public override void AttachHandlers(){
On<AttachmentAdded>(e=>e.Source.LogEvent(
"Attachment named '{0}' added".With(e.Attachment.Name)));
On<AttachmentRemoved>(e=>e.Source.LogEvent(
"Attachment named '{0}' removed".With(e.Attachment.Name)));
@judofyr
judofyr / fizzbuzz.rb
Created August 1, 2012 21:37 — forked from JEG2/fizzbuzz.rb
Writing FizzBuzz with flip-flops
a=b=c=(1..100).each do |num|
print num, ?\r,
("Fizz" unless (a = !a) .. (a = !a)),
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))),
?\n
end
require 'bundler/inline'
require 'json'
require 'uri'
require 'net/http'
gemfile(true) do
gem 'inflecto'
gem 'rom', github: 'rom-rb/rom'
gem 'rom-support', github: 'rom-rb/rom-support'
gem 'rom-http', github: 'rom-rb/rom-http'
This diff is a modified version of a diff written by Arnis Lapsa.
[ The original can be found here: https://gist.github.com/ArnisL/6156593 ]
This diff adds support to tmux for 24-bit color CSI SRG sequences. This
allows terminal based programs that take advantage of it (e.g., vim or
emacs with https://gist.github.com/choppsv1/73d51cedd3e8ec72e1c1 patch)
to display 16 million colors while running in tmux.
The primary change I made was to support ":" as a delimeter as well
@javiertoledo
javiertoledo / README.txt
Created September 7, 2012 03:40
Hack to allow unions on ActiveRecord models
Add union_hack.rb to your project, for example at lib folder and ensure you're loading it on your application.rb file:
# You'll need to add something like that
config.autoload_paths += %W(#{config.root}/lib)
Then extend your favourite model with the module and you'll be able to do unions with unique records, sorted by any fields and limited in number of records (see my_timeline_method):
class Profile < ActiveRecord::Base
extend UnionHack
@lulalala
lulalala / rspecgrep.sh
Created November 2, 2012 09:36
rspec with grep to run selected specs
function rspecgrep()
{
SPK_FILES=`find spec -type f -name "*_spec.rb" | grep $1`
echo $SPK_FILES
time rspec $SPK_FILES --format documentation
}
@codebrew
codebrew / assets.js.erb
Created November 29, 2011 20:31
javascript asset helper
// helper to create proper asset paths if an asset host is configured
App.assets = {
assets : {
<% AssetsUtil.images.each do |img| %>
"<%= img %>" : "<%= asset_path(img) %>",
<% end %>
},
@benedikt
benedikt / rails.rb
Created July 30, 2011 13:16
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
end
end
@ebeigarts
ebeigarts / gist:3159994
Last active February 15, 2023 07:05
Icons

729 icons, free, webfont, grayscale

200 icons, free

400 icons, $25

@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call