Skip to content

Instantly share code, notes, and snippets.

View abelorian's full-sized avatar
🎯
Focusing

Abel O'Rian abelorian

🎯
Focusing
View GitHub Profile
@remino
remino / compression.rb
Created September 3, 2014 03:58
Ruby on Rails: Minify HTML, CSS, & JS, and compress with gzip https://remino.net/rails-html-css-js-gzip-compression/
# config/initializers/compression.rb
Rails.application.configure do
# Use environment names or environment variables:
# break unless Rails.env.production?
break unless ENV['ENABLE_COMPRESSION'] == '1'
# Strip all comments from JavaScript files, even copyright notices.
# By doing so, you are legally required to acknowledge
# the use of the software somewhere in your Web site or app:
@julianeon
julianeon / http-escalation-put.rb
Created May 28, 2014 00:34
PUT example using HTTParty.
require 'httparty'
subdomain='FAKE'
api_token='FAKE'
id='FAKE'
endpoint="https://#{subdomain}.pagerduty.com/api/v1/escalation_policies/#{id}"
token_string="Token token=#{api_token}"
data= {
name: "New name"
@tadast
tadast / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@pyk
pyk / active-record-migration-expert.md
Last active August 2, 2021 09:20
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb

Applications of Cognitive Theory in Data Modeling and Software Design

Written as both a refresher course on the mechanics of cognition in human psychology, and as the beginning of a working theory, wherein one might make some deductions from human psychology to broadly advance/improve the design of server software and data models for the industry en masse.

c. Mike McNeil, 2013-2014 All Rights Reserved.

What's the point of this? I think psychology will inevetiably instruct the future of software design, in the same way neurobiology is beginning to impact the hardware engineering industry. >

@mikermcneil
mikermcneil / sails_heroku_postgres.md
Last active February 19, 2016 07:23
How to configure a Sails.js app with a remote Postgres database hosted on Heroku

Using a PostgreSQL database on Heroku with Sails.js

The trick to setting up a Sails.js app with a remote Postgres database hosted on Heroku is all about SSL. Here's how you do it:

In your adapters.js file

Note: This is for Sails v0.9.x, the stable release at the time of this writing.

In Sails v0.10.x, the config/adapters.js file has been replaced with config/connections.js

@kerimdzhanov
kerimdzhanov / random.js
Last active April 20, 2024 03:21
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@natew
natew / deploy.rb
Last active March 16, 2022 06:35
Puma + Nginx + Capistrano
require 'bundler/capistrano'
require 'capistrano_colors'
load 'deploy/assets'
# ssh forwarding and shell
set :default_run_options, { :pty => true }
set :ssh_options, { :forward_agent => true }
set :scm_verbose, true
set :scm, :git
@codespore
codespore / CORS with Rails Devise
Created August 31, 2012 23:49
Sench Touch with Rails
References:
http://blog.carbonfive.com/2012/02/27/supporting-cross-domain-ajax-in-rails-using-jsonp-and-cors/
https://github.com/cyu/rack-cors
http://nelm.io/blog/2011/11/cors-with-sencha-touch/
http://jessehowarth.com/2011/04/27/ajax-login-with-devise
=============================================================================================================
GEMFILE
=============================================================================================================
gem 'rack-cors', :require => 'rack/cors'
@rwz
rwz / gist:3281979
Created August 7, 2012 05:35
Rendering Jbuilder templates from within model
# this is the easiest way to use partials from model I could find so far
class Entry < AR::Base
def as_json
context = ApplicationController.new.view_context
context.render('/api/entries/entry.json', entry: self)
end
end