This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Enum{ | |
//To use this Enum class, just extend it and fill it with costants ;) | |
public static final function get_const_list(){ | |
$r = new ReflectionClass(get_called_class()); | |
/*I chose to flip the array because it's more flexible to work with integers as keys | |
*rather than strings... | |
*/ | |
return array_flip($r->getConstants()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Searches a CI resultset, and when the match is evaluated, returns the specified value | |
* Both params of $match array are required | |
* | |
* Example of use: if you want to get the ID of an item where the row 'type' is 'user' | |
* you do: | |
* | |
* Take note: The comparison doesn't take account of whitespace characters before and | |
* after the data of the result sets rows | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function group_sort($array, $order) | |
{ | |
$new = array(); | |
foreach ($array as $row){ | |
foreach ($order as $ord){ | |
$new[$ord][] = $row[$ord]; | |
} | |
} | |
$str = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sorts a multidimentional array in groups. The sorting sequence is provided by using an array | |
* that contains the keys that should be grouped | |
* | |
* @param array $array | |
* @param array $order | |
*/ | |
function group_sort(&$array, $order) | |
{ | |
if(!$array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="app"> | |
<head> | |
</head> | |
<body> | |
<div> | |
<div ng-controller="ListsController"> | |
<!-- sortable-connect-with specifies the element that will be connected to this --> | |
<!-- sortable-limit tells the directive that this element cannot contain more elements than those specified --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ClientDB = function(){ | |
var DB = this; | |
var localStorage = window.localStorage; | |
// This object will contain an array for every data type | |
var tables = {}; | |
// This object will contain the latest id for every table in the app. | |
var table_ids = {}; | |
// This record will contain any records that are deleted from the local DB, but are not yet synched with the server | |
var deleted_records = {}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collisionsExist = false; | |
rows.map(function(row){ | |
row.timebands.map(function(timeband){ | |
if(timeband !== $scope.timeband){ | |
var newTb = fixTimeband($scope.timeband), testTb = fixTimeband(timeband); | |
// The new timeband starts before the test timeband starts, and ends after the test timeband ends | |
if(newTb.to <= testTb.to && newTb.from >= testTb.from){ | |
collisionsExist = true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
// We do not know if this file is used inside a web script or a webworker script, | |
// so we use this hack to get access to the current global object | |
var get = eval; | |
var window = get("this"); | |
// Some versions of IE have no set method in the Uint8ClampedArray. | |
// This was propably a bug that was fixed in a later update but we'll add it here | |
// just to be sure... | |
Uint8ClampedArray.prototype.set = Uint8ClampedArray.prototype.set || function(data){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extending the user creation functionality | |
*/ | |
if(Meteor.isServer){ | |
Accounts.onCreateUser(function(options, user){ | |
user.username = Meteor.call('generateUsername'); | |
var existing = Meteor.users.find({username: user.username}, {limit:1, fields:{_id:1}}).fetch().length; | |
if(existing){ | |
// Get the total number of usernames that start with the existing username, add | |
// their total count at the end to make it unique |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tail "$@" | awk ' | |
{matched=0} | |
/INFO:/ {matched=1; print "\033[0;37m" $0 "\033[0m"} # WHITE | |
/NOTICE:/ {matched=1; print "\033[0;36m" $0 "\033[0m"} # CYAN | |
/WARNING:/ {matched=1; print "\033[0;34m" $0 "\033[0m"} # BLUE | |
/ERROR:/ {matched=1; print "\033[0;31m" $0 "\033[0m"} # RED | |
/ALERT:/ {matched=1; print "\033[0;35m" $0 "\033[0m"} # PURPLE | |
matched==0 {print "\033[0;33m" $0 "\033[0m"} # YELLOW |
OlderNewer