Skip to content

Instantly share code, notes, and snippets.

View dimchansky's full-sized avatar

Dmitrij Koniajev dimchansky

View GitHub Profile
@dimchansky
dimchansky / sse.go
Created June 13, 2017 07:46 — forked from ismasan/sse.go
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@dimchansky
dimchansky / .block
Created June 9, 2017 12:51 — forked from mbostock/.block
Line Transition
license: gpl-3.0

Making a PDF + Bootable ISO Hybrid Polyglot

If you've not seen my résumé, that is what this post is about, and you should probably look at it first to get an idea of what's happening.

A Tale of Two Files

PDF and ISO9660 are two very different file formats. PDF is actually a surprisingly human-readable (but, sadly, not very human-writable) plain-text format, technically descended from PostScript. PDF is not very forgiving on changes, as it stores tables of offsets to various elements, so it is very difficult to insert or remove content manually without going through a robust PDF manipulation library.

ISO9660 is a disk filesystem, meant to be written once and read many times on many different kinds of hardware. As it is sector-based, it expects data structures to be at particular absolute offsets.

@dimchansky
dimchansky / gist:4fb975b1af6b9053a824705d10f848ad
Created November 22, 2016 16:45 — forked from sgergely/gist:3793166
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@dimchansky
dimchansky / fileserver.go
Created April 22, 2016 20:22
A very simple static file server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8080": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8080 will display the index.html or directory
listing file.
*/
package main
@dimchansky
dimchansky / concurrency-in-go.md
Created October 4, 2015 17:50 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
@dimchansky
dimchansky / introrx.md
Last active August 29, 2015 14:21 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@dimchansky
dimchansky / Sorted-Word-Frequencies.hs
Created April 4, 2015 10:54
Counts the number of times each word appears in a (non-unicode) file and outputs result to other file sorting by frequencies and then by word (asc).
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
module Main where
import qualified Data.ByteString.Lazy as S
import qualified Data.ByteString.Lazy.Builder as SB
import qualified Data.ByteString.Lazy.Char8 as C
import Data.Foldable (foldMap)
import qualified Data.HashMap.Strict as HM
import Data.List (sortBy)
@dimchansky
dimchansky / MaybeMonad.cs
Last active August 29, 2015 14:17
Maybe monad in C#
using System;
namespace MaybeMonad
{
internal class Program
{
private static void Main()
{
var result = from a in "Hello ".ToMaybe()
from b in Nothing<string>.Instance