Skip to content

Instantly share code, notes, and snippets.

View HashNuke's full-sized avatar
💭
Life happened. I now have varied interests. I may be slow to respond.

Akash Manohar HashNuke

💭
Life happened. I now have varied interests. I may be slow to respond.
View GitHub Profile
defmodule Tryout do
def hello(name \\ "akash")
def hello(name) do
IO.puts name
end
end
Tryout.hello #=> akash
Tryout.hello("nuke") #=> nuke
@HashNuke
HashNuke / fantastic_rotors.ex
Created October 4, 2014 04:53
INCOMPLETE - WORK IN PROGRESS. Supposed to be used as Fantastic.Rotors.start(options)
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"}
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") }
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
paths = ["lib/appname/**"]
Rotor.add_group :elixir_reload, paths, fn(files)->
Enum.each files, fn(file)->
Code.load_file(file.path)
end
end
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:background">@color/app_bg</item>
<item name="android:actionBarStyle">@style/AppActionBar</item>
</style>
== Compilation error on file lib/phoenix/examples/router.ex ==
could not compile dependency phoenix, mix compile failed. You can recompile this dependency with `mix deps.compile phoenix` or update it with `mix deps.update phoenix`
** (CompileError) deps/phoenix/lib/phoenix/examples/router.ex:1: def users_comments_path/1 has default values and multiple clauses, use a separate clause for declaring defaults
(elixir) src/elixir_def.erl:286: :elixir_def.store_each/8
(elixir) src/elixir_def.erl:101: :elixir_def.store_definition/9
(stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:121: :erl_eval.exprs/5
/tmp/build_af8985d4-6c77-4ac3-a850-adbd1bd91562/deps/phoenix/lib/phoenix/examples/router.ex:1: Phoenix.Router.Mapper.__before_compile__/1
@HashNuke
HashNuke / riak.conf
Created April 15, 2014 02:55
riak disable javascript VMs.
# along with other config options
javascript.map_pool_size
javascript.reduce_pool_size
javascript.hook_pool_size
@HashNuke
HashNuke / riak-advanced-config-start.txt
Last active December 29, 2015 21:08
Riak doesn't start when I add an etc/advanced.config. When there's none, it starts fine.
# I'm using Riak v2.0pre7 (latest tagged release from the github repo)
$ cat etc/advanced.config
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
[
{riak_kv, [
{add_paths, ["/Users/akashmanohar/projects/rinket/_build/shared/lib/firebrick/ebin"]}
]}
]