Skip to content

Instantly share code, notes, and snippets.

View programaker's full-sized avatar

Marcelo da Silva Gomes programaker

View GitHub Profile
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@cmilfont
cmilfont / service.java
Created May 31, 2012 21:10
não quero escrever controllers
package org.javace.oportunidades;
/* pra que? */
import static br.com.caelum.vraptor.view.Results.json;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
/* pra que? */
@xymor
xymor / mountain-lion-brew-setup.markdown
Created August 4, 2012 17:52 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@noelmarkham
noelmarkham / gist:3743931
Created September 18, 2012 16:03
Kleisli composition
scala> import scalaz._, Scalaz._
import scalaz._
import Scalaz._
scala> def str(x: Int): Option[String] = Some(x.toString)
str: (x: Int)Option[String]
scala> def toInt(x: String): Option[Int] = Some(x.toInt)
toInt: (x: String)Option[Int]
@loicdescotte
loicdescotte / Forcomptran.md
Last active May 27, 2023 06:27
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@edenfall
edenfall / js-array-sort.js
Last active March 4, 2024 08:59
Implements selection, bubble, insertion, quick and heap sort algorythms in Array prototype
/*
(c) 2010~2013 Alessandro Ramos dos Santos
edenfall@gmail.com
This file implements selection, bubble, insertion, quick and heap sort algorythms in Array prototype.
It adds a swap() method for use with these algorythms.
Hope you like it. :)
Forgive my bad English. :(
@Diego81
Diego81 / WordCounter.scala
Last active December 12, 2021 12:36
Simple Word Counter implemented using Akka
import akka.actor.{ Actor, ActorRef, Props, ActorSystem }
case class ProcessStringMsg(string: String)
case class StringProcessedMsg(words: Integer)
class StringCounterActor extends Actor {
def receive = {
case ProcessStringMsg(string) => {
val wordsInLine = string.split(" ").length
sender ! StringProcessedMsg(wordsInLine)
@WebReflection
WebReflection / fast-bind.js
Last active March 27, 2021 18:29
Function.prototype.bind performance problem solved in JS … (at least for 90% of common cases without partial args)
/*jslint indent: 2 */
(function (FunctionPrototype) {
'use strict';
var originalBind = FunctionPrototype.bind;
if (!originalBind.patched) {
Object.defineProperty(
FunctionPrototype,
'bind',
{
configurable: true,
@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]