Skip to content

Instantly share code, notes, and snippets.

View kohgpat's full-sized avatar
🤖
...

Nikolay Burlov kohgpat

🤖
...
  • Russia, Siberia
View GitHub Profile
var notify = require('gulp-notify');
function log() {
var args = Array.prototype.slice.call(arguments);
// Send error to notification center with gulp-notify
notify.onError({
title: 'Compile Error',
message: '<%= error %>'
}).apply(this, args);

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

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.

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

/*
This document has been created with Marked.app <http://markedapp.com>, Copyright 2011 Brett Terpstra
Please leave this notice in place, along with any additional credits below.
---------------------------------------------------------------
Upstanding Citizen by Brett Terpstra
Non-standard fonts used:
* OSPDIN
* League Gothic
* Fjord
* Inconsolata
@kohgpat
kohgpat / default.vcl.pl
Created November 30, 2012 06:48 — forked from bmarini/default.vcl.pl
A good varnish config for a Rails app
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html
# https://www.varnish-cache.org/trac/wiki/VCLExamples
# Summary
# 1. Varnish will poll the backend at /health_check to make sure it is
# healthy. If the backend goes down, varnish will server stale content
# from the cache for up to 1 hour.
# 2. Varnish will pass X-Forwarded-For headers through to the backend
# 3. Varnish will remove cookies from urls that match static content file
# extensions (jpg, gif, ...)
@kohgpat
kohgpat / Rakefile
Created November 13, 2012 13:10
Sequel Rake tasks for a Sinatra app
# change foo to your library name
# change Foo::Database to your Sequel database
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
@kohgpat
kohgpat / gist:3993186
Created November 1, 2012 11:47 — forked from stepantubanov/gist:3993184
vim 7.3
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
tar -xf vim-7.3.tar.bz2
cd vim73
./configure --prefix=/usr/local --without-x --disable-nls --with-tlib=ncurses --enable-multibyte --enable-rubyinterp --enable-pythoninterp --with-features=huge --enable-gui=gnome2
make
sudo make install
sudo ln -f /usr/local/bin/vim /usr/local/bin/vi
user jessed staff;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
@kohgpat
kohgpat / gist:3847026
Created October 7, 2012 03:44 — forked from jamiehodge/gist:1327195
Warden and Sinatra example
require 'sinatra/base'
require 'rack/flash'
require 'warden'
require 'slim'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table :users do
primary_key :id

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access: