Skip to content

Instantly share code, notes, and snippets.

@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
#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)
#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
atom.commands.add 'atom-text-editor',
'custom:insert-pipe': (event) ->
editor = @getModel()
editor.insertText('|>')
(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)
package models
import (
"time"
"github.com/mrkaspa/geoserver/utils"
"gopkg.in/mgo.v2/bson"
)
type Persistance interface {
package models
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gopkg.in/mgo.v2/bson"
)
package models
type mockPersistor struct {
}
func NewMockPersistor() Persistance {
return mockPersistor{}
}
func (p mockPersistor) PersistAndFind(sn StrokeNear) ([]Stroke, error) {
@mrkaspa
mrkaspa / build.gradle
Created August 30, 2016 18:46
Calling spark from jruby
/*
* This project is intended to be used as an acceptance test *and* a
* documentation example. If you change this file, please be sure that it
* renders appropriately in the generated documentation
*/
buildscript {
repositories { jcenter() }
dependencies {
/* here to make sure that our dependencies get loaded in properly under
@mrkaspa
mrkaspa / pre-commit
Created September 16, 2016 21:59 — forked from matteosister/pre-commit
pre-commit hook for elixir
#!/bin/sh
# credo checks before commit
mix credo
CREDO_RES=$?
if [ $CREDO_RES -ne 0 ]
then
exit $CREDO_RES
fi