Skip to content

Instantly share code, notes, and snippets.

View justinhernandez's full-sized avatar
🐙

Justin Hernandez justinhernandez

🐙
View GitHub Profile
@justinhernandez
justinhernandez / gist:1077273
Created July 12, 2011 02:21
simple codeigniter htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /m/index.php/$1 [L]
var fs = require('fs');
var base = '../vagabond';
var dirs = fs.readdirSync(base);
var _ = require('lodash');
var archiver = require('archiver');
_.each(dirs, function(dir){
var archive = archiver('zip', { zlib: { level: 9 } });
var output = fs.createWriteStream('../zips/vagabond-' + dir + '.cbz');
archive.pipe(output);
@justinhernandez
justinhernandez / rds.sh
Created December 25, 2015 17:38 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@justinhernandez
justinhernandez / rename_columns.sql
Last active December 21, 2022 14:43
Rename columns from camelCase to underscore - PostgreSQL
WITH from_table AS (
SELECT 'janky_table'::text AS name
)
SELECT 'ALTER TABLE "' || f.name || '" RENAME COLUMN "' || cols.column_name || '" TO "' || cols.regular_pgstyle || '";' AS stmt
FROM (SELECT column_name,
lower(regexp_replace(column_name, E'([A-Z])', E'\_\\1','g')) As regular_pgstyle
FROM information_schema.columns,
from_table f
<?php
$testString = "• janky • stuff • take me away ••";
function escape_mb_chars($str) {
$first = preg_replace_callback('/\p{C}/u', function ($m) {
$char = current($m);
return substr(json_encode($char), 1, -1);
}, $str);
return rtrim($first, '\n');

Keybase proof

I hereby claim:

  • I am justinhernandez on github.
  • I am justinhernandez (https://keybase.io/justinhernandez) on keybase.
  • I have a public key ASCjLq3QJB9STTS88kzSftF3ufX2U_VmZurKHM6CGFgVpQo

To claim this, I am signing this object: