Skip to content

Instantly share code, notes, and snippets.

View EmmanuelOga's full-sized avatar
🏠
Working from home

Emmanuel Oga EmmanuelOga

🏠
Working from home
View GitHub Profile
@EmmanuelOga
EmmanuelOga / salsa.fs
Created December 27, 2016 03:00
Scraping salsa songs with F#!~
# Scraping http://salsahackers.com/dj-pick/
open System
open System.Text.RegularExpressions
open FSharp.Data
open FSharp.Data
let Show x = x.Dump(); x
let domain = "http://salsahackers.com"
@EmmanuelOga
EmmanuelOga / F#
Created December 27, 2016 03:00
Salsa songs!
# Scraping http://salsahackers.com/dj-pick/
open System
open System.Text.RegularExpressions
open FSharp.Data
open FSharp.Data
let Show x = x.Dump(); x
let domain = "http://salsahackers.com"
@EmmanuelOga
EmmanuelOga / urlProcessor.fs
Created November 24, 2016 02:51
Agent based web crawler
open System.Net
open System.IO
open System.Threading
open System.Text.RegularExpressions
let limit = 50
let linkPat = "href=\s*\"[^\"h]*(http://[^&\"]*)\""
let getLinks (txt : string) =
[ for m in Regex.Matches(txt, linkPat) -> m.Groups.Item(1).Value ]
@EmmanuelOga
EmmanuelOga / reloader.dart
Created June 13, 2016 22:28
Simple web reloader
library simple_reloader;
import 'dart:async';
import 'dart:core';
import 'dart:html';
final RegExp paramPat = new RegExp(r'(\&|\?)_cacheOverride=\d+');
final RegExp queryPat = new RegExp(r'\?');
reloadStylesheets() {
@EmmanuelOga
EmmanuelOga / paragraph.dart
Created March 16, 2016 05:41
Paragraphs with html5 and dart.
import 'dart:html';
import 'dart:math';
var text = '''
William Shakespeare (/ˈʃeɪkspɪər/;[1] 26 April 1564 (baptised) – 23 April 1616)[nb 1] was an English poet, playwright, and actor, widely regarded as the greatest writer in the English language and the world's pre-eminent dramatist.[2] He is often called England's national poet, and the "Bard of Avon".[3][nb 2] His extant works, including collaborations, consist of approximately 38 plays,[nb 3] 154 sonnets, two long narrative poems, and a few other verses, some of uncertain authorship. His plays have been translated into every major living language and are performed more often than those of any other playwright.[4]
Shakespeare was born and brought up in Stratford-upon-Avon, Warwickshire. At the age of 18, he married Anne Hathaway, with whom he had three children: Susanna, and twins Hamnet and Judith. Sometime between 1585 and 1592, he began a successful career in London as an actor, writer, and part-owner of a playing company called the Lord Chamberlain's
@EmmanuelOga
EmmanuelOga / composite.dart
Created January 6, 2016 02:03
dart composition
class A {
String f1, f2, f3;
A({this.f1, this.f2, this.f3});
@override
String toString() => 'A: $f1 $f2 $f3';
}
class B {
String f1, f2, f3;
B({this.f1, this.f2, this.f3});
@EmmanuelOga
EmmanuelOga / composite.ceylon
Last active January 6, 2016 02:22
composition in ceylon
class A(String f1 = "a1", String f2 = "a2", String f3 = "a3") {
shared default String str => "A: ``f1``, ``f2``, ``f3``";
}
class B(String f1 = "b1", String f2 = "b2", String f3 = "b3") {
shared default String str => "B: ``f1``, ``f2``, ``f3``";
}
class Base(String base1 = "base1", String base2 = "base2", String base3 = "base3") {
shared actual default String string = "Base: ``base1``, ``base2``, ``base3``";
@EmmanuelOga
EmmanuelOga / drawAorBonClick.rkt
Created November 28, 2015 02:59
Draws something different each time someone clicks on the window.
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
;; The onMouse function takes a world and mouse event parameters, and returns a new world if a click
;; happened, or the same world if some other event happened (e.g. mouse move)
(define (onMouse world x y ev)
(if (equal? ev "button-down")
(cond
@EmmanuelOga
EmmanuelOga / recursive.rkt
Created November 26, 2015 11:32
Recursive data structure (plai)
#lang plai
(((λ (newbox)
(λ (setbox)
((λ (_) newbox) (setbox newbox))))
(box 'dummy))
(λ (box) (set-box! box box)))
; b now refers to itself.
@EmmanuelOga
EmmanuelOga / begin.rkt
Created November 26, 2015 00:05
Desugaring sequencing (begin ...) over lambdas.
#lang racket
; Desugaring sequencing (begin ...) over lambdas.
(define (h _) (print "hello"))
(define (w _) (print "world"))
(define (seq x)
(λ (y)
(y (x null))))