Skip to content

Instantly share code, notes, and snippets.

View nikibobi's full-sized avatar
📈
The future belongs to the people that turn data into products

Borislav Kosharov nikibobi

📈
The future belongs to the people that turn data into products
View GitHub Profile
@nikibobi
nikibobi / PairHeap.fs
Created August 3, 2016 08:57
F# pairing heap implementation
module PairHeap
type Heap<'a> =
| Empty
| Heap of 'a * (Heap<'a> list)
let top =
function
| Empty -> failwith "empty"
| Heap (c,_) -> c
@nikibobi
nikibobi / cases.fs
Last active June 7, 2016 12:06
Get a seq of all the cases of union type in F#
open Microsoft.FSharp.Reflection
let cases<'a> = seq {
for case in FSharpType.GetUnionCases typeof<'a> do
yield (FSharpValue.MakeUnion(case, [||]) :?> 'a)
}
#define T 30
#define PIN_START 3
#define PIN_TOP 4
#define PIN_BOT 5
#define PIN_DOWN 7
#define PIN_UP 9
void setup() {
pinMode(PIN_START, INPUT);
#define STEPS 800 //motor steps for one cut
#define DIRECTION 1 //motor direction 1 or 0
#define CUT_TIME 500 //time to cut in ms
#define CUT_COUNT 20 //number of cuts
#define SPEED_TIME 1 //speed between impulses in ms
#define PAUSE_TIME 100 //time after pause button is pressed
#define GRAB_TIME 200 //time for grabbing/releasing the paperj
#define STEP_PIN 5 //motor driver STEP pin
#define DIR_PIN 11 //motor driver DIR pin
@nikibobi
nikibobi / bosakkoshi.css
Last active December 21, 2015 23:38
Tumblr blog stylesheet
/*links*/
a {
text-decoration: none;
}
a:hover {
color: #ffff00;
}
a:active {
@nikibobi
nikibobi / argnull.d
Created August 7, 2013 21:54
argnull.d
import std.string : format;
///Use with mixins. mixin(ArgNull!<arg>);
template ArgNull(alias argument) {
enum ArgNull = format(
"if(%1$s is null)
throw new Exception(\"%1$s cannot be null.\");", argument.stringof);
}
unittest {
@nikibobi
nikibobi / init.d
Created August 7, 2013 20:20
init.d
///This is only for debug. The same role as Type.init == init!Type
@property auto init(Target)() {
writeln(Target.init); //used for debug
return Target.init;
}
///Returns Source's .init converted with std.conv.to to Target
@property auto init(Source, Target)() {
return init!Source.to!Target;
}
@nikibobi
nikibobi / nigga.d
Last active December 20, 2015 17:29
nigga
module nigga;
import std.algorithm : reduce;
import std.conv : to;
import std.process : browse;
import std.stdio : write, writeln, readln;
import std.string : toLower, capitalize, toUpper;
void main() {
"http://www.youtube.com/watch?v=0itOCgJtNVU".browse;
@nikibobi
nikibobi / moduleimport.md
Last active March 5, 2019 16:54
D module import tips

Module imports

When declaring imports follow the following convention:

  1. Specify the module name module fancymodule.functions;
  2. Import all std modules import std.stdio;
  3. Import all external library modules import dsfml.system;
  4. Import all modules part of your project import fancymodule.actions;
  • Have a module named all that only publicly imports all of your library's modules:
@nikibobi
nikibobi / preferences.json
Last active December 18, 2015 05:49
Sublime Text 2 preferences
{
"color_scheme": "Packages/Color Schemes by carlcalderon/Stereokai/Stereokai.tmTheme",
"font_face": "Monaco",
"font_size": 16,
"translate_tabs_to_spaces": true,
"use_tab_stops": false
}