Skip to content

Instantly share code, notes, and snippets.

Avatar
🖥️
Working

Mior Muhammad Zaki crynobone

🖥️
Working
View GitHub Profile
View Create or add text parser.php
<?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 Mar 10, 2011
Malaysia Indentification Card Number to Birthdate
View Birthdate Parser.js
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 Apr 26, 2011
Fuel Project standard .gitignore file
View fuel.gitignore
*~
*.bak
Thumbs.db
desktop.ini
.DS_Store
.buildpath
.project
.settings
fuel/app/config/db.php
fuel/app/logs/*/*/*
@crynobone
crynobone / fuel-update.sh
Created Apr 27, 2011
Fuel Project Update File
View fuel-update.sh
#!/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 Jun 1, 2011
Retrieve and reassigning multiselect value
View multiselect.html
<!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 Oct 8, 2015
Allow OneAuth to use Sentry Auth Driver
View oneauth-sentry.php
<?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 Aug 28, 2012
Overwriting `oneauth.logged` default event listener
View oneauth-logged.php
<?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 Oct 3, 2012
Sync Facebook Profile Picture to User's avatar
View oneauth_facebook.php
<?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 Dec 12, 2012
my.cnf configuration for Macbook Air using MAMP.
View my.cnf
[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 Jan 15, 2013
Simple Regular Expression to parse `NAME <email@address.com>`
View name-email.php
<?php
$email = "Mior Muhammad Zaki <crynobone@gmail.com>";
if (preg_match('/^(.+\s)<(.*)>$/', $email, $matches))
{
$name = $matches[1];
$email = $matches[2];
}