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
#!/bin/sh | |
#Script to generate a skeletal HTML AIR application | |
#Copyright (C) 2010 Akash Manohar J (akashxav.com) | |
# | |
#Instructions: | |
#add <air_sdk>/bin to path (skip this if you did when you installed AIR SDK) | |
#save file as newairapp in the <air_sdk>/bin | |
#chmod+x <air_sdk>/bin/newairapp | |
#usage: newairapp <app_name> | |
#example: newairapp HelloAir |
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 Mix.Tasks.Phoenix.Release do | |
use Mix.Task | |
@shortdoc "Creates a release using exrm" | |
def run(args) do | |
Application.put_env(:phoenix, :serve_endpoints, true, persistent: true) | |
Mix.Task.run "release", args | |
end | |
end |
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
machine: | |
environment: | |
PATH: "$HOME/.asdf/bin:$HOME/.asdf/shims:$PATH" | |
services: | |
- redis | |
dependencies: | |
cache_directories: | |
- ~/.asdf | |
pre: | |
- if ! asdf | grep version; then git clone https://github.com/HashNuke/asdf.git ~/.asdf; fi |
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 Tryout do | |
def hello(name \\ "akash") | |
def hello(name) do | |
IO.puts name | |
end | |
end | |
Tryout.hello #=> akash | |
Tryout.hello("nuke") #=> nuke |
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 Fantastic.Rotors do | |
import Rotor.BasicRotors | |
import CoffeeRotor | |
import SassRotor | |
# NOT TESTED won't work | |
# TODO digested output has to be stored in the application env, as a map, so that it's accessible in the templates. | |
# so the hash would contain %{"file name" => "digest"} | |
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
Rotor.watch :all_files_in_project_root, ["*"], fn(changed, all)-> | |
IO.inspect "CHANGED FILES" | |
IO.inspect changed | |
IO.inspect "ALL FILES" | |
IO.inspect all | |
end | |
# Options can be passed as a 4th arg after the rotor function. | |
# Currently available option is `interval`. | |
# Default polling interval is 2500 (2.5 seconds). |
A sorting algorithm for sorting by "hotness", roughly based on Reddit's algorithm with a few tweeks.
scope :order_by_hot, ->
{ order("round((votes_count - 1) / POW(DATE_PART('day', Now() - created_at) * 24 + DATE_PART('hour', Now() - created_at) + 2, 1.5)::numeric, 8) DESC, votes_count DESC") }
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
class Story < ActiveRecord::Base | |
# make likes count whatever basic score you want. it would be the sum of up plus down votes, or use whatever cache counters you have and weight them accordingly. | |
#the magic time should just be a unix time right before people started making stuff, for us, its just 6 months before we started makr.io | |
def self.ranked | |
order("(ln( 1 + posts.likes_count) + (EXTRACT(EPOCH FROM created_at) - 1327654606)/9000) desc") | |
end | |
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
paths = ["lib/appname/**"] | |
Rotor.add_group :elixir_reload, paths, fn(files)-> | |
Enum.each files, fn(file)-> | |
Code.load_file(file.path) | |
end | |
end |