Skip to content

Instantly share code, notes, and snippets.

module Main (
main
) where
import Control.Monad.Trans.Either
import Data.List (stripPrefix)
import Data.Char(isUpper)
import System.Exit (exitFailure)
import Test.QuickCheck.All (quickCheckAll)
import 'dart:html';
/*
// compiled in cygwin with:
// g++ -Wall -O2 -o skinning_test_no_simd skinning_test_no_simd.cpp
#include <vector>
#include <set>
#include <map>
#include <assert.h>
@andyfriesen
andyfriesen / pyconfig.h
Created September 18, 2013 02:44
pyconfig for Python 3.1.2
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
/* pyconfig.h. NOT Generated automatically by configure.
This is a manually maintained version used for the Watcom,
Borland and Microsoft Visual C++ compilers. It is a
standard part of the Python distribution.
WINDOWS DEFINES:
#include <iostream>
#define DEFPROP(name, type_) type_ name;
#define S(_) \
_(foo, int); \
_(bar, float)
struct MyStruct {
@andyfriesen
andyfriesen / lolphp.php
Created February 7, 2014 00:53
PHP, __call and access protection.
<?php
class B {
public function __call($fn, $args) {
$c = array($this, 'hello');
$c();
}
private function hello() {
echo "hello B\n";
@andyfriesen
andyfriesen / lolphp.php
Created February 7, 2014 01:38
PHP and function indirection
<?php
class C {
public function call_private_function($f) {
return $f();
}
private function run() {
echo "run!\n";
}
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files."
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (and (buffer-file-name) (not (buffer-modified-p)))
(revert-buffer t t t) )))
(message "Refreshed open files.") )
template<class T,class...>class C{C<T*const,T,C>a;C<T,C>b;};C<int>c;
@andyfriesen
andyfriesen / oops.cpp
Last active August 29, 2015 14:03
It would be nice if this generated a compiler warning
#include <stdio.h>
enum Enumeration {
ENUM = 0,
};
struct S final {
explicit S(unsigned short id)
: S(ENUM, value)
{ }
@andyfriesen
andyfriesen / TestableIO.hs
Last active August 10, 2021 18:25
Tiny example showing how to force your Haskell code to be 100% deterministic under unit tests
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Control.Applicative ((<$>))
import Control.Monad.State.Lazy as S
class Monad m => World m where
writeLine :: String -> m ()
instance World IO where