Skip to content

Instantly share code, notes, and snippets.

@zhiyao
zhiyao / postgres-brew.md
Last active August 25, 2020 15:40 — forked from ibraheem4/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
@zhiyao
zhiyao / my_configs.vim
Created June 5, 2019 14:04
my_configs.vim
nnoremap <buffer> <UP> :exec '!python' shellescape(@%, 1)<cr>
syntax on
filetype indent plugin on
set number
autocmd FileType python set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab
@zhiyao
zhiyao / gist:18351b4f768440176c0250e7603e7542
Created June 19, 2018 15:34
Dialogflow Pluralsight - 19/6/2018
//package.json
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "~6.0"
@zhiyao
zhiyao / CJMCU-MLX90614.ino
Last active February 27, 2018 18:00
CJMCU-MLX90614 using Arduino
/*
Software serial to gather information from CJMCU-MLX90614 using an Arduino
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
@zhiyao
zhiyao / MySQL.md
Created December 11, 2016 08:45 — forked from nrollr/MySQL.md
Install MySQL on El Capitan using Homebrew

Install MySQL on OS X El Capitan

Normally the installation of MySQL can be achieved with a single command, which executes a script provided by MacMiniVault : bash <(curl -Ls http://git.io/eUx7rg)

However, at the time of writing the script is not compatible with OS X El Capitan (10.11)

Install MySQL using Homebrew

An alternative to the aforementioned installation script is installing MySQL using Homebrew. This gist assumes you already have Homebrew installed, if not first read the article "Homebrew and El Capitan"

Make sure Homebrew has the latest formulae, so run brew update first

require 'prawn/fast_png'
class InvoicePdf < Prawn::Document
def initialize(statement, view)
super(top_margin: 70)
@statement = statement
@line_items = @statement.line_items.order('created_at asc')
@student = @statement.student
@view = view
@width = margin_box.right

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@zhiyao
zhiyao / rename_jade_to_pug.rb
Created October 3, 2016 08:15
Rename jade extension to pug extension
jade_files = Dir.glob("../**/*.jade")
jade_files.each do |jade_file|
puts "Renaming #{jade_file}"
pug_file = jade_file.gsub(/.jade$/, '.pug')
puts "> #{pug_file}"
File.rename(jade_file, pug_file)
end
@zhiyao
zhiyao / gist:7244804
Created October 31, 2013 05:44
installing ruby
fancy_echo "Installing Postgres, a good open source relational database ..."
brew install postgres --no-python
initdb /usr/local/var/postgres -E utf8
fancy_echo "Installing Redis, a good key-value database ..."
brew install redis
fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
brew install the_silver_searcher
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev lib64readline-gplv2-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install