Skip to content

Instantly share code, notes, and snippets.

View iskeld's full-sized avatar
🐱
🙀

Maciej Woźniak iskeld

🐱
🙀
View GitHub Profile
@iskeld
iskeld / gist:10934747
Created April 16, 2014 21:26
trapped in the state monad
open System;
module StateMonad =
let (>>=) x f = (fun s0 ->
let a,s = x s0
f a s)
let kwik = (>>=)
let returnS a b = a, b
function isCustomObject(obj) {
var result = obj && Object.prototype.toString.call(obj) == '[object Object]';
return result;
}
function deepOmit(obj) {
var newEntity = _.transform(obj, function(result, value, key) {
console.log(value.constructor.name);
var isParentProperty = String(key).toLowerCase().indexOf("parent") >= 0;
if (!isParentProperty) {
@iskeld
iskeld / Funktemplater.fs
Created November 16, 2014 23:21
Initial works on a simple Ms Word templating engine, using Office Open XML SDK
open System;
open DocumentFormat.OpenXml;
open DocumentFormat.OpenXml.Packaging;
open DocumentFormat.OpenXml.Wordprocessing;
[<Literal>]
let openingBracket = "<#"
[<Literal>]
let closingBracket = "#>"
@iskeld
iskeld / ProjectPropertyWriter.cs
Created December 1, 2013 21:16
A simple MSBuild Task to modify the project file properties.
using System.IO;
using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace EldSharp.Scripts.MsBuild
{
public sealed class ProjectPropertyWriterTask : Task
{
@iskeld
iskeld / ConEmu.CtrAltN.lua
Created December 4, 2013 19:00
FAR Manager macro which runs ConEmu tasks inside FAR current working directory.
local ConEmu = "4b675d80-1d4a-4ea9-8436-fdc23f2fc14b"
local function RunTask(TaskName)
callString = string.gsub("Task(\"" .. TaskName .. "\",\"" .. APanel.Path .. "\")", "\\", "\\\\");
Plugin.Call(ConEmu, callString)
end
Macro { area="Shell"; key="CtrlAlt1"; action = function() RunTask("VSConsole") end; }
Macro { area="Shell"; key="CtrlAlt2"; action = function() RunTask("Powershell") end; }
@iskeld
iskeld / OverridenFormatter.swift
Last active May 26, 2016 07:33
Swift base class exceptions
/*
* Code to my question http://stackoverflow.com/questions/37448249/propagating-base-class-errors-in-swift
* I don't understand why there's such a difference in these two Formatters behavior
*/
import Cocoa
class OverridenFormatter: NSNumberFormatter {
override func getObjectValue(obj: AutoreleasingUnsafeMutablePointer<AnyObject?>, forString string: String, range rangep: UnsafeMutablePointer<NSRange>) throws {
// not doing anything, just delegating to the base class
try super.getObjectValue(obj, forString: string, range: rangep)
@iskeld
iskeld / shirt_fetcher.ex
Created September 24, 2017 15:24
Gildan Shirt imager fetcher in Elixir
defmodule ShirtFetcher do
import Meeseeks.CSS
@output_dir "woman_shirts"
def fetch(url) do
root = URI.parse(url)
document = HTTPoison.get!(url)
links = Meeseeks.all(document.body, css("div.itemWrap > a"))
urls = for anchor <- links, href = Meeseeks.Result.attr(anchor, "href"), do: URI.merge(root, href) |> to_string()
@iskeld
iskeld / NaryTreeStateMonad
Created May 29, 2014 20:04
F# State Monad implementation for n-ary tree (based on "The Zen of Stateless State" video by Brian Beckman)
open System
type Tree<'a> =
| Leaf of 'a
| Branch of Tree<'a> list
type StateMonad<'state, 'content> = StateMonad of ('state -> ('state * 'content))
let testTree =
Branch [
@iskeld
iskeld / combinations.fsx
Last active March 2, 2022 19:57
F# combinations generator. Based on the series "Producing combinations" by Eric Lippert
(*
* F# Implementation of the combinations generator, based on the series "Producing combinations" by Eric Lippert
* - http://ericlippert.com/2014/10/13/producing-combinations-part-one/
* - ...
* - http://ericlippert.com/2014/10/27/producing-combinations-part-five/
*)
open System.Collections
open System.Collections.Generic
module List =