Skip to content

Instantly share code, notes, and snippets.

View rexim's full-sized avatar
📺
https://twitch.tv/tsoding

Alexey Kutepov rexim

📺
https://twitch.tv/tsoding
View GitHub Profile
@rexim
rexim / tortoise_and_hare.hs
Created August 7, 2014 18:24
Tortoise-and-hare algorithm
import Data.Array
type LinkedList = Array Int Int
-- Tests ------------------------------
makeTest :: [Int] -> LinkedList
makeTest xs = array (1, n) $ zip [1 .. n] xs
where n = length xs
--- mytits.json 2015-06-22 21:04:35.765208405 +0600
+++ package.json 2015-06-22 20:50:51.645234253 +0600
@@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
- "url": "https://github.com/pspeter3/typescript-register.git"
+ "url": "git+https://github.com/pspeter3/typescript-register.git"
},
"keywords": [
@rexim
rexim / emacs-windows-xbm-bug.el
Created October 25, 2015 09:02
Emacs Windows XBM bug
;;; -*- lexical-binding: t -*-
;; 1. Copy this code to an Emacs buffer
;; 2. M-x eval-buffer
(let ((width 90)
(height 90)
(tiles-column-count 3)
(tiles-row-count 3)
(foreground-color "red")
(background-color "blue"))
#include <iostream>
#include <string>
using namespace std;
template <typename T>
struct Node
{
T data;
Node* next;
@rexim
rexim / io-probe.el
Created March 25, 2016 10:34
IO probe for GCJ
(require 'cl-lib)
(defun read-next-word ()
(let ((end (progn (forward-word)
(point)))
(start (progn (backward-word)
(point))))
(forward-word)
(buffer-substring start end)))
@rexim
rexim / example.ml
Created April 14, 2016 17:02 — forked from Minoru/example.ml
OCamlin' along with @rexim
let on f g = fun x y -> f (g x) (g y)
# uncurry from https://thelema.github.io/batteries-included/hdoc/BatPervasives.html
# dunno if you can use that
# line 15 can't be rewritten like that.
# I'm still trying to come up with another solution, but it's really different from the other two
# line 16
List.map (fun (vx, vy) -> atan2 (float_of_int vy) (float_of_int vx))
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading conrod v0.35.0
Compiling winapi-build v0.1.1
Compiling bitflags v0.6.0
Compiling read_color v0.1.0
Compiling num-traits v0.1.32
Compiling winapi v0.2.7
Compiling rustc-serialize v0.3.19
Compiling kernel32-sys v0.2.2
Compiling fixedbitset v0.1.1

Usage

$ git clone git@github.com:musitdev/portmidi-rs.git
$ nix-shell midi-looper.nix -A midiLooperEnv
$ cd portmidi-rs

$ cargo run --example play

object TermOutputHelper {
def smartShowTerm(term: LambdaTerm): String = {
val (prefix, value) = decode(term)
s"$prefix: $value"
}
private def decode(term: LambdaTerm): (String, String) = {
decoders
.map(_(term)) // apply each encoder to the term