Skip to content

Instantly share code, notes, and snippets.

View CMCDragonkai's full-sized avatar
🚀
Lightspeed

Roger Qiu CMCDragonkai

🚀
Lightspeed
View GitHub Profile
@CMCDragonkai
CMCDragonkai / session_status_vs_session_id.php
Last active December 18, 2015 17:38
PHP: Why PHP 5.4's session_status() is better than session_id() for determining if a PHP session is active. Also shows how to resolve multiple session restarting.
<?php
ob_start();
session_start();
var_dump(session_status());
var_dump(PHP_SESSION_ACTIVE);
var_dump(session_status() == PHP_SESSION_ACTIVE); //(true means active, false means no)
var_dump(session_id() !== '');
@CMCDragonkai
CMCDragonkai / XXX_camel_tables.php
Created June 27, 2013 03:59
PHP: Codeigniter migrating snake_case column names to camelCase column names.
<?php
//this migration demonstrates a potential migration that changes snake case column names to camelcase names
//the reverse is in the down function
class Migration_camel_tables extends CI_Migration {
public function up(){
$tables = $this->db->list_tables();
@CMCDragonkai
CMCDragonkai / XXX_add_sessions.php
Created June 27, 2013 04:17
PHP: Codeigniter sessions migration.
<?php defined('BASEPATH') OR exit('No direct script access allowed');
//this migration can only be ran when you have switched off session use tables, then after migrating, switch it back on!
class Migration_add_sessions extends CI_Migration {
public function up(){
$this->dbforge->add_field(array(
'session_id' => array(
'type' => 'VARCHAR',
@CMCDragonkai
CMCDragonkai / EqualiseHeights.Directive.js
Last active December 20, 2015 04:58
JS: AngularJS Equalise Height Directives. Relies on jQuery and jquery-resize. AMD Compatible.
define(['angular'], function(angular){
'use strict';
/**
* Equalise Heights
*
* @param string jQuery Selector of which to equalise
*/
angular.module('Directives')
@CMCDragonkai
CMCDragonkai / Prepos Filters
Last active December 20, 2015 16:39
CONFIGURATION: Prepos Filters
bower_components,node_modules,vendor,img,image,fonts,project_design,system,secrets,c9revisions,bin,README.md,js
define(['angular', 'masonry', 'imagesLoaded', 'lodash'], function(angular, Masonry, imagesLoaded, _){
'use strict';
/**
* Masonry Directive for a wall of item.
* This directive is intended to be used along with ng-repeat directive.
* Put masonryWallDir on the container element and pass in a class selector for each item to be laid out.
* Pass in optional options via masonryWallOptions.
* Put the masonryItemDir next to ng-repeat directive on the item to be repeated.
@CMCDragonkai
CMCDragonkai / transparent_background_mixin.less
Created August 17, 2013 10:05
LESS: Transparent Background Mixin Cross Browser
.transparent-background(@red: 0, @green: 0, @blue: 0, @alpha: 0.5){
background: transparent;
background: rgba(@red, @green, @blue, @alpha);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=argb(rgba(@red, @green, @blue, @alpha)), endColorstr=argb(rgba(@red, @green, @blue, @alpha)))";
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=argb(rgba(@red, @green, @blue, @alpha)), endColorstr=argb(rgba(@red, @green, @blue, @alpha)));
}
@CMCDragonkai
CMCDragonkai / apple_touch_icons_and_favicon.html
Created August 17, 2013 10:17
HTML: Apple Touch Icons & Favicon Meta Tags Example. Expected images are to be stored in an "img" folder. Except the favicon, leave it at the root.
<html>
<head>
<link rel="shortcut icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144x144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-57x57-precomposed.png">
</head>
</html>
@CMCDragonkai
CMCDragonkai / angularjs_base_url_explanation.txt
Created August 17, 2013 10:28
JS: AngularJS with HTML5 URLs
When ever you start an AngularJS project and you wish to use HTML5 urls. It is a
good practice to use the base tag. The base tag will set all your URLs relative
to what is set in the base, and that value could be set by your server side
templating language.
Example:
<html>
<head>
<base href="ENTER HOST ROOT" />
@CMCDragonkai
CMCDragonkai / Autolink.Filter.js
Created August 18, 2013 20:14
JS: AngularJS Autolinking Filter. Adapted from: http://jsfiddle.net/bmleite/FyGen/