Skip to content

Instantly share code, notes, and snippets.

View miguelff's full-sized avatar

Miguel Fernández miguelff

View GitHub Profile
@miguelff
miguelff / strike.md
Created November 14, 2012 10:45 — forked from cavalle/strike.md
My reasons to support the general strike in Spain

My reasons to support the general strike in Spain

I think the austerity measures imposed by Europe to Spain will eventually work. But the only possible outcome I personally expect is to get back to where we were before the crisis. An illusion of wealth just waiting for the next crisis to happen.

Politicians seem to have decided that this crisis won't change anything. Probably because the first thing that needs to change are the politicians themselves.

After this crisis, Spain will be as inefficient and as brittle as it was before. Spain economy will keep depending on the state, on the banks and on a few very big companies to survive. We will keep depending on our King closing big deals with Arab Sheiks while hunting elephants in Africa.

The banks and the big companies, knowing that the consequences of their errors will be assumed by the tax-payers, as they cannot afford to let them down, will keep becoming increasingly more inefficient and incompetent.

My job, explained so my mom can understand it

"I am a freelance Ruby and Rails developer". When I talk with my geek friends, everyone understands what I do and they have a reasonable understanding of how I spend my day. But sometimes, less technical people ask me what I do for a living and then I tend to dumb down the answer: "I am a programmer, I usually build websites.". Oh -they say- my nephew also make websites, he even built me a blog in Blogger.

Err... yes, but that hardly has anything to do with what I do for a living.

There are many different kinds of websites, built with different technologies, and depending on the site and the technology used to build it, they are made by one kind of professional or another. The craft of building a website comprises many different disciplines, and professionals usually specialize in just one part of the process. Although I do many different things, my specialization is mainly programming dynamic websites using Ruby and Rails.

In this article I want to

#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
# With thanks to https://github.com/optoro/activerecord-callback_notification for original inspiration
if Rails.env.development?
module ActiveRecord
module CallbackNotifications
extend ActiveSupport::Concern
module ClassMethods
def notify_all_callbacks
# Make sure all models are loaded before trying to enumerate
# see: http://weblog.therealadam.com/2011/02/12/simple-ruby-pleasures/comment-page-1/#comment-315
class QueryTracer < ActiveSupport::LogSubscriber
ACCEPT = %r{^(app|config|lib)}.freeze
FRAMES = 5
THRESHOLD = 300 # In ms
def sql(event)
return unless event.duration > THRESHOLD

Simplistic Full-Text Search With Redis's Sorted Sets

Howto

git clone git://gist.github.com/923934.git redisearch

cd redisearch

As a global platform for creativity and self-expression, Tumblr is deeply committed to supporting and protecting freedom of speech. At the same time, we draw lines around a few narrowly defined but deeply important categories of content and behavior that jeopardize our users, threaten our infrastructure, and damage our community.

What Tumblr is for:

Tumblr celebrates creativity. We want you to express yourself freely and use Tumblr to reflect who you are, and what you love, think, and stand for. What Tumblr is not for:

  • Malicious Speech. Don't encourage violence or hatred on the basis of things like race, ethnic origin, religion, disability, gender, age, veteran status, or sexual orientation. We encourage you to dismantle negative speech through argument rather than censorship. We will, however, remove anything that is overtly malicious.

  • Harm to Minors. Be thoughtful when posting anything involving a minor. Don't post or solicit anything relating to minors that is sexually suggestive or violent. Don’

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.