Skip to content

Instantly share code, notes, and snippets.

View lrlucena's full-sized avatar
🦐
Working on Potigol Language (potigol.github.io)

Leonardo Lucena lrlucena

🦐
Working on Potigol Language (potigol.github.io)
View GitHub Profile
import scala.xml.{Node, Elem, Group}
/**
* A path to a Node in a Node tree.
*/
sealed trait NodePath {
def depth: Int
}
object NodePath {
@mumoshu
mumoshu / read-a-file-using-stream.scala
Created December 9, 2011 00:58
Read a file using Stream (Scala)
import java.io.File
import java.io.FileInputStream
case class Chunk(length: Int, bytes: Array[Byte])
def fileContentStream(fileIn: FileInputStream): Stream[Chunk] = {
val bytes = Array.fill[Byte](1024)(0)
val length = fileIn.read(bytes)
Chunk(length, bytes) #:: fileContentStream(fileIn)
}
@lrlucena
lrlucena / Q01.rb
Last active October 7, 2015 04:27
Gabarito da Lista de Exercícios 12
# Escreva uma classe, chamada Ponto, que representa um ponto no
# plano cartesiano. A figura abaixo mostra quais atributos e métodos
# da classe.
class Ponto
attr_reader :x, :y
def initialize(x,y)
@x = x
@y = y
@paulmillr
paulmillr / type-inference.coffee
Created July 17, 2012 17:39
Damas-Hindley-Milner type inference algorithm in LiveScript
# Algorithm W (Damas-Hindley-Milner) in LiveScript.
# By Paul Miller (paulmillr.com), Public domain.
#
# Based on Robert Smallshire's [Python code](http://bit.ly/bbVmmX).
# Which is based on Andrew's [Scala code](http://bit.ly/aztXwD).
# Which is based on Nikita Borisov's [Perl code](http://bit.ly/myq3uA).
# Which is based on Luca Cardelli's [Modula-2 code](http://bit.ly/Hjpvb).
# Something like that.
prelude = require './prelude'
@jeffreyolchovy
jeffreyolchovy / LRUCache.scala
Created August 6, 2012 21:19
LRU cache implementation in Scala
import akka.stm._
import scala.collection.immutable.ListMap
case class LRUCache[A, B](private val MAX_ENTRIES: Int)
{
protected val cache = Ref(ListMap.empty[A, B])
def getOrElse(key: A)(fn: => B): B = {
get(key).getOrElse {
val result = fn
@rxaviers
rxaviers / gist:7360908
Last active April 19, 2024 22:38
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@iamnewton
iamnewton / bash-colors.md
Last active April 12, 2024 10:58
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
# -*- coding: utf-8 -*-
'''
Autor: Luiz Felipe na Lista Python Brasil 31-10-2015
A série de Fibonacci é formada pela seqüência 1,1,2,3,5,8,13,21,34,55,...
Faça um programa capaz de gerar a série até o n−ésimo termo.
'''
#Fn = F(n-1) + F(n-2)