Skip to content

Instantly share code, notes, and snippets.

package models
import (
"time"
"github.com/mrkaspa/geoserver/utils"
"gopkg.in/mgo.v2/bson"
)
type Persistance interface {
(defadvice switch-to-buffer (before save-buffer-now activate)
(when buffer-file-name (save-buffer)))
(defadvice other-window (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(server-start)
atom.commands.add 'atom-text-editor',
'custom:insert-pipe': (event) ->
editor = @getModel()
editor.insertText('|>')
#Add the library to your dependencies
def deps do
[{:mutant, "~> 0.0.2"}]
end
#create a module and use the Mutant module passing the fields
defmodule MyMutant do
use Mutant, name: ""
end
#creating
{:ok, pid} = Agent.start_link(fn -> [] end)
#getting state
Agent.get(pid, fn(arr) -> arr end)
#updating state
Agent.get(pid, fn(arr) -> [1 | arr] end)
@mrkaspa
mrkaspa / ifx.exs
Last active January 8, 2016 06:54
If else built in elixir using macros
defmodule My do
defmacro ifx(conds, [do: code1, else: code2]) do
quote do
case unquote conds do
true -> unquote code1
_ -> unquote code2
end
end
end
end
@mrkaspa
mrkaspa / y-combinator.go
Last active August 29, 2015 14:27 — forked from wancw/y-combinator.go
Y combinator in Go, runable example: http://play.golang.org/p/xVHw0zoaWX
package main
import "fmt"
type (
tF func(int) int
tRF func(tF) tF
tX func(tX) tF
)
@mrkaspa
mrkaspa / onchange.sh
Last active August 29, 2015 14:25 — forked from evgenius/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
function toon {
echo -n "λ>"
}
get_git_dirty() {
git diff --quiet || echo '*'
}
autoload -Uz vcs_info
zstyle ':vcs_info:*' check-for-changes true
@mrkaspa
mrkaspa / sgit
Last active August 29, 2015 14:24
No more large commits
#!/bin/bash
ARGSI="${#}"
if [ $ARGSI == "1" ]; then
git add -A && git commit -m "$1" && git push origin master
else
if [ $ARGSI == "2" ]; then
git add -A && git commit -m "$1" && git push origin $2
else
if [ $ARGSI == "3" ]; then