Skip to content

Instantly share code, notes, and snippets.

View okiwan's full-sized avatar

Sergio Ocaña Gálvez okiwan

View GitHub Profile
@okiwan
okiwan / pglag.sh
Created November 13, 2013 07:50 — forked from dansimau/pglag.sh
#!/bin/bash
#
# Show replication lag for one or more postgresql slaves in streaming replication.
#
# dsimmons@squiz.co.uk
# 2012-01-09
#
psql="which psql"
psql_extra_opts=""
@okiwan
okiwan / gist:10961868
Created April 17, 2014 07:44
Open links in a background tab (tested on Chrome 34 only)
<html>
<head>
</head>
<body>
<ul id="links">
<li><a href="http://sega.co.jp/">SEGA</a></li>
<li><a href="http://www.yahoo.com/">Yahoo!</a></li>
</ul>
<a href="#" onclick="openAll();return false;">Click here</a>
@okiwan
okiwan / gist:10972411
Created April 17, 2014 10:35
JavaScript event delegation example
window.onload = function() {
if(document.body.addEventListener) {
document.body.addEventListener('mouseover', onMouseOverHandler, false);
document.body.addEventListener('mouseout', onMouseOutHandler, false);
} else {
document.body.attachEvent('onmouseover', onMouseOverHandler);
document.body.attachEvent('onmouseout', onMouseOutHandler);
}
function switchImage(e, o) {
@okiwan
okiwan / gist:11396781
Created April 29, 2014 10:54
Background color transparency on all browsers
/* Fallback */
background-color: rgb(0, 0, 0);
/* Modern browsers */
background-color: rgba(0, 0, 0, 0.6);
/* IE 6, 7 */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
/* IE 8 */
@okiwan
okiwan / gist:b368de40c3846b640177
Created May 13, 2014 14:41
Mysql UTF8 user configuration file
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
@okiwan
okiwan / gist:5d5fb13cc616ae83e095
Created May 22, 2014 07:51
POST request with PHP Curl
<?php
$data = file_get_contents('/Users/socana/Desktop/request.txt');
$rsc = curl_init();
curl_setopt($rsc, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($rsc, CURLOPT_URL, "http://demo.optimizr.eu:8080/OptimizrAnalysis/analyze");
curl_setopt($rsc, CURLOPT_POST, true);
curl_setopt($rsc, CURLOPT_POSTFIELDS, $data);
curl_setopt($rsc, CURLOPT_RETURNTRANSFER, true);
@okiwan
okiwan / gist:7914136ba8ac017ec499
Last active August 29, 2015 14:02
Fibonacci demo
#!/usr/bin/php
<?php
define('GOAL', 30);
function fibonacciV1($n = 0) {
if(!$n) : return 0;
elseif ($n < 3) : return 1;
else : return fibonacciV1($n-1) + fibonacciV1($n-2);.
endif;
@okiwan
okiwan / gist:1858a60dcf28e7cbc9d1
Last active August 29, 2015 14:02
Disable SSL certificate check when cloning repos via GIT...
env GIT_SSL_NO_VERIFY=true git clone https://···
@okiwan
okiwan / gist:9cb0741715469c40803d
Last active August 29, 2015 14:08
Keybase.io Verification
### Keybase proof
I hereby claim:
* I am okiwan on github.
* I am okiwan (https://keybase.io/okiwan) on keybase.
* I have a public key whose fingerprint is 16A1 181C 8A6F A81E 5310 068D B973 2D62 46D4 F9AE
To claim this, I am signing this object:
#!/bin/bash
#
# Tomcat 8 start/stop/status init.d script
# Initially forked from: https://gist.github.com/valotas/1000094
# @author: Miglen Evlogiev <bash@miglen.com>
#
# Release updates:
# Updated method for gathering pid of the current proccess
# Added usage of CATALINA_BASE
# Added coloring and additional status