Skip to content

Instantly share code, notes, and snippets.

@jeffweiss
jeffweiss / cleanCheckout.groovy
Created February 7, 2017 19:28
Jenkins clean checkout
#!groovy
def call() {
checkout([
$class: 'GitSCM',
branches: scm.branches,
extensions: scm.extensions + [[$class: 'WipeWorkspace'], [$class: 'LocalBranch']],
userRemoteConfigs: scm.userRemoteConfigs
])
}
@jeffweiss
jeffweiss / fpm snippet
Created April 15, 2016 17:57
snippets for elixir continuous delivery pipeline
cmd = [
'fpm',
'-t deb',
'-s dir',
'-d postgresql',
'-m ' + config[:maintainer],
"-n '#{config[:product]}'",
"--prefix /opt/puppet/#{config[:product]}",
'-v ' + deb_version,
"--deb-init #{config[:product]}.init",
@jeffweiss
jeffweiss / channels.conf
Created February 23, 2016 17:34
ohaibot channels.conf example
[<<"#ohaibot-testing">>].
[<<"#elixirconf">>].
@jeffweiss
jeffweiss / emit_log.exs
Last active June 29, 2022 21:02
RabbitMQ Tutorial - Elixir examples
{:ok, connection} = AMQP.Connection.open
{:ok, channel} = AMQP.Channel.open(connection)
message = Enum.join(System.argv, " ") || "Hello World!"
AMQP.Exchange.declare(channel, "logs", :fanout)
AMQP.Basic.publish(channel, "logs", "", message)
IO.puts " [x] Sent '#{message}'"
@jeffweiss
jeffweiss / eldap.exs
Created November 9, 2015 19:30
sample of using eldap from elixir
:application.ensure_all_started(:ssl)
{:ok, handle} = :eldap.open(['ldap.example.com'], [{:port, 636}, {:ssl, true}])
authenticated =
:ok == :eldap.simple_bind(handle,
'uid=jeff,ou=users,dc=example,dc=com',
'notmyrealpassword')
{:ok, {:eldap_search_result, list_of_entries, _}} =
@jeffweiss
jeffweiss / x10.ex
Created November 4, 2015 22:45
Sample X10 packet (de)composition in Elixir
defmodule X10 do
# all codes referenced from http://www.haibrain.com/informatie-domotica-x10-protocol-c-131_148_141.html?language=en
@house_codes %{
6 => :house_a,
14 => :house_b,
2 => :house_c,
10 => :house_d,
1 => :house_e,
9 => :house_f,
@jeffweiss
jeffweiss / mix.exs
Last active December 18, 2018 23:13
Retrieving application version number in mix.exs from git describe
defmodule MyApp.Mixfile do
use Mix.Project
def project do
[app: :my_app,
version: get_version,
elixir: "~> 1.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: Mix.compilers,
build_embedded: Mix.env == :prod,
@jeffweiss
jeffweiss / post_message.lua
Created October 4, 2015 02:26
Sending POSTs to Elixir Phoenix using wrk or wrk2
wrk.method = "POST"
-- this assumes that we're sending to a html form endpoint with csrf protection disabled
-- wrk.body and wrk.headers would be different if we were sending a JSON payload to a JSON API endpoing
wrk.body = "message[body]=wat"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
@jeffweiss
jeffweiss / basic_bench.exs
Last active August 29, 2015 14:20
Numbers to words
defmodule BasicBench do
use Benchfella
@num :random.uniform(999_999_999_999)
bench "interpolation" do
@num
|> NumToWordsString.say
end
@jeffweiss
jeffweiss / Topics
Last active August 29, 2015 14:05
Elixir Demo
1. Clustering
a. Interaction w/ running code without having code
b. Remote process spawning
c. std in/out redirect
2. Supervision Trees
3. Live Code Update