Skip to content

Instantly share code, notes, and snippets.

{
"birth_name": "Lynn Braun",
"nickname": "LB",
"first_name": "Lynn",
"last_name": "Braun",
"grade": "9th Grade",
"school_name": "JFK High School",
"about_me": "I'm a cool sophomore that's in to Poggs.",
"name": "LB Braun",
"avatar_url": "https://zeumo-staging-2.s3.amazonaws.com/uploads/student/avatar/32/polaroid_avatar.jpg?1374245357",
@ascot21
ascot21 / api_controller.rb
Created July 25, 2013 14:57
Return 404 if record not found
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
def record_not_found(exception)
render :json => {:errors => [exception.message]}, :status => 404
end
@ascot21
ascot21 / gist:6107455
Created July 29, 2013 20:21
Use the correct cordova.js file for each platform
<script type="text/javascript">
// <![CDATA[
if (navigator.userAgent.toLowerCase().match(/android/)) {
document.write('<script charset="utf-8" src="cordova-android.js"><\/script>');
}
else {
document.write('<script charset="utf-8" src="cordova-ios.js"><\/script>');
}
// ]]></script>
{
"broadcast": {
"interest_id": 43,
"headline": "Why is there so much drama in the LBC?",
"body": "Tupac",
"response_options_attributes": {
"0": {
"text": "Fjjb"
},
"1": {
{
"broadcast": {
"interest_id": 38,
"headline": "How about this",
"body": "Image?",
"response_options_attributes": {
"0": {
"text": ""
},
"1": {
@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
render: ->
@$el.html @template(@model.attributes)
@setupScrolling()
@$el
$ ->
$(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
@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

@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'