Skip to content

Instantly share code, notes, and snippets.

View rpavlovic's full-sized avatar

Rahmin Pavlovic rpavlovic

  • Ernst & Young
  • NYC
View GitHub Profile
@rpavlovic
rpavlovic / create_time_zone.sql
Created February 15, 2015 13:59
Create Time Zone Tables
CREATE TABLE `time_zone` (
`Time_zone_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Use_leap_seconds` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`Time_zone_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1676 DEFAULT CHARSET=utf8 COMMENT='Time zones';
CREATE TABLE `time_zone_leap_second` (
`Transition_time` bigint(20) NOT NULL,
`Correction` int(11) NOT NULL,
PRIMARY KEY (`Transition_time`)
@rpavlovic
rpavlovic / recommended_innodb.sql
Last active September 8, 2015 14:39
Query to recommended InnoDB buffer pool
#!/bin/bash
usage() {
echo "$0 usage:"
echo ""
echo " $0 [options]"
echo ""
echo "Where [options] include:"
echo ""
echo " -h|--help Show this help"
@rpavlovic
rpavlovic / server.js
Created February 12, 2015 18:15
simple Node.js server
// A very basic web server in node.js
// Stolen from: Node.js for Front-End Developers by Garann Means (p. 9-10)
var port = 8000;
var serverUrl = "127.0.0.1";
var http = require("http");
var path = require("path");
var fs = require("fs");
@rpavlovic
rpavlovic / search_zip_files.sh
Created February 2, 2015 16:49
search directory of .zip files for file(s) containing text
#!/bin/bash
for file in *.zip; do unzip -c "$file" | grep "text to find" && echo $f;
@rpavlovic
rpavlovic / list_props.js
Created January 31, 2015 19:02
Use JavaScript to list any/all properties of any JS object (native or custom)
/*
Each browser/device has their set of JS properties (some more secret than others)
Use JavaScript to list any/all properties of any JS object (native or custom)
An old method of mine from the "browser wars"
*/
var logger = logger || {
getProperties : function(obj) {
var props = [];
for(var n in obj) {
var prop = obj.toString() + "." + n;
@rpavlovic
rpavlovic / wp_average_comments.sql
Created January 29, 2015 14:43
Wordpress SQL: average comments per day over time
SELECT
'2010-11-24' AS date_begin,
'2015-01-26' AS date_end,
day_of_week,
AVG(comment_count) AS average_comments
FROM (
SELECT
comment_date,
DAYNAME(comment_date) day_of_week,
DAYOFWEEK(comment_date) day_num,