Skip to content

Instantly share code, notes, and snippets.

View clementi's full-sized avatar
🎵
NP: String Quartet in D Major, Op. 50 No. … (3:34/10:05)

Jeff Pratt clementi

🎵
NP: String Quartet in D Major, Op. 50 No. … (3:34/10:05)
View GitHub Profile
@clementi
clementi / rap.py
Last active August 29, 2015 14:04
Recycle IIS app pools
import argparse
import json
import os.path
import subprocess
import sys
CONFIG_FILE_NAME = ".raprc"
APPCMD_PATH = "c:/windows/system32/inetsrv/appcmd.exe"
@clementi
clementi / lspath.fs
Last active August 29, 2015 14:19
List the contents of the PATH environment variable in F#
open System
open System.IO
let getPathItems =
let path = Environment.GetEnvironmentVariable "PATH" in
path.Split Path.PathSeparator
[<EntryPoint>]
let main argv =
Array.iter (printfn "%s") getPathItems
@clementi
clementi / lspath.hs
Last active August 29, 2015 14:19
List the contents of the PATH environment variable in Haskell
import System.Environment
import System.FilePath
wordsWhen :: (Char -> Bool) -> String -> [String]
wordsWhen p s = case dropWhile p s of
"" -> []
s' -> w : wordsWhen p s''
where (w, s'') = break p s'
main :: IO ()
@clementi
clementi / which.hs
Last active August 29, 2015 14:20
"Which" in Haskell
module Main where
import System.Directory
import System.Environment
import System.Info
firstJust :: [Maybe a] -> Maybe a
firstJust [] = Nothing
firstJust (x:xs) = case x of
Nothing -> firstJust xs
#lang racket
(require racket/match)
(define (eval exp env)
(match exp
[`(,f ,e) (apply (eval f env) (eval e env))]
[`(λ ,v . ,e) `(closure ,exp ,env)]
[(? symbol?) (cadr (assq exp env))]))
(defn factorial [n]
(if (= n 0)
1
(* n (factorial (- n 1)))))
var prefixes = [
{
prefix: "",
name: ""
},
{
prefix: "Ki",
name: "kibi"
},
{
var prefixes = [
{
prefix: "",
name: ""
},
{
prefix: "Ki",
name: "kibi"
},
{
namespace Ncoa.Matching.UI
{
using System.Collections.Generic;
using System.Linq;
using StorageAccess;
public abstract class FakeQueryStorage<T> : IQueryStorage
{
protected IEnumerable<T> items;
def logistic_map(x0, r, n):
if n == 0:
return x0
x_prev = logistic_map(x0, r, n - 1)
return r * x_prev * (1 - x_prev)