Skip to content

Instantly share code, notes, and snippets.

View cefigueiredo's full-sized avatar

Carlos Figueiredo cefigueiredo

  • Montreal, Quebec
View GitHub Profile
@joshnuss
joshnuss / udp_server.exs
Last active February 5, 2026 18:03
Fault tolerant UDP Server in Elixir
# to run:
# > elixir --no-halt udp_server.exs
# to test:
# > echo "hello world" | nc -u -w0 localhost 2052
# > echo "quit" | nc -u -w0 localhost 2052
# Let's call our module "UDPServer"
defmodule UDPServer do
# Our module is going to use the DSL (Domain Specific Language) for Gen(eric) Servers
use GenServer
@eloypnd
eloypnd / dnsmasq_setup_osx.md
Last active July 4, 2025 01:04
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@johnantoni
johnantoni / gist:07df65898456ace4307d5bb6cbdc7f51
Last active January 15, 2026 14:48 — forked from mgmilcher/gist:5eaed7714d031a12ed97
Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X

This is my take on how to get up and running with NGINX, PHP-FPM, MySQL and phpMyAdmin on OSX Yosemite.

This article is adapted from the original by Jonas Friedmann. Who I just discovered is from Würzburg in Germany. A stonesthrow from where I was born ;)

Xcode

Make sure you have the latest version of XCode installed. Available from the Mac App Store.

Install the Xcode Command Line Tools:

xcode-select --install

@airblade
airblade / copy_attachments.rb
Created November 10, 2015 11:01
Copies S3-stored Paperclip attachments from one AR model to another
# lib/paperclip/copy_attachments.rb
# Copies S3-stored Paperclip attachments from one AR model to another.
#
# This module should be mixed into the target AR model.
if Gem::Version.new(::AWS::VERSION) >= Gem::Version.new(2)
raise NotImplementedError, 'coded for aws-sdk v1'
end
@juanplopes
juanplopes / rainbow.py
Last active August 29, 2015 14:23
Python script to put a rainbow overlay in an image
#!/usr/bin/env python
import Image, colorsys, sys
if len(sys.argv) < 2:
print 'usage: {} <file> [<output>]'.format(sys.argv[0])
sys.exit(0)
img = Image.open(sys.argv[1])
width, height = img.size
@ChuckJHardy
ChuckJHardy / example_activejob.rb
Last active March 12, 2025 21:24
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@ksin
ksin / copy_attachments.rb
Last active February 13, 2017 19:59
Paperclip copy attachments s3
### s3 implementation of Paperclip module that supports deep
### cloning of objects by copying image attachments.
### Refer to Paperclip issue: https://github.com/thoughtbot/paperclip/issues/1361#issuecomment-39684643
### Original gist works with fog: https://gist.github.com/stereoscott/10011887
module Paperclip
module CopyAttachments
def copy_attachments_from(source_obj, source_bucket = nil, destination_bucket = nil)
self.class.attachment_definitions.keys.each do |attachment_name|
source_attachment = source_obj.send(attachment_name)
@lukemelia
lukemelia / gist:ec6d03802c6a80ac1c99
Created November 25, 2014 14:37
component helper
import Ember from 'ember';
Ember.Handlebars.registerHelper('component', function (name, options) {
var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this;
if (options.types[0] === "ID") {
name = Ember.Handlebars.get(context, name, options);
}
var container = options.data.view.container;
var fullName = 'component:' + name;
var templateFullName = 'template:components/' + name;
@namuol
namuol / INSTALL.md
Last active December 11, 2024 12:21
rage-quit support for bash

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.