Skip to content

Instantly share code, notes, and snippets.

View crynobone's full-sized avatar
🖥️
Working

Mior Muhammad Zaki crynobone

🖥️
Working
View GitHub Profile
<?php
$string_create = 'create_some_long_tablename';
$string_add = 'add_some_tablename_to_other_long_table_name';
function get($string) {
$string = str_replace(array('create_', 'add_','_to_'), array('create-', 'add-', '-to-'), $string);
if (preg_match('/^(create|add)\-([A-Za-z0-9\_]*)(\-to\-)?([A-Za-z0-9\_]*)?$/i', $string, $matches)) {
if ($matches[1] == 'create') {
@crynobone
crynobone / Birthdate Parser.js
Created March 10, 2011 21:24
Malaysia Indentification Card Number to Birthdate
var ic = '090303086521';
if(ic.match(/^(\d{2})(\d{2})(\d{2})-?\d{2}-?\d{4}$/)) {
var year = RegExp.$1;
var month = RegExp.$2;
var day = RegExp.$3;
console.log(year, month, day);
var now = new Date().getFullYear().toString();
@crynobone
crynobone / fuel.gitignore
Created April 26, 2011 07:01
Fuel Project standard .gitignore file
*~
*.bak
Thumbs.db
desktop.ini
.DS_Store
.buildpath
.project
.settings
fuel/app/config/db.php
fuel/app/logs/*/*/*
@crynobone
crynobone / fuel-update.sh
Created April 27, 2011 14:45
Fuel Project Update File
#!/bin/bash
#
cd ~/htdocs/fuelphp
git checkout $1
echo 'start updating repository to master branch'
echo 'update fuel'
cd ~/htdocs/fuel/fuel
git checkout $1
@crynobone
crynobone / multiselect.html
Created June 1, 2011 09:32
Retrieve and reassigning multiselect value
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
</head>
<body>
<select id="the-list" multiple="multiple">
<option id="list-1" value="1">Hello World</option>
@crynobone
crynobone / oneauth-sentry.php
Last active October 8, 2015 17:38
Allow OneAuth to use Sentry Auth Driver
<?php
/*
|--------------------------------------------------------------------------
| OneAuth IoC
|--------------------------------------------------------------------------
|
| Register Auth adapter as IoC, allow it to be replaced by any Authentication
| bundle that doesn't use Laravel\Auth\Drivers
*/
@crynobone
crynobone / oneauth-logged.php
Created August 28, 2012 16:18
Overwriting `oneauth.logged` default event listener
<?php
// In order to overwrite the default listener we must add the event overwrite
// after the bundle is started.
Event::listen('laravel.started: oneauth', function ()
{
Event::clear('oneauth.logged');
Event::listen('oneauth.logged', function ($client, $userdata)
{
@crynobone
crynobone / oneauth_facebook.php
Created October 3, 2012 12:20
Sync Facebook Profile Picture to User's avatar
<?php
Event::listen('oneauth.logged', function ($client, $user_data)
{
if ($client->user_id > 0)
{
// get user information using eloquent.
$user = User::find($client->user_id);
$user->avatar = $user_data['info']['image'];
@crynobone
crynobone / my.cnf
Created December 12, 2012 11:56
my.cnf configuration for Macbook Air using MAMP.
[mysqld]
default-storage-engine=InnoDB
collation-server=utf8_unicode_ci
character-set-server=utf8
init-connect='SET NAMES utf8'
table_cache=250
query_cache_size=0
query_cache_type=0
@crynobone
crynobone / name-email.php
Created January 15, 2013 09:13
Simple Regular Expression to parse `NAME <[email protected]>`
<?php
$email = "Mior Muhammad Zaki <[email protected]>";
if (preg_match('/^(.+\s)<(.*)>$/', $email, $matches))
{
$name = $matches[1];
$email = $matches[2];
}