Skip to content

Instantly share code, notes, and snippets.

View jordanhudgens's full-sized avatar

Jordan Hudgens jordanhudgens

View GitHub Profile
# Add config.assets.precompile += Ckeditor.assets to application.rb
# Add gem 'turbo-sprockets-rails3' to my Gemfile under :assets group.
# Removed unused Gems from Gemfile.
# Bundle Install
# Remove the following lines from active_admin.js.coffee:
//= require active_admin/base
//= require ckeditor/override
//= require ckeditor/init
class DomainConfig
def initialize(config)
@config = config
end
def hosta
return @config["host"][Rails.env] || 'example1.dev'
end
100.times do |i|
User.create!(username: "username#{i}", email: "user#{i}@hudgens.com", password: "secret123", password_confirmation: "secret123")
end
10.times do |j|
Friendship.create!(user_id: User.first.id, friend_id: User.find(j + 1).id, authorized: true)
end
programming_category = Category.create!(title: "Programming")
sports_category = Category.create!(title: "Sports")
# Run this command to create a database backup
$ heroku pgbackups:capture
# Run this to download the database dump locally
$ curl -o latest.dump `heroku pgbackups:url`
# Run this to restore the db contents locally (substituting myuser/mydb to match the database.yml file contents)
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
getParameterByName = (name) ->
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
regex = new RegExp('[\\?&]' + name + '=([^&#]*)')
results = regex.exec(location.search)
if results == null then '' else decodeURIComponent(results[1].replace(/\+/g, ' '))
# ---
# generated by js2coffee 2.0.3
autoSaveBookChapter = ->
def self.fetch_studio_schedule(*opts)
options = opts.extract_options!
start_date = options[:start_date] || Date.today
end_date = options[:end_date] || Date.today + 2.weeks
message = {
StartDateTime: start_date,
EndDateTime: end_date,
HideCanceledClasses: false
}
@jordanhudgens
jordanhudgens / sample
Created May 16, 2015 01:32
Sample AJAX call
sampleExerciseSave = ->
$.ajax
type: 'POST'
url: '/scores/new'
data: $('.edit_book_chapter').serialize()
dataType: 'script'
success: (data) ->
return
@jordanhudgens
jordanhudgens / sample.html.erb
Created May 21, 2015 19:38
Sample GA + FB Commerce
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"88ed96912f","applicationID":"4229176","transactionName":"ewsMREVbW19dRkpaQFwBEEMYQF9SVl8W","queueTime":0,"applicationTime":685,"agent":"js-agent.newrelic.com/nr-632.min.js"}</script>
<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o?o:n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({QJf3ax:[function(e,n){function t(e){function n(n,t,a){e&&e(n,t,a),a||(a={});for(var u=c(n),f=u.length,s=i(a,o,r),p=0;f>p;p++)u[p].apply(s,t);return s}function a(e,n){f[e]=c(e).concat(n)}function c(e){return f[e]||[]}function u(){return t(n)}var f={};return{on:a,emit:n,create:u,listeners:c,_events:f}}function r(){return{}}var o="nr@
@jordanhudgens
jordanhudgens / ga
Created May 21, 2015 19:41
gadetails
Track Pageview
ga_debug.js:24 Found UA client id
analytics_debug.js:9 Initializing Google Analytics.
analytics_debug.js:9 Running command: ga("create", "UA-55113418-1", "auto")
analytics_debug.js:9 Creating new tracker: t0
analytics_debug.js:9 Auto cookieDomain found: "none"
analytics_debug.js:9 Running command: ga("send", "pageview")
analytics_debug.js:9
Sent beacon:
v=1&_v=j36d&a=2106000679&t=pageview&_s=1&dl=http%3A%2F%2Flocalhost%2Forders%2Fthanks.1957&ul=en-us&de=UTF-8&dt=quip&sd=24-bit&sr=2560x1080&vp=1265x467&je=1&fl=17.0%20r0&_u=AACAAEABI~&jid=&cid=1620357248.1427595649&tid=UA-55113418-1&z=1145217400
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol ) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker('UA-55113418-1');
pageTracker._trackPageview();
var order = <%= raw @order.to_json %>;