This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reduce = (reducer, initial, [head, ...tail]) => | |
head // condition to go or stop | |
? reduce(reducer, reducer(initial, head), tail) // recursion | |
: initial // stop | |
const map = (mapper, [head, ...tail]) => | |
head // condition to go or stop | |
? [ mapper(head), ...map(mapper, tail) ] //recursion | |
: [] // stop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const count = arr => | |
arr.map( (subarr) => | |
subarr.length ).reduce( (acc, l) => acc + l, 0) | |
const step = ({ | |
source: [ [ head, ...mtail ], ...tail], | |
result | |
}) => ({ | |
source: mtail.length === 0 ? [...tail] : [ [...mtail], ...tail ], | |
result: [...result, head] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (distribuicao) => { | |
const pulaLinha = (linha, coluna) => [linha+1, coluna] | |
const pulaLinhaIniciaColuna = (linha, coluna) => [linha+1, 0] | |
const pulaLinhaColuna = (linha, coluna) => [linha+1, coluna+1] | |
const pulaLinhaDiminuiColuna = (linha, coluna) => [linha+1, coluna-1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str.split(',') | |
.map(section => section.split(';')) | |
.map(([page, rel]) => [ | |
Number(rxPage.exec(page)[1]), | |
rxRel.exec(rel)[1] | |
]).reduce((acc, [ page, rel ]) => ( | |
{...acc, [rel]: page}), {} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (text, p, div) | |
-- based on https://en.wikipedia.org/wiki/Luhn_algorithm | |
lunh : ( Int -> Int ) -> Int -> List Int -> List Int | |
lunh f len nums = | |
let | |
cycles = ceiling (toFloat len / (toFloat (List.length nums))) | |
cycle nums len = | |
nums |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
SIZE = 128 | |
# Preenche uma string com 0x0 em múltiplos de 128 | |
# e divide em blocos de 128 bytes na forma de array de inteiros | |
def blocks(input) | |
final_size = input.bytes.length + (SIZE - input.bytes.length % SIZE) | |
pad_char = 0x0.chr | |
input += pad_char * (final_size - input.bytes.length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Anotações da palestra: | |
https://www.youtube.com/watch?v=oar-T2KovwE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'base64' | |
puts 'Go to https://jsfiddle.net/kq8Lfpar/7/ and encrypt some text for decrypt here' | |
print 'Password: ' | |
password = gets.chomp | |
print 'Encrypted: ' | |
encrypted = gets.chomp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "openssl" | |
require 'digest/sha2' | |
require 'base64' | |
# We use the AES 256 bit cipher-block chaining symetric encryption | |
alg = "AES-256-CBC" | |
# We want a 256 bit key symetric key based on some passphrase | |
digest = Digest::SHA256.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define 'components/singleton', [], -> | |
### | |
Singleton class | |
### | |
class Singleton extends Backbone.View | |
# @static | |
@getInstance = -> | |
@_instance = new @ unless @_instance? | |
@_instance |