Skip to content

Instantly share code, notes, and snippets.

class FileInput < SimpleForm::Inputs::FileInput
def input_html_classes
super.delete_if { |k| k == 'form-control' }
end
end
defmodule HelloWorld do
def say do
world_pid = spawn(HelloWorld, :world, [])
spawn(HelloWorld, :hello, [1000, world_pid])
end
def hello(n, world_pid) when n > 0 do
IO.puts "Hello, "
world_pid <- {:world, Process.self}
@bellthoven
bellthoven / README
Created September 13, 2012 04:57
Profiling codepoints
Instructions:
- Apply the patch
- Compile elixir
- Run the tests
$ git apply /path/to/patch.diff
$ make compile
$ ./bin/elixir native.ex > /tmp/native.ex
$ ./bin/elixir unicode.ex > /tmp/unicode.ex
@bellthoven
bellthoven / gist:3691245
Created September 10, 2012 14:47
Ponging
defmodule TCPServer do
def listen(port) do
tcp_options = [:list, {:packet, 0}, {:active, false}, {:reuseaddr, true}]
{:ok, l_socket} = :gen_tcp.listen(port, tcp_options)
do_listen(l_socket)
end
defp do_listen(l_socket) do
{:ok, socket} = :gen_tcp.accept(l_socket)
@bellthoven
bellthoven / gist:2343470
Created April 9, 2012 13:40
Access orddict by strings
diff --git a/lib/access.ex b/lib/access.ex
index 009fdf2..1b3d396 100644
--- a/lib/access.ex
+++ b/lib/access.ex
@@ -27,6 +27,10 @@ defimpl Access, for: List do
atom_access(list, atom)
end
+ def access(list, binary) when is_binary(binary) do
+ atom_access(list, binary_to_atom(binary))
@bellthoven
bellthoven / gist:2028139
Created March 13, 2012 11:02
Elixir patch
diff --git a/lib/file.ex b/lib/file.ex
index b64161c..b5715fd 100644
--- a/lib/file.ex
+++ b/lib/file.ex
@@ -53,6 +53,41 @@ defmodule File do
FN.basename(path, extension)
end
+ @doc """
+ Returns a string with one or more paths components joint by the path separator.
@bellthoven
bellthoven / backbone.snippets
Created January 27, 2012 13:50 — forked from milosdakic/backbone.snippets
Backbone.js Vim Snippets
# Class
snippet bc
var ${1:Thing} = Class.extend({
initialize: function(${2:Attributes}) {
}
});
# Model
snippet bbm
var ${1:Thing} = Backbone.Model.extend({
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{graphicx}
\title{Mapeamento de Processo \\ Empresa Gatewaybox Tecnologia LTDA.}
\author{Gustavo Dutra \\ Patric dos Santos \\ Ronaldo Moreira \\ Eduardo Sarturi}
\begin{document}
#!/usr/bin/perl -w
{
package CineFacade;
sub new {
my $this = {};
my $class = shift;
$class = ref($class) || $class;
$this->{amplifier} = shift || undef;
from django.http import HttpResponse,HttpResponseRedirect
from django.shortcuts import render_to_response
from crongd.accounts.forms import LoginForm
def root(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/account/profile')
else:
vars = {'user': request.user, 'loginForm': LoginForm()}
html = render_to_response('root.html',vars)