Skip to content

Instantly share code, notes, and snippets.

View oivoodoo's full-sized avatar
🏠
Working from home

Alex oivoodoo

🏠
Working from home
View GitHub Profile
@ibussieres
ibussieres / upgrade_pg.sh
Last active May 26, 2021 04:29
Upgrade PostgreSQL 9.1 to 9.3 on Ubuntu 12.04
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
@jlecour
jlecour / post_to_slack.rb
Last active May 22, 2022 17:43
How to post alerts from Monit to Slack
# encoding: UTF-8
require 'optparse'
require 'net/http'
require 'json'
def parse_options(argv)
opts = {}
@parser = OptionParser.new do |o|
@Zmetser
Zmetser / youtubeID.js
Last active August 29, 2015 13:56 — forked from takien/youtubeID.js
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
@thbar
thbar / go_build.rb
Last active March 4, 2017 02:09
Integration testing of a golang app with rspec and capybara-webkit.
module GoBuild
extend self
def build(file)
process = ChildProcess.build('go', 'build', file)
err = Tempfile.new('stderr-spec')
process.io.stderr = err
process.start
process.poll_for_exit(10)
err.rewind
@aras-p
aras-p / preprocessor_fun.h
Last active May 18, 2024 08:55
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@igrigorik
igrigorik / index.html
Created June 8, 2013 22:36
XHR streaming example
<p>Hello
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', '/stream');
xhr.seenBytes = 0;
xhr.onreadystatechange = function() {
console.log("state change.. state: "+ xhr.readyState);
<!DOCTYPE html>
<html>
<body>
<h3>Hello SSE!</h3>
<script>
var source = new EventSource('/events');
// new connection opened callback
source.addEventListener('open', function(e) {
console.log('connection opened');
@jdeoliveira
jdeoliveira / gist:4080656
Created November 15, 2012 19:28
Dump/restore a postgres database in binary format for distribution
/Library/PostgreSQL/9.1/bin/pg_dump --host localhost --port 5432 --username <USERNAME> -b -c -E UTF-8 --no-owner --no-privileges --no-tablespaces --clean --schema public -F c -Z 9 -f <BACKUPFILENAME> <DATABASENAME>
/Library/PostgreSQL/9.1/bin/pg_restore --host localhost --port 5432 --username <USERNAME> --dbname <DATABASENAME> --no-owner --no-privileges --no-tablespaces --clean --schema public "<BACKUPFILENAME>"
@wycats
wycats / iterators.js
Created October 13, 2012 09:33
Iterators in ES6 are, surprisingly, quite similar to the Ruby enumeration protocol
import { iterator, isStopIteration } from "@iter";
class Node {
constructor(item) {
this.item = item;
}
*@iterator() {
let node = this;
while (node && node.item) {
@hzlzh
hzlzh / feedback-button.html
Created August 8, 2012 16:16
CSS3 Feedback Button
<div class="feedback-btn">
<a class="en-us" title="Feedback" target="_blank" href="#">Feedback</a>
<br />
<br />
<a class="zh-cn" title="用户反馈" target="_blank" href="#"> 用 户 反 馈 </a>
</div>​