Skip to content

Instantly share code, notes, and snippets.

View justinhernandez's full-sized avatar
🐙

Justin Hernandez justinhernandez

🐙
View GitHub Profile

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:

<?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');
@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
@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
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 / 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]
# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/6.9"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-server -J-Xverify:none -J-d64 -J-Xss2m -J-Xms256m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.opengl=true -J-Dsun.java2d.d3d=false -J-Dawt.nativeDoubleBuffering=true -J-XX:+UseAdaptiveSizePolicy -J-Djava.net.preferIPv4Stack=true -J-XX:+AggressiveOpts -J-XX:+AggressiveHeap"
# Note that a default -Xmx is selected for you automatically.
# You can find this value in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx here
# or on the command line.
@justinhernandez
justinhernandez / gist:630770
Created October 17, 2010 11:39
pretty array export for var_export
function pretty_var($myArray){
print str_replace(array("\n"," "),array("<br>","&nbsp;"), var_export($myArray,true))."<br>";
}
"Effective people are not problem-minded; they're opportunity minded. They feed opportunities and starve problems." -Stephen R. Covey
"Don't think of problems as difficulties. Think of them as opportunities for action." - Unknown
While one person hesitates because he feels inferior, the other is busy making mistakes and becoming superior. - Henry C. Link
Innovation distinguishes between a leader and a follower. - Steve Jobs
The art of leadership is saying no, not yes. It is very easy to say yes. - Tony Blair
<?php if (@$errors): ?>
<ul class="errors">
<?php foreach ($errors as $field => $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>