Skip to content

Instantly share code, notes, and snippets.

View ademar's full-sized avatar
👻
Building stuff

Ademar Gonzalez ademar

👻
Building stuff
View GitHub Profile
@ademar
ademar / gist:898038
Created April 1, 2011 12:00
One-Way File Synchronization
// Learn more about F# at http://fsharp.net
open Microsoft.FSharp.Control
open System.Collections.Generic
open System.Threading
open System.IO
type RequestGate(n:int) =
let semaphore = new Semaphore(initialCount=n,maximumCount=n);
member x.AcquireAsync(?timeout) =
async {
@ademar
ademar / gist:911439
Created April 9, 2011 14:39
How to write a financial contract
//Implements the theory from 'How to write a financial contract' by S.L Peyton Jones and J-M Eber
type RandomVariable<'a> = seq<'a>
type Process<'a> = Process of (seq<RandomVariable<'a>>)
let liftP f (Process(p)) = Process(Seq.map (Seq.map f) p)
let liftP2 f (Process(p1)) (Process(p2)) =
Process(Seq.map2 (Seq.map2 f) p1 p2)
@ademar
ademar / gist:1016874
Created June 9, 2011 14:49
Combinators for logic programming
// Based on the article 'Combinators for logic programming' by Michael Spivey and Silvija Seres.
let rec inf_seq n = seq { yield n; yield! inf_seq (n+1) }
let rec lzw f l1 l2 =
LazyList.delayed ( fun () ->
match l1,l2 with
|LazyList.Nil, _ -> l2
|_, LazyList.Nil -> l1
|LazyList.Cons(p1,tail1),LazyList.Cons(p2,tail2)
@ademar
ademar / gist:1256105
Created October 1, 2011 14:24
RSK algorithm
//RSK algorithm (Robinson–Schensted–Knuth correspondence)
//Implements a bijective mapping between permutations and pairs of standard Young tableaux, both having the same shape.
//http://en.wikipedia.org/wiki/Robinson%E2%80%93Schensted_correspondence
let snoc p ls = ls @ [p]
let bump q L =
let rec loop P i = function
| [] -> (None, snoc q P,i)
@ademar
ademar / gist:8443249
Last active November 5, 2019 08:51
CDO enable ssl
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
if needToAuth then
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
@ademar
ademar / gist:a54838eded33a86b9281
Created September 24, 2014 02:09
Bitcoin block chain SQL schema
// original found : https://bitcointalk.org/index.php?topic=38246.0
CREATE TABLE blocks (
hash char(32) binary primary key,
version integer,
hashPrev char(32) binary not null,
hashMerkleRoot char(32) binary not null,
nTime integer unsigned not null,
nBits integer unsigned not null,

Keybase proof

I hereby claim:

  • I am ademar on github.
  • I am ademar (https://keybase.io/ademar) on keybase.
  • I have a public key whose fingerprint is 9321 F370 F2D3 CB59 37FB F881 7E2C DB32 F13C 9E5B

To claim this, I am signing this object:

@ademar
ademar / gist:dcb5cd2fdd832fc34baa
Created October 30, 2014 14:06
Generate GRANT statements for stored procedures (SQL Server 2000)
DECLARE @User varchar(50)
SELECT @User = 'myuser'
SELECT
'GRANT EXEC ON ' + name + ' TO ' + @User
FROM
sysobjects
WHERE
type = 'P'
AND category = 0
@ademar
ademar / sample.php
Created August 21, 2015 13:21
PHP example : Sending email and performing SMTP authentication with Pearl Mail package
<?
# PHP example : Sending email and performing SMTP authentication with Pearl Mail package
include_once("Mail.php");
$recipients = 'mail_to@domain.mail';
$headers["From"] = 'mail_from@domain.mail';
$headers["To"] = 'mail_to@domain.mail';

Keybase proof

I hereby claim:

  • I am ademar on github.
  • I am ademar (https://keybase.io/ademar) on keybase.
  • I have a public key whose fingerprint is E397 C714 13D6 781E 5E83 629D 1A3B 3917 6D43 2321

To claim this, I am signing this object: