Skip to content

Instantly share code, notes, and snippets.

View blacktaxi's full-sized avatar
🇺🇦
russia is a terrorist state, russians are a terrorist nation

Serhii Yavnyi blacktaxi

🇺🇦
russia is a terrorist state, russians are a terrorist nation
View GitHub Profile
@gusty
gusty / zipIndex.fsx
Last active August 29, 2015 14:01
Solve stack overflow in zipIndex function.
#r @"c:/packages/FsControl.1.0.9/lib/net40/FsControl.Core.dll"
open FsControl.Core.TypeMethods
open FsControl.Core.Types
open FsControl.Operators
type MonadBuilder() =
member inline b.Return(x) = result x
member inline b.Bind(p,rest) = p >>= rest
member b.Let (p,rest) = rest p
@Thimoteus
Thimoteus / settimeout.purs
Last active August 29, 2015 14:23
Synchronous setTimeout with Purescript and the ContT monad
module Main where
import Data.Function
import Debug.Trace
import Control.Monad.Trans
import Control.Monad.Cont.Trans
import Control.Monad.Eff
foreign import data Timeout :: !
type Milliseconds = Number
@toburger
toburger / reflector.fsx
Last active August 29, 2015 14:25
Cool new F# 4.0 feature
module Reflection =
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open System.Reflection
let private (|Name|) (info: MemberInfo) = info.Name
let private (|PropertyName|_|) = function
| PropertyGet (_, Name name, _) -> Some name
| _ -> None
@akimboyko
akimboyko / howto.md
Last active December 17, 2015 23:29
#HotCode conference: Metaprogramming in .Net

Как метапрограмировать используя .Net на конференции #HotCode

@mausch
mausch / gist:6774627
Created October 1, 2013 06:37
Applicative validation is simple.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
// As opposed to magic validation libraries that rely on reflection and attributes,
// applicative validation is pure, total, composable, type-safe, works with immutable types, and it's easy to implement.
public abstract class Result<T> {
private Result() { }
@mrange
mrange / pc.fs
Last active April 27, 2016 09:50
Minimalistic Parser Combinators in F#
// Minimalistic Parser Combinator in F#
// Neither Performance nor Error Reporting has been considered
// For production code you are better off using http://www.quanttec.com/fparsec/
// Inspired by the classic: http://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf
[<Measure>]
type ParserPos
type ParserResult<'T> = 'T option*int<ParserPos>
type Parser<'T> = string*int<ParserPos> -> ParserResult<'T>
module Parser =
@NOTtheMessiah
NOTtheMessiah / SpaceWar test
Created September 19, 2013 22:24
SpaceWar! Originally 40 pages of code written for the PDP-1 and rendered on an oscilloscope, this imitation version, written in Elm, is intended to serve as an example of how Functional Reactive Programming can be used for video games.
-- SpaceWar Elm by NOTtheMessiah (http://twitter.com/N0TtheMessiah)
--
-- Initial Commit
-- Todo: cleanup, graphics, scoreboard, options, respawn delay
--
-- Player 1 uses wasd and shift
-- Player 2 uses arrow keys and space
import Keyboard
import Window
@anaisbetts
anaisbetts / analytics.js
Created January 7, 2015 20:47
Google Analytics in Atom Shell
// Pretend that cookies work
(function (document) {
var cookies = {};
document.__defineGetter__('cookie', function () {
var output = [];
for (var cookieName in cookies) {
output.push(cookieName + "=" + cookies[cookieName]);
}
return output.join(";");
});
@mrcoles
mrcoles / offset.js
Created June 18, 2018 22:27
Compute the offset of a DOM element taking into account CSS transforms and scrolled parents.
export const computeOffset = elt => {
let rect = elt.getBoundingClientRect();
let width = rect.width;
let height = rect.height;
let left = 0;
let top = 0;
let offsetParent = elt;
while (offsetParent) {
left += offsetParent.offsetLeft;
@panesofglass
panesofglass / TcpServer.fsx
Created January 4, 2011 17:43
Asynchronous TCP server in F#
// [snippet: Async socket server using F# async computations.]
open System
open System.IO
open System.Net
open System.Net.Sockets
open System.Threading
type Socket with
member socket.AsyncAccept() = Async.FromBeginEnd(socket.BeginAccept, socket.EndAccept)