Skip to content

Instantly share code, notes, and snippets.

View ramntry's full-sized avatar

Roman Tereshin ramntry

View GitHub Profile
#include <tuple>
#include <iostream>
template <size_t... Indices>
struct indices {
template <size_t Last>
using append = indices<Indices..., Last>;
};
template <size_t Size>
@ramntry
ramntry / llvm-bootstrap.sh
Last active August 29, 2015 14:05
LLVM Bootstrapping Script
#!/bin/bash
llvm_releases_url="http://llvm.org/releases"
llvm_major_version="3.4"
llvm_minor_version="2"
llvm_version="${llvm_major_version}.${llvm_minor_version}"
llvm_source_directory="llvm-${llvm_version}.src"
llvm_archive_filename="${llvm_source_directory}.tar.gz"
llvm_archive_url="${llvm_releases_url}/${llvm_version}/${llvm_archive_filename}"
@ramntry
ramntry / jblab-summer-school-2014-bootstrap.sh
Last active August 29, 2015 14:05
Programs and Proofs: Mechanizing Mathematics with Dependent Types Software Bootstrapping Script
#!/bin/bash
# Bootstrapping script for setup software environment needed by SSReflect course
# http://ilyasergey.net/pnp-2014/
# Was tested only on
# Ubuntu/Lubuntu 14.04 LTS 64 bit
# Ubuntu 12.04 LTS 64 bit
# Debian 7.6.0 64 bit
# Fedora 20 64 bit
@ramntry
ramntry / create_2k
Created August 23, 2014 11:19
Random write disk benchmark
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/lexical_cast.hpp>
void create_file(std::string const &filename, std::string const &contents) {
std::ofstream outfile(filename.c_str(), std::ios::binary);
@ramntry
ramntry / explicit_polymorphic_function.ml
Last active August 29, 2015 14:05
Explicit polymorphism in OCaml
type 'value expression =
| Const of 'value
| IfThenElse of bool expression * 'value expression * 'value expression
let rec eval : 'value. 'value expression -> 'value = function
| Const value -> value
| IfThenElse (condition, then_expr, else_expr) ->
if eval condition
then eval then_expr
else eval else_expr
@ramntry
ramntry / very_usefull_program.pl
Created August 19, 2014 13:14
Express Yourself!
#!/usr/bin/perl -w
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..2)
{;}my @camel1hump;my$camel;
my$Camel ;while( ){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=)){@camel1hum p=split(//);}while(@dromeda
ry1){my$camel1hump=0 ;my$CAMEL=3;if(defined($_=shif
value rec meta_binding _loc =
fun
[ Ast.BiAnt x0 x1 -> Ast.ExAnt x0 x1
| Ast.BiEq x0 x1 x2 ->
Ast.ExApp _loc
(Ast.ExApp _loc
(Ast.ExApp _loc
(Ast.ExId _loc
(Ast.IdAcc _loc (Ast.IdUid _loc "Ast")
(Ast.IdUid _loc "BiEq")))
@ramntry
ramntry / main.ml
Created August 17, 2014 19:03
Call-by-name?
let get_incremetor =
let current_defult_delta = ref 0 in
let closure () =
incr current_defult_delta;
fun ?(delta=(int_of_string (string_of_int (!current_defult_delta)))) n ->
n + delta
in
closure
let () =
@ramntry
ramntry / swapps1.ml
Created August 11, 2014 08:53
Irregular types, swapps
type ('first, 'second, 'third) irregular =
| Swap of ('second, 'first, 'third) irregular
| Cycle of ('second, 'third, 'first) irregular
| Leaf of 'first * 'second * 'third
let rec map_irregular first_func second_func third_func = function
| Swap swapped -> Swap (map_swapped second_func first_func third_func swapped)
| Cycle cycled -> Cycle (map_cycled second_func third_func first_func cycled)
| Leaf (first, second, third) -> Leaf (first_func first, second_func second, third_func third)
@ramntry
ramntry / aliases.hs
Last active August 29, 2015 14:04
Haskell type aliases
import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Function (on)
import Data.List
data SimpleType = SimpleType TyCon [TyVar]
data Type = Type TyCon [Type]
| TyVar TyVar