This file contains 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
<?php | |
$randomValue = mt_rand(); | |
$even = $randomValue & ~1; | |
$odd = $randomValue | 1; | |
// magical unicorn isn't it? |
This file contains 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
<?php | |
function runCommand () | |
{ | |
$command = 'php artisan queue:listen > /dev/null & echo $!'; | |
$number = exec($command); | |
file_put_contents(__DIR__ . '/queue.pid', $number); | |
} | |
if (file_exists(__DIR__ . '/queue.pid')) { |
This file contains 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
String.prototype.padLeft = function (n, str) { | |
if (n < String(this).length) { | |
return this.toString(); | |
} | |
else { | |
return Array(n - String(this).length + 1).join(str || '0') + this; | |
} | |
} | |
function crc16(s) { |
This file contains 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
// Thanks to MoOx and martindafonte over at | |
// https://gist.github.com/MoOx/93c2853fee760f42d97f | |
var labels = []; | |
[].slice.call(document.querySelectorAll(".label-link")) | |
.forEach(function(element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
description: element.getAttribute("aria-label"), | |
// using style.backgroundColor might returns "rgb(...)" |
This file contains 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/sh | |
# Printing PDF files from your command prompt. | |
# 1. Create a "print" folder in your home directory. | |
# 2. Put this "print.sh" in the "print" folder. | |
# 3. Run "chmod +x print.sh" to make me executable | |
# 4. For each time you want to print PDF files: | |
# i) Place a copy of the PDF files in the "print" folder | |
# ii) run "./print.sh" |
This file contains 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
<?php | |
namespace Mauris\Utility; | |
class NricUtility | |
{ | |
public static function validate($nric) | |
{ | |
$nric = strtoupper($nric); | |
if (strlen($nric) == 9) { | |
$hash = self::checksum(substr($nric, 0, 8)); |
This file contains 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
// The mathematical definition (i.e. simple recursion): | |
function fib(n) { | |
if (n < 1) { // base case 1 | |
return 0; | |
} | |
if (n < 3) { // base case 2 | |
return 1; | |
} | |
// recursion steps |
This file contains 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
{ | |
"canon_url": "https:\/\/bitbucket.org", | |
"commits": [ | |
{ | |
"author": "mauris", | |
"branch": "master", | |
"files": [ | |
{ | |
"file": "test", | |
"type": "added" |
This file contains 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
export RUNFILE=BabyNames; javac $RUNFILE.java; for file in *.in; do java $RUNFILE < $file | diff ${file%.*}.out -; done |
NewerOlder