Skip to content

Instantly share code, notes, and snippets.

View gtkatakura's full-sized avatar

gtkatakura

View GitHub Profile
@leobaiano
leobaiano / array_aleatorio.js
Last active July 1, 2016 16:23
Criando arrays aleatórios
function createRandomArray( lenght, max ) {
return Array.apply( null, Array ( lenght ) ).map( function( _, i ) {
return Math.round( Math.random() * max );
});
}
console.log( createRandomArray( 20, 300 ) );
@VictorTaelin
VictorTaelin / why.md
Last active August 12, 2017 22:54
What is wrong with the web and why we need Moon (draft)

What is wrong with the web and why we need Moon (draft)

A few days ago, I published an article about Moon, a fundamental building block of a decentralized browser that aims to solve many of Mist's problems. I've showed up some fancy features such as its decentralized package manager and a generalized monadic notation. I guess that made some people angry, wondering why the hell I made yet another programming language when we have so many of them. If you're on that group: you're right. I'm sorry. Believe me when I say I'm as tired of new languages as you, and I'm as pissed with myself as you are. But I'd not have done this if I didn't have a very good reason. Give me, thus, a chance to justify my sins. For one, I didn't actually invent a programming lang

@Luiz-Monad
Luiz-Monad / high_ef.fs
Last active January 31, 2018 01:32
HighOrder EntityFramework
//how to implement CRUD with F# and entityframework and TypeClasses
//transform this into an highorder type
type Customer with static member queryId = <@ fun ( λ : Customer ) -> λ.Id @>
//just a helper
type entity<'T> = ('T -> int)
//our highorder context
@Luiz-Monad
Luiz-Monad / overloaded_overload.fs
Last active January 31, 2018 01:32
Overloading and TypeClasses
//////////////////////////////////////////////////////////////////////////////////////////
// first try, trying to generalize over overloading, nope, cant generalize over
// two overloads
let inline backend<'M, 'C, 'VM when 'C : (new : unit -> 'C)
and 'C : (member Get : unit -> 'M seq)
and 'C : (member Get : int Nullable -> 'M seq)
and 'C : (member Get :'M Selector -> 'M seq)> () =
let getGet0 ( controller : ^C ) () =
@adomokos
adomokos / visitor_pattern_example.rb
Created May 24, 2011 17:28
The Visitor Pattern implementation in Ruby from the Wikipedia example
class CarElement
def accept(visitor)
raise NotImpelementedError.new
end
end
module Visitable
def accept(visitor)
visitor.visit(self)
end
@VitorLuizC
VitorLuizC / without.js
Last active December 10, 2018 22:39
"without" module exports a function. It returns a new object without specified properties.
/**
* Returns new object without specified properties.
* @param {Array.<string>} keys
* @param {Object.<string, *>} object
* @returns {Object.<string, *>}
*/
const without = (
[ key, ...keys ] = [],
{ [key]: _, ...object } = {}
) => keys.length ? object : without(keys, object);

Today, in Ruby, if I want to make a network request, I block

response = Net::HTTP.get("/post/1")

If I want to do multiple requests in parallel, I can use a thread per request

responses = ["/post/1", "/post/2"].map do |url|
@VictorTaelin
VictorTaelin / formality.md
Last active July 28, 2019 03:32
Formality FAQ - atualizado 27 de Julho de 2019

O que é o Formality?

Formality é uma linguagem de programação funcional em desenvolvimento, e que será lançada oficialmente ainda esse ano. Ela é uma linguagem bem "hardcore", com tipos dependentes e provas formais, inspirada em Haskell/Agda/Coq, mas com uma série de diferenciais, principalmente no que diz respeito ao runtime (optimal reductions, paralelismo, runtime fusion, etc.), visando combinar todo esse alto nível matemático com o potencial de ser realmente eficiente na prática. Essa é a carinha atual dela:

// Datatypes estilo Haskell

// O tipo de números naturais
T Nat
| succ {pred : Nat}
@arikfr
arikfr / query.py
Created May 21, 2015 15:19
re:dash Python datasource join example
# get existing queries results
users = get_query_result(132) # this one has {id, name}
events_by_users = get_query_result(131) # this one has {user_id, events count}
# actual merging. can be replaced with helper function and/or some Pandas code
events_dict = {}
for row in events_by_users['rows']:
events_dict[row['user_id']] = row['count']
for row in users['rows']: