Skip to content

Instantly share code, notes, and snippets.

View Gonzih's full-sized avatar
🤠
ATX

Maksim Soltan Gonzih

🤠
ATX
View GitHub Profile
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z_.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z_.]+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z_.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z_.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z_.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z_.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z_.]+):[^->\n]*$/\1/f,field/
@Gonzih
Gonzih / redefine-plus.clj
Created March 24, 2013 17:59
clj redefine +
(ns my-awesome-nampspace
(:refer-clojure :exclude [+]))
(defn + [a b]
(println (str a b)))
(+ "aaa" "bbb")
@Gonzih
Gonzih / .xinitrc
Created May 22, 2013 21:34
XMonad + Gnome 3 $HOME/.xinitrc /usr/share/applications/xmonad.desktop /usr/share/gnome-session/sessions/xmonad-gnome.session /usr/share/xsessions/gnome-xmonad.desktop
#!/usr/bin/fish
exec gnome-session --session=xmonad-gnome "$argv"
@Gonzih
Gonzih / try-macro.clj
Last active April 11, 2017 14:09
Clojure try* macro experiment. Part of small project that I'm working on right now (https://github.com/Gonzih/feeds2imap.clj).
(defmacro try*
"Macro to catch multiple exceptions with one catch body.
Usage:
(try*
(println :a)
(println :b)
(catch* [A B] e (println (class e)))
(catch C e (println :C))
(finally (println :finally-clause)))
@Gonzih
Gonzih / .asoundrc
Created July 9, 2013 10:15
How to force alsa to use pulseaudio (useful for flash for example).
#~/.asoundrc
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
@Gonzih
Gonzih / sketch.ino
Last active December 20, 2015 03:09
Arduino timer with nokia display
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
@Gonzih
Gonzih / debugger.lisp
Last active December 22, 2015 17:28
Better stacktraces for SBCL without external dependencies
(in-package :some-debugger)
(defun vector->list (vec)
(coerce vec 'list))
(defun frame-file (frame)
(let* ((code-location (sb-di:frame-code-location frame))
(dsource (sb-di:code-location-debug-source code-location)))
(if dsource
(let ((file (sb-c::debug-source-namestring dsource)))
@Gonzih
Gonzih / main.lisp
Created September 25, 2013 09:58
cl-async socket test
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(ql:quickload "cl-async")
(defun error-handler ()
(lambda (err) (format t "listener event: ~a~%" err)))
@Gonzih
Gonzih / parallel.rb
Last active December 28, 2015 00:19
Experimenting with parallel map in ruby using pipes and processes.
require 'yaml'
require 'enumerator'
module Reducer
def cores_count
case RbConfig::CONFIG['host_os']
when /darwin9/
`hwprefs cpu_count`.to_i
when /darwin/
((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
@Gonzih
Gonzih / gist:7654912
Last active December 29, 2015 10:09
yin-yang continuations puzzle in ruby
# http://stackoverflow.com/questions/2694679/how-does-the-yin-yang-puzzle-work
require "continuation"
yin = ->(cc) { print "@"; sleep 0.5; cc }.call(callcc { |cc| cc })
yang = ->(cc) { print "*"; sleep 0.5; cc }.call(callcc { |cc| cc })
yin.call(yang)