Skip to content

Instantly share code, notes, and snippets.

View kaaloo's full-sized avatar

Luis Arias kaaloo

View GitHub Profile
@kaaloo
kaaloo / gist:6884209
Created October 8, 2013 12:52
A simplified model for the natural numbers (Peano numbers), from week 4 of Functional Programming in Scala
abstract class Nat {
def isZero: Boolean
def predecessor: Nat
def successor: Nat = new Succ(this)
def +(that: Nat): Nat
def -(that: Nat): Nat =
if (that.isZero)
this
else
predecessor - that.predecessor
var Zero = {
isZero: function() {
return true;
},
predecessor: function() {
throw "No such element";
},
successor: function() {
/**
* Base64-encodes the specified serialized byte array and sets that base64-encoded String as the cookie value.
* <p/>
* The {@code subject} instance is expected to be a {@link WebSubject} instance with an HTTP Request/Response pair
* so an HTTP cookie can be set on the outgoing response. If it is not a {@code WebSubject} or that
* {@code WebSubject} does not have an HTTP Request/Response pair, this implementation does nothing.
*
* @param subject the Subject for which the identity is being serialized.
* @param serialized the serialized bytes to be persisted.
*/
@kaaloo
kaaloo / gist:9784776
Created March 26, 2014 14:35
10 biggest tables in MySQL
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
The meetup will begin at 18:30 the early presentations at 19:00. The preliminary program is as follows:
6:30 p.m. Doors. Pizza, Champagne ....
7:00 p.m. Intro: Franck Bardol Igor Carron
7:05 p.m. Bastien Legras, Francois Sterin
7:30 p.m. Andrew Ng (remote from SF)
var React = require('react');
var ReactDOM = require('react-dom');
var CSSTransitionGroup = require('react-addons-css-transition-group');
var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route;
var Navigation = ReactRouter.Navigation;
var History = ReactRouter.History;
var createBrowserHistory = require('history/lib/createBrowserHistory');
@kaaloo
kaaloo / file.js
Last active January 29, 2019 22:05
js I ported
const fs = require('fs')
const path = require('path')
const { featureCollection } = require('@turf/helpers')
const Fuse = require('fuse.js')
const streetAddressesGeoJSON = featureCollection(JSON.parse(fs.readFileSync(path.join(__dirname, 'adresses.json'))))
const streetAddressesFuse = new Fuse(streetAddressesGeoJSON.features.features, {
shouldSort: true,
keys: [
"properties.adresse"
@kaaloo
kaaloo / File.fs
Last active January 29, 2019 22:05
module Mdar.Addresses
open Fable.Core.JsInterop
open Fable.Import
open Fable.Import.Fuse
open Node.Exports
open Node.Globals
open Thoth.Json
open Fable.Core
@kaaloo
kaaloo / secrets.py
Created January 9, 2023 16:47
Secrets Management with Colab
import json
import os
from getpass import getpass
from pathlib import Path
from typing import Dict, List, Optional, Union
def load_secrets(secrets: Optional[Union[str, Dict[str, str]]] = None, overwrite=False) -> None:
"""
Loads secrets and sets up some env vars and credential files.