This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| module Main where | |
| import Control.Applicative | |
| import Control.Monad | |
| import qualified Data.Map as M | |
| import Test.QuickCheck (quickCheck) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet.html | |
| {-# LANGUAGE FlexibleContexts #-} | |
| module Main where | |
| import Control.Applicative | |
| import Control.Monad.Reader | |
| loeb :: Functor a => a (a x -> x) -> a x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://en.wikipedia.org/wiki/Cantor%27s_diagonal_argument | |
| def bits(n): | |
| return list(int(x) for x in reversed(bin(n)[2:])) | |
| def nth(lst, n): | |
| if n < len(lst): | |
| return lst[n] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys, marshal, functools, subprocess | |
| child_script = """ | |
| import marshal, sys, types; | |
| fn, args, kwargs = marshal.load(sys.stdin) | |
| marshal.dump( | |
| types.FunctionType(fn, globals())(*args, **kwargs), | |
| sys.stdout) | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import bohrium as np | |
| from math import pi | |
| import matplotlib.pyplot as plt | |
| import matplotlib.colors as colors | |
| fig = plt.figure() | |
| plt.xticks([]) | |
| plt.yticks([]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Linq; | |
| [RequireComponent(typeof(Rigidbody))] | |
| public class RigidbodyMassCalculator : MonoBehaviour { | |
| public float density = 1f; | |
| public bool recalculateOnAwake = true; | |
| Rigidbody rb; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <time.h> | |
| namespace { | |
| const int64_t SEC = 1; | |
| const int64_t MILI = 1000; // 10^3 | |
| const int64_t MICRO = 1000 * 1000; // 10^6 | |
| const int64_t NANO = 1000 * 1000 * 1000; // 10^9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export PROMPT_DIRTRIM=3 | |
| export PS1='\[\033[0;35m\]\u@\h\[\033[0;33m\] \w\[\033[00m\]$ ' | |
| export TERM=xterm-256color | |
| export PATH="$HOME/bin:$PATH" | |
| export GOPATH="$HOME/.go" | |
| export USE_CCACHE=1 | |
| export CCACHE_DIR="$HOME/.ccache" | |
| export CC=/usr/bin/clang | |
| export CXX=/usr/bin/clang++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <errno.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| namespace { | |
| template<typename F> | |
| class ScopeGuard { | |
| public: | |
| ScopeGuard(F f) : f_(f) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <complex> | |
| #include <tuple> | |
| namespace { | |
| // See http://blogs.mathworks.com/cleve/2013/10/14/complex-step-differentiation/ | |
| template<class R, class F> | |
| std::tuple<R, R> dF(F f, R x, R h=1e-8) { | |
| using C = std::complex<R>; |