Skip to content

Instantly share code, notes, and snippets.

@flq
flq / EntryPoint.ts
Last active October 10, 2015 23:45
Gists for the blog post porting react app to tyescript
import {assign} from 'lodash'
function startModule() {
//etc.
}
global['Project'] = assign(global['Project'] || {}, {
startModule
});
@flq
flq / Permutation.hs
Last active August 29, 2015 14:23
No-frills permutation code in Haskell
module Permutation where
permutate :: [a] -> [[a]]
permutate [x1,x2] = [[x1,x2],[x2,x1]]
permutate items = concat $ map p $ getEachInFrontOnce items
where
p (x:xs) = map (\items -> [x]++items) $ permutate xs
getEachInFrontOnce items = map (putItemAtIndexToFront items) [0..length items-1]
putItemAtIndexToFront items idx = [items!!idx] ++ take idx items ++ drop (idx+1) items
@flq
flq / CompileHub.cs
Last active March 8, 2019 22:18
Roslyn Refactoring
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
namespace ReFuc
@flq
flq / ast.fs
Last active October 17, 2024 10:39
Lexing and Parsing in F# on Cobol
module Ast
open System
type slotDeclaration= {
Index : int
Name : string
Size : int
}
@flq
flq / euler001.hs
Last active December 24, 2015 08:09
Euler Problems solved with Haskell
-- http://projecteuler.net/problem=1
sum [x | x <- [0..999], any (\d -> mod x d == 0) [3,5]]
@flq
flq / UiMessages.cs
Created September 20, 2013 15:01
Example setup for Membus to dispatch messages of a certain kind onto the UI thread...
// Use like BusSetup.StartWith<Conservative>().Apply<UiMessages>().Construct();
internal class UiMessages : ISetup<IConfigurableBus>
{
void ISetup<IConfigurableBus>.Accept(IConfigurableBus setup)
{
setup.ConfigurePublishing(obj =>
{
obj.MessageMatch(mi => mi.IsType<IUIMsg>()).PublishPipeline(new UiMsgDispatcher());
});
@flq
flq / spaceinvaders.hs
Created September 10, 2013 20:39
A subset of the Space invaders game with moving left/right, shooting with space. The "game" ends when exiting with x or all enemies being dead.h
module Main where
import Control.Monad
import Data.List (maximumBy,minimumBy,find,(\\))
import Data.Ord
import Graphics.UI.SDL as FX
type Point = (Int,Int)
type MovementPattern = [(Movement, [(Int, Int)] -> Bool)]
@flq
flq / josephus.hs
Last active August 16, 2018 20:27
Stuff I made in Haskell
module Josephus where
import Data.List
-- own, atrocious solution to josephus problem
lastSurvivor :: Int -> Int
lastSurvivor 1 = 1
lastSurvivor noOfPeople = fst . last $ unfoldr theSurvivors (1,(1,[])) where
theSurvivors (person, (count, theKilled))
| length theKilled == noOfPeople - 1 = Just (countOn, breakCondition)
@flq
flq / _intro.md
Last active June 18, 2020 19:57
Fizzbuzzes in many colours.

A collection of FizzBuzz implementations over many languages. The specification goes something like this...

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

The expected outcome is something like:

1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,
11,Fizz,13,14,FizzBuzz,16,17,Fizz,19,Buzz,

Fizz,22,23,Fizz,Buzz,26,Fizz,28,29,FizzBuzz,

- Cloned from a remote repository
- Initialized an empty repository
- Pulled from a remote repository
- Made first commit
- Pushed to a remote repository
- Made first local branch
- Pushed a new branch
- Added a second remote
- Merged a branch into another one
- Deleted a local branch