Skip to content

Instantly share code, notes, and snippets.

View Jeemusu's full-sized avatar

James Morris Jeemusu

View GitHub Profile
@Jeemusu
Jeemusu / rollup.config.js
Last active May 17, 2016 06:29
Rollup config for ES6 module bundling, transpiling to ES5 (Buble) and compression (Uglify).
//npm install rollup --global
//npm install --save-dev- rollup-plugin-buble
//npm install --save-dev- rollup-plugin-uglify
import buble from 'rollup-plugin-buble';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'src/main.js',
dest: 'dist/main.min.js',
@Jeemusu
Jeemusu / gist:9165fe7f6287fa54b9489a4da81a5d4d
Created April 17, 2016 06:46
Serve pre-gzip'd files (apache)
AddEncoding gzip .gz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Konqueror
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)\.css$ $1.css.gz [QSA,L]
RewriteRule ^(.*)\.js$ $1.js.gz [QSA,L]
RewriteRule ^(.*)\.html$ $1.html.gz [QSA,L]
@Jeemusu
Jeemusu / prefectures.txt
Last active April 14, 2016 07:25
Japanese prefecture PHP arrays
$prefectures = array(‘北海道’,'青森県’,'岩手県’,'宮城県’,'秋田県’,'山形県’,'福島県’,'茨城県’,'栃木県’,'群馬県’,'埼玉県’,'千葉県’,'東京都’,'神奈川県’,'新潟県’,'富山県’,'石川県’,'福井県’,'山梨県’,'長野県’,'岐阜県’,'静岡県’,'愛知県’,'三重県’,'滋賀県’,'京都府’,'大阪府’,'兵庫県’,'奈良県’,'和歌山県’,'鳥取県’,'島根県’,'岡山県’,'広島県’,'山口県’,'徳島県’,'香川県’,'愛媛県’,'高知県’,'福岡県’,'佐賀県’,'長崎県’,'熊本県’,'大分県’,'宮崎県’,'鹿児島県’,'沖縄県’);
$prefectures = array(’1′=>’北海道’,’2′=>’青森県’,’3′=>’岩手県’,’4′=>’宮城県’,’5′=>’秋田県’,’6′=>’山形県’,’7′=>’福島県’,’8′=>’茨城県’,’9′=>’栃木県’,’10′=>’群馬県’,’11′=>’埼玉県’,’12′=>’千葉県’,’13′=>’東京都’,’14′=>’神奈川県’,’15′=>’新潟県’,’16′=>’富山県’,’17′=>’石川県’,’18′=>’福井県’,’19′=>’山梨県’,’20′=>’長野県’,’21′=>’岐阜県’,’22′=>’静岡県’,’23′=>’愛知県’,’24′=>’三重県’,’25′=>’滋賀県’,’26′=>’京都府’,’27′=>’大阪府’,’28′=>’兵庫県’,’29′=>’奈良県’,’30′=>’和歌山県’,’31′=>’鳥取県’,’32′=>’島根県’,’33′=>’岡山県’,’34′=>’広島県’,’35′=>’山口県’,’36′=>’徳島県’,’37′=>’香川県’,’38′=>’愛媛県’,’39′=>’高知県’,’40′=>’福岡県’,’41′=>’佐賀県’,’42′=>’長崎県’,’43′=>’熊本県’,’44′=>’大分県’,’45′=>’宮崎県’,’46′=>’鹿児島県’,’47′=>’沖縄県’);
@Jeemusu
Jeemusu / gist:9200688
Created February 25, 2014 01:13
Mulit-byte Unserialize
/**
* Mulit-byte Unserialize
*
* Recalculates the length of a multibyte strings and unserializes.
* Source: http://dzone.com/snippets/mulit-byte-unserialize
*
* @param string
* @return string
*/
function mb_unserialize($string) {
@Jeemusu
Jeemusu / config.yaml
Created February 16, 2014 05:38
I use this with Vagrant and Puppet to create a Debian Wheezy VM For PHP5.4 and Apache development. Includes Mongodb, beanstalkd, elsatic search, xdebug, xhprof. Also has an example for setting up SSL vhosts without the need to faff around self signing certificates.
---
vagrantfile-local:
vm:
box: debian-wheezy72-x64-vbox43
box_url: 'http://box.puphpet.com/debian-wheezy72-x64-vbox43.box'
hostname: null
network:
private_network: 192.168.56.101
forwarded_port:
laSB20cs7VhK:
@Jeemusu
Jeemusu / gist:7525186
Last active December 14, 2020 04:41
Check if string is full-width Japanese. Useful when you need to validate a name field in Japanese.
function jpn_zenkaku_only($str) {
$encoding = "UTF-8";
// Get length of string
$len = mb_strlen($str, $encoding);
// Check each character
for ($i = 0; $i < $len; $i++) {