Skip to content

Instantly share code, notes, and snippets.

View amxn's full-sized avatar

Mohammed Ameen amxn

View GitHub Profile
@amxn
amxn / 0_reuse_code.js
Created March 13, 2017 19:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@amxn
amxn / visual_studio_code_from_cli.sh
Last active November 19, 2015 03:26
Run Visual Studio Code from Zsh on Mac OSX
# Currently, there isn't an automatic method for doing this,
# but with a little code in your `.zshrc` file, you can configure it.
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
@amxn
amxn / active_admin_generate_csv_collection_action.rb
Created February 28, 2014 16:39
Generate a CSV from a collection action.
collection_action :download_report, method: :get do
users = User.where('created_at >= ?', Date.today - 1.month)
csv = CSV.generate( encoding: 'Windows-1251' ) do |csv|
# add headers
csv << [ #Some header ]
# add data
users.each do |user|
csv << [ user.created_at ]
end
end
@amxn
amxn / Helper
Created October 11, 2013 14:52 — forked from ciscodesign/Helper
def icon(name, size=1)
#icon("camera-retro")
#<i class="icon-camera-retro"></i>
html = "<i class='icon-#{name}' "
html += "style='font-size:#{size}em' "
html += "></i>"
html.html_safe
end
@amxn
amxn / index.md
Created October 8, 2013 05:56 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@amxn
amxn / dabblet.css
Created April 28, 2013 06:38
Circular Tooltip (SO)
/**
* Circular Tooltip (SO)
* http://stackoverflow.com/q/13132864/1397351
*/
* { margin: 0; padding: 0; }
body {
overflow: hidden;
background: url(http://theearlcarlson.com/experiments/amTooltip/img/bg.jpg);
}
/* generic styles for button & circular menu */
@amxn
amxn / dabblet.css
Created April 28, 2013 06:33
Circular Tooltip (SO)
/**
* Circular Tooltip (SO)
* http://stackoverflow.com/q/13132864/1397351
*/
* { margin: 0; padding: 0; }
body {
overflow: hidden;
background: url(http://theearlcarlson.com/experiments/amTooltip/img/bg.jpg);
}
/* generic styles for button & circular menu */
@amxn
amxn / reddit_saved_stories.py
Created November 28, 2011 06:18 — forked from mduvall/reddit_saved_stories.py
just grab all your saved stories on reddit with python wrapper lib
import reddit, getpass
if __name__ == "__main__":
r = reddit.Reddit(user_agent="test")
user_name = raw_input("User name: ")
password = getpass.getpass("Password: ")
r.login(user=user_name,password=password)
saved_links = r.get_saved_links()
for link in saved_links:
print "Title: " + link.title