This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Example.Server do | |
use GenServer | |
defmodule Data do | |
defstruct client: Example.Client | |
end | |
def init(%{client: client}), do: {:ok, %Data{client: client}, 500} | |
def init(_), do: {:ok, %Data{}, 500} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am jerel on github. | |
* I am jerel (https://keybase.io/jerel) on keybase. | |
* I have a public key ASCJUGUw8Ek_glkidrXcFXY-GmF5awcOn7IwVuDINk34sAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from StringIO import StringIO | |
from django.http import StreamingHttpResponse | |
class StreamCSV(object): | |
def __init__(self): | |
self._buffer = StringIO() | |
self._writer = csv.writer(self._buffer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule :release_tasks do | |
def seed do | |
:ok = Application.load(:myapp) | |
[:postgrex, :ecto, :logger] | |
|> Enum.each(&Application.ensure_all_started/1) | |
Myapp.Repo.start_link | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule User do | |
def all do | |
from(u in UserSchema, where: is_nil(u.deleted_at)) |> Repo.all | |
end | |
def delete(user_id) do | |
user = Repo.get!(UserSchema, user_id) | |
changeset = Ecto.Changeset.change(user, deleted_at: Ecto.DateTime.utc) | |
Repo.update(changeset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
work() { | |
while true; do | |
sleep 1800 #30 min | |
espeak "$1 pushups" | |
xinput set-prop 14 'Device Enabled' 0 #disable keyboard | |
xinput set-prop 16 'Device Enabled' 0 #disable mouse | |
xset dpms force off #disable monitors | |
sleep 15 | |
xinput set-prop 14 'Device Enabled' 1 | |
xinput set-prop 16 'Device Enabled' 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# implicit return is fairly obvious but foreign to most languages | |
def foo(arg) do | |
arg | |
end | |
# foo/2 is the notation for a function that takes two arguments | |
# optional parenthesis | |
def foo arg, arg2 do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
watchman watch-list | tr -d '[:space:]' | grep -Po '(?<="roots":\[).*?(?=\])' | grep -Po '(?<=").*?(?="?,)' | while read path; do watchman watch-del "$path"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Method 1 | |
// add the twitter widget library to the bottom of app/index.html (after your Ember app) | |
<script src="//platform.twitter.com/widgets.js" charset="utf-8"></script> | |
// initialize it after the content is in the DOM | |
import Ember from 'ember'; | |
export default Ember.View.extend({ | |
didInsertElement: function() { | |
window.twttr.widgets.load(); |
NewerOlder