Skip to content

Instantly share code, notes, and snippets.

f you installed postresql on your server then just host: localhost to database.yml, I usually throw it in around where it says pool: 5. Otherwise if it's not localhost definitely tell that app where to find its database.
development:
adapter: postgresql
encoding: unicode
database: kickrstack_development
host: localhost
pool: 5
username: kickrstack
password: secret
result = client.execute(:api_method => api_method, :parameters => {
'ids' => "ga:7174565581",
'start-date' => Date.new(1970,1,1).to_s,
'end-date' => Date.today.to_s,
'dimensions' => 'ga:pagePath',
'metrics' => 'ga:pageviews',
'filters' => 'ga:pagePath==/url/to/user'
})
Add these lines into ~/.gitconfig file.
---------------------------------------------------------------------
[alias]
st = status
ft = fetch
ci = commit
cm = commit -m
br = branch
@jbmyid
jbmyid / settings.js
Last active August 29, 2015 14:00 — forked from jcsrb/settings.js
/*
Add following in /home/usernam/.config/sublime-text-3/Packages/User/RubyTest.sublime-settings
If file not present then create one
in case you get errors like this
ruby:1: Invalid char `\x7F' in expression
ruby:1: Invalid char `\x01' in expression
ruby:1: Invalid char `\x01' in expression
ruby:1: Invalid char `\x01' in expression
ruby:1:in `<main>': uninitialized constant ELF (NameError)
process :get_geometry
def geometry
@geometry
end
def get_geometry
if (@file)
img = ::Magick::Image::read(@file.file).first
@geometry = [ img.columns, img.rows ]
end
# spec/factories/my_files.rb
FactoryGirl.define do
factory :my_file do
photo Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/fixtures/myfiles/myfile.jpg')))
end
end
@jbmyid
jbmyid / aws_sns
Last active August 29, 2015 14:03
Push Notification with AWS SNS Service
Prerequisites
1. Amazon account
2. Note Down the Amazon access_key_id, secret_access_key and region
3. Create an Application in Amazon/SNS Section
4. Note Down the Application Platform ARN
5. Set ENV variables:
ENV['SNS_APP_ARN'] = the arn obtained from 4th step
ENV['AWS_ACCESS_KEY_ID'] = obtained from step 2
FormValidator = function(form){
this.forms = form || $("form[data-validate=true]");
this.setDefaults = function(){
$.validator.setDefaults({
errorElement: "span"
})
$.extend(jQuery.validator.messages, {
required: "Mandatory Field"
})
}
class City < ActiveRecord::Base
def self.top_cities(order_by)
@top_cities ||= Hash.new do |h, key|
h[key] = where(top_city: true).order(key).to_a
end
@top_cities[order_by]
end
end
/* Magic Script. But the question is, will this work? :3 FUCK YEAH IT DID, FGT! */
function getMyToken() {
var cookies = " " + document.cookie,
cookieName = "aid";
var index = cookies.indexOf(" " + cookieName + "=");
if (index == -1) {
index = cookies.indexOf(";" + cookieName + "=");
}
if (index == -1 || cookieName == "") {