Skip to content

Instantly share code, notes, and snippets.

View davidstump's full-sized avatar

David Stump davidstump

View GitHub Profile
@davidstump
davidstump / curl-websocket.sh
Created March 17, 2020 05:06 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@davidstump
davidstump / gist:52a0ad6e4943efef6bf8
Last active February 1, 2018 04:59
Send email from your Phoenix app in under 10 minutes

How to Send Email From Your Phoenix App in Under 5 Minutes

Phoenix Framework Logo

Sending scheduled or automated emails from your application is a very common problem with a number of solutions. In this write-up I am going to demonstrate one particularly easy approach to adding email functionality to your Phoenix App. Phoenix is a web framework written in Elixir that is enjoying a meteoric rise in popularity recently. Many people are jumping onto the Phoenix bandwagon for its explicit, non-magical and functional approach to development.

For this demonstration, I am going to use an external library that integrates Mailgun into my Phoenix application. Phoenix includes the Elixir configuration file mix.exs which we will use to add our new dependency. We will add {:mailgun, "~> 0.1.1"} to the list of "deps" our project is currently us

@davidstump
davidstump / gist:fc8544865837f6aa99af
Last active August 29, 2015 14:18
NGService Example
class Thing extends @NGService
@$inject: []
edit: (id) ->
@notify "thing:edit", id
reload: ->
@notify "thing:reload"
@davidstump
davidstump / gist:71eb005a354c204a4814
Last active August 29, 2015 14:07
Disable Angular URL Manipulation
@App.config [
# disable angular url manipulation
$provide.decorator "$browser", ["$delegate", ($delegate) ->
$delegate.onUrlChange = -> angular.noop()
$delegate.url = -> ""
$delegate
]
]
@davidstump
davidstump / gist:d0b9f87f6a132c2991fb
Created September 16, 2014 15:02
Delayed keyup directive
@App.directive "onDelayedKeyup", ['$timeout', ($timeout) ->
(scope, element, attrs) ->
timer = false
element.bind "keyup", ->
$timeout.cancel(timer) if timer
timer = $timeout ->
scope.$apply attrs.onKeyup
, 500
]
// Elixir
case {1, 2, 3} do
{4, 5, 6} ->
"This clause won't match"
{1, x, 3} ->
"This clause will match and bind x to 2 in this clause"
_ ->
"This clause would match any value"
end
@davidstump
davidstump / gist:11058674
Last active August 29, 2015 14:00
rake console
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -I lib -r YOUR_GEM_NAME.rb"
end
@davidstump
davidstump / touch.coffee
Created May 1, 2013 23:42
Simple class to handle touch events and emit them to your application. Utilizes EventEmitter.
@Touch=
horizontal_sensitivity: 22
vertical_sensitivity: 6
touchDX: 0
touchDY: 0
touchStartX: 0
touchStartY: 0
bind: (elements...) ->