Skip to content

Instantly share code, notes, and snippets.

require 'active_record/connection_adapters/abstract/schema_definitions'
class ActiveRecord::ConnectionAdapters::TableDefinition
def publishing(*args)
options = args.extract_options!
column(:publish_up, :datetime, options)
column(:publish_down, :datetime, options)
end
end
@ivawzh
ivawzh / connect-heroku-app-to-postgres-rds-with-ssl.md
Created December 18, 2018 10:13 — forked from glarrain/connect-heroku-app-to-postgres-rds-with-ssl.md
How to connect a Heroku application to an Amazon RDS PostgreSQL instance, forcing SSL and certificate chain verification

1 - Download the RDS certificates (root plus region-specific intermediate ones) bundle:

wget -O config/rds-combined-ca-bundle.pem https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem

2 - Add config/rds-combined-ca-bundle.pem to the repository and redeploy to Heroku.

3 - Update the DATABASE_URL env var:

@ivawzh
ivawzh / .log
Created October 4, 2018 14:54
Javascript singleton in ES6
TCL: -------------------------------------
TCL: main -> db1 === db2 true
TCL: main -> db1 === db3 true
TCL: -------------------------------------
@ivawzh
ivawzh / new-recomposed-component.js
Last active April 13, 2018 12:33
React Class Component VS Recomposed Component
import React from 'react'
import { withStyles } from 'material-ui/styles'
import AppBar from 'material-ui/AppBar'
import Toolbar from 'material-ui/Toolbar'
import Typography from 'material-ui/Typography'
import IconButton from 'material-ui/IconButton'
import Hidden from 'material-ui/Hidden'
import Button from 'material-ui/Button';
import MenuIcon from 'material-ui-icons/Menu'
import Menu, { MenuItem } from 'material-ui/Menu'
@ivawzh
ivawzh / render-promise-in-react.js
Created April 10, 2018 11:03 — forked from hex13/render-promise-in-react.js
how to render promises in React
//License CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0/
class Deferred extends React.Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
}
componentDidMount() {
# frozen_string_literal: true
require 'config'
require 'rest-client'
require 'retriable'
require 'contract_repository'
require 'group_contracts_by_agency'
require 'tzinfo'
require 'monitoring'
require 'pp'
@ivawzh
ivawzh / .\.vscode\launch.json
Last active December 8, 2018 13:27
Visual Studio Code settings
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "WebsiteService: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
@ivawzh
ivawzh / clean_docker.bash
Last active November 18, 2017 03:09
remove all docker images and containers
# remove all docker images and containers
clean_docker () {
docker rm -f $(docker ps -aq)
docker rmi $(docker images | grep '^<none>' | awk '{print $3}')
}
@ivawzh
ivawzh / bash.sh
Created October 24, 2017 00:26
clean docker images and containers
clean_docker () {
docker rm -f $(docker ps -aq)
docker rmi $(docker images | grep '^<none>' | awk '{print $3}')
}
@ivawzh
ivawzh / login.js
Last active April 18, 2017 02:06
Redux Login Action snippet
// @ redux/actions/login.js
export function loginStart(username, pw): Promise<void> {
return async (dispatch) => {
dispatch({ type: 'LOGIN_START' })
try {
const userData = await login(username, pw)
dispatch(loginSuccess(userData))
} catch (error) {
dispatch(loginFailure(error))
}