Skip to content

Instantly share code, notes, and snippets.

View bcachet's full-sized avatar

Bertrand Cachet bcachet

  • Neuchatel; Switzerland
View GitHub Profile
#!/usr/bin/env python
def convert_base(value, base_k, base_n):
"""
Convert value from base K to base N
>>> convert_base('5', BASE10, BASE2)
101
>>> convert_base('10', BASE10, BASE2)
1010
>>> convert_base('33', BASE4, BASE8)
public static readonly Parser<char> Dot = CharP('.');
public static Parser<char> Sign = Sat(c => "+-".Contains(c));
public static Parser<char> Exponent = Sat(c => "Ee".Contains(c));
public static Parser<double> RealNumber() {
return
from integer in Natural
from fractional in (from dot in Dot
from digit in Natural
@bcachet
bcachet / DisplayDShowCameraPropertiesPanel.cpp
Last active March 2, 2016 13:55
MFC application to connect to DirectShow's camera and display properties panel
#include "stdafx.h"
#include <atlstr.h>
#include <dshow.h>
//#include <afxwin.h>
#include <string>
using namespace std;
#define CHECK(err)\
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
static class VariableHeightItems
{
[DllImport("user32")]
static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wp, IntPtr lp);
[StructLayout(LayoutKind.Sequential)]

Keybase proof

I hereby claim:

  • I am bcachet on github.
  • I am bcachet (https://keybase.io/bcachet) on keybase.
  • I have a public key ASDPUpFyYKrP5isTfO0tpoTQoxeRxPm9R0AHt_kIe638Ywo

To claim this, I am signing this object:

#load "Tree.fs"
open Tree
open System
open System.IO
type FileSystemTree = Tree<IO.FileInfo,IO.DirectoryInfo>
let fromFile (fileInfo:FileInfo) =
LeafNode fileInfo
namespace Units
type MeasureType =
| BaseUnit of string
| Multiple of Measure * ValueType
with
member this.BaseUnitName =
let rec traverse = function
| BaseUnit s -> s
| Multiple(Measure(_,m),_) -> traverse m
@bcachet
bcachet / graph.fs
Last active August 11, 2017 21:00
Kahn sorting in F#
namespace Graph
// Implementation based on https://gist.github.com/alandipert/1263783
module Map =
let keys map =
map |> Map.toSeq |> Seq.map fst |> Set.ofSeq
let values map =
map |> Map.toSeq |> Seq.map snd |> Set.ofSeq
@bcachet
bcachet / profile.ps1
Last active August 29, 2017 15:01
PowerShell Profile
$modules = @('posh-git', 'Jump.Location', 'PathUtils')
$notInstalledModules = New-Object System.Collections.ArrayList
$modules | ForEach-Object {
If(-Not (Test-Path -Path (Join-Path $PSScriptRoot ".\Modules\$_")))
{
$notInstalledModules.Add($_)
}
}
@bcachet
bcachet / PKGBUILD
Last active December 18, 2017 13:16
libzookeeper PKGBUILD patch
# Maintainer: <aaron.l.france@gmail.com>
pkgname=libzookeeper
pkgver=3.4.7
pkgrel=1
pkgdesc="libzookeeper"
arch=('i686' 'x86_64')
url="https://github.com/apache/zookeeper"
license=('Apache')
makedepends=(apache-ant autoconf cppunit)
checkdepends=()