Skip to content

Instantly share code, notes, and snippets.

View sserrato's full-sized avatar

P. Sergio Serrato sserrato

View GitHub Profile
@mpvosseller
mpvosseller / create_heroku_app.rb
Last active January 2, 2023 19:34
Ruby function to create a new Heroku app with the Heroku Platform API
# Function to create a new Heroku app instance using the ruby Heroku Platform API
#
# Documentation:
# https://devcenter.heroku.com/articles/setting-up-apps-using-the-heroku-platform-api
# https://devcenter.heroku.com/articles/platform-api-reference#app-setup
# https://github.com/heroku/platform-api
# https://heroku.github.io/platform-api
#
# Add the gem 'platform-api'
require "platform-api"
@malkab
malkab / postgresql-copy_from_copy_to.md
Last active October 12, 2022 19:06
PostgreSQL - copy from / copy to

Copy To and Copy From

Copy is a command and a psql metacommand to import data into a PostgreSQL:

-- Tables
\copy test_data.test from sigwx.csv with delimiter '|' csv delimiter E'\t' header quote '"' encoding 'utf-8' null '-'

\copy test_data.test to sigwx.csv with delimiter '|' csv header quote '"' encoding 'utf-8' null '-'
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@ibraheem4
ibraheem4 / postgres-brew.md
Last active March 20, 2024 11:33 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@jkubecki
jkubecki / ExportKindle.js
Last active February 25, 2024 00:45
Amazon Kindle Export
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
var db = openDatabase('K4W', '3', 'thedatabase', 1024 * 1024);
getAmazonCsv = function() {
// Set header for CSV export line - change this if you change the fields used
var csvData = "ASIN,Title,Authors,PurchaseDate\n";
db.transaction(function(tx) {
@ktheory
ktheory / Readme.md
Last active January 20, 2024 15:41
Easily make HTTPS requests that return promises w/ nodejs

Javascript request yak shave

I wanted to easily make HTTP requests (both GET & POST) with a simple interface that returns promises.

The popular request & request-promises package are good, but I wanted to figure out how to do it w/out using external dependencies.

The key features are:

  • the ability to set a timeout
  • non-200 responses are considered errors that reject the promise.
  • any errors at the TCP socker/DNS level reject the promise.
@JessyGreben
JessyGreben / Binary Search Tree - Ruby
Last active September 25, 2020 11:14
Binary Search Tree - Ruby
class Node
attr_reader :value
attr_accessor :left, :right
def initialize(value=nil)
@value = value
left = nil;
right = nil;
end
end
@carlessanagustin
carlessanagustin / VAGRANT-Cheat-Sheet.md
Last active November 7, 2023 20:27
This is a VAGRANT cheat sheet

Vagrant Cheat Sheet

add image

local

$ vagrant box add {title} {url}
$ vagrant init {title}
$ vagrant up
@thanhcuong1990
thanhcuong1990 / posts_controller(2).rb
Last active January 11, 2016 19:07
Scope examples
# /app/controllers/posts_controller.rb
def index
@posts = Post.where(:user_id => current_user.id).
order('created_at desc').
limit(10)
@trending = Topic.where('started_trending > ?', 1.day.ago).
order('mentions desc').
limit(7)
# ...
@underhilllabs
underhilllabs / rails_assoc_select.md
Last active September 23, 2015 06:20
Rails association in select drop down

The Task Model

Task belongs_to User and Project

class Task < ActiveRecord::Base
  belongs_to :project
  belongs_to :user
  validates :title, presence: true, length: {minimum: 5}
end

Project has many tasks