Skip to content

Instantly share code, notes, and snippets.

@ascot21
ascot21 / timezone_names.txt
Created November 4, 2019 17:25
List of current Timezones in Rails with their alias
["American Samoa", "Pacific - Pago Pago"],
["International Date Line West", "Pacific - Midway"],
["Midway Island", "Pacific - Midway"],
["Hawaii", "Pacific - Honolulu"],
["Alaska", "America - Juneau"],
["Pacific Time (US & Canada)", "America - Los Angeles"],
["Tijuana", "America - Tijuana"],
["Arizona", "America - Phoenix"],
["Chihuahua", "America - Chihuahua"],
["Mazatlan", "America - Mazatlan"],
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@ascot21
ascot21 / gist:11234106
Created April 23, 2014 22:06
Merge hashes while adding values of identical keys
a = [{'a' => 30, 'b' => 14}, {'a' => 4, 'b' => 23, 'c' => 7}, {'a' => 6, 'b' => 20, 'c' => 5}]
puts a.inject{|tot, new| tot.merge(new){|k,val_from_a,val_from_b|val_from_a+val_from_b}}
=> {"a"=>40, "b"=>57, "c"=>12}
@ascot21
ascot21 / active_admin.js
Created January 6, 2014 03:44
Inline Editing in ActiveAdmin with Best In Place Gem
//= require jquery
//= require best_in_place
//= require jquery.purr
//= require active_admin/base
$(document).ready(function() {
$(".best_in_place").best_in_place()
$('.best_in_place').bind("ajax:success", function () {$(this).closest('tr').effect('highlight'); });
$(document).on('best_in_place:error', function(event, request, error) {
@ascot21
ascot21 / gist:8261528
Created January 4, 2014 22:23
Export Local DB & Importing to Heroku

First, create a dump of local DB:

pg_dump -Fc --no-acl --no-owner -h localhost -U USER_NAME DATABASE_NAME > mydb.dump

Upload the mydb.dump file to a web server (ie. Dropbox, S3, etc...)

Import to Heroku

heroku pgbackups:restore DATABASE 'PATH_TO_HOSTED_DB_DUMP_FILE'

@ascot21
ascot21 / gist:8149029
Last active January 1, 2016 13:09
list most used Linux commands

Bash history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

Oh-My-ZSH zsh_stats

$ ->
$(window).scroll ->
if $(window).width() > 640
$widget = $(".sidebar-widget")
$position = $widget.offset().top
$breakPosition = $('.author-bio').offset().top
if ($(window).scrollTop() > $('.post-header').height()) && ($position < $breakPosition)
$widget.stop().animate marginTop: $(window).scrollTop() - $('header').height() - 155
else
render: ->
@$el.html @template(@model.attributes)
@setupScrolling()
@$el
@ascot21
ascot21 / gist:6158947
Created August 5, 2013 19:49
Setting up GenyMotion

Overview

Genymotion is a very fast Android emulator (much faster than the one that ships with the Android SDK).

Dependencies

Virtualbox

Installation

  1. Sign up for an account
  2. Download and install GenyMotion (make sure you move Genymotion and Genymotion shell to application directory
  3. Launch GenyMotion
{
"broadcast": {
"interest_id": 38,
"headline": "How about this",
"body": "Image?",
"response_options_attributes": {
"0": {
"text": ""
},
"1": {