Skip to content

Instantly share code, notes, and snippets.

View samnang's full-sized avatar
🚀

Samnang Chhun samnang

🚀
View GitHub Profile
# Compile source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@samnang
samnang / README-Template.md
Created November 13, 2017 16:41 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@samnang
samnang / .md
Last active February 17, 2017 21:21
Guard clause vs Control Structures in #Elixir?

1. Using guard

defmodule MyList do
  def max(list), do: _max(list, nil)

  defp _max([], max_value), do: max_value
  defp _max([head | tail], nil), do: _max(tail, head)

  # using guard
  defp _max([head | tail], max_value) when max_value < head, do: _max(tail, head)
@samnang
samnang / heroku-environments
Created August 11, 2016 19:48 — forked from csexton/heroku-environments
Heroku Environment CLI Wrapper
#!/usr/bin/env ruby
# Heroku enviroment helper script
#
# This is to streamline using differnt heroku enviroments from one repo.
# Symlink this file to an envroment name (as set by the git-remote name), then
# when running that symlink the script will look up the name in the git config
# and use that remote as the heroku name.
#
# Setup:
@samnang
samnang / env.rb
Last active August 5, 2016 14:40 — forked from netzpirat/env.rb
Cucumber ActiveResource faking with Webmock
require 'fakeweb'
require 'fake_resource'
ActiveResource::Base.send :include, ActiveResource::FakeResource
Before do
FakeWeb.allow_net_connect = false
end
After do |scenario|
ActiveResource::FakeResource.clean
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@samnang
samnang / gist:cb9515ffcf5b0ab03f8f
Created May 29, 2015 02:49
TOC of Github's README
function tocLink(heading, title, href) {
var ele = '<li class="tooltipped tooltipped-w" aria-label="'+title+'">'+
'<a href="'+href+'" aria-label="'+title+'"'+
'class="js-selected-navigation-item sunken-menu-item">'+
'<span class="full-word">'+title+'</span></a></li>'
return ele;
}
var header = "<li class='tooltipped tooltipped-w'><strong>&nbsp;Table of Contents</strong></li>"
var rows = [];
@samnang
samnang / clear_logs.rb
Created May 24, 2015 14:02
Clear logs
# config/initializers/clear_logs.rb
if Rails.env.development?
MAX_LOG_SIZE = 2.megabytes
logs = File.join(Rails.root, 'log', '*.log')
if Dir[logs].any? {|log| File.size?(log).to_i > MAX_LOG_SIZE }
$stdout.puts "Runing rake log:clear"
`rake log:clear`
end
end
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
$ boom -n 100 -c 30 -h Authorization:"Bearer xxxxxxxxx" http://api.waggram.net/v1/me/feed
100 / 100 Boooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! 100.00 %
Summary:
Total: 3.7877 secs.
Slowest: 2.0238 secs.
Fastest: 0.6192 secs.
Average: 1.0054 secs.
Requests/sec: 26.4014