Skip to content

Instantly share code, notes, and snippets.

💭
Automate

Sam Yong mauris

💭
Automate
  • Singapore
Block or report user

Report or block mauris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mauris
mauris / export.js
Last active Aug 29, 2018
Github Repository Labels Import / Export - Aug 2018
View export.js
// 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(...)"
View print.sh
#!/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"
@mauris
mauris / fib.js
Last active Nov 28, 2017
Fibonacci Dynamic Programming
View fib.js
// 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
View gist:c285698cc303e4509106fefd967f9c67
export RUNFILE=BabyNames; javac $RUNFILE.java; for file in *.in; do java $RUNFILE < $file | diff ${file%.*}.out -; done
View FileTree.js
/**
* This code was extracted from https://github.com/mauris/gitguard/blob/master/src/components/FileTree/index.js
* Using AngularJS, this 60-LoC file forms the controller neccessary for the frontend of a file tree component
* to be working.
*
* Whenever a folder from the list is selected, the code will request the server for the list of files in that path.
*/
const app = require('../../app');
let $controller = function ($http, $scope) {
View node-global.sh
sudo npm i -g bower coffee-script cordova electron-packager electron-prebuilt express-generator forever grunt grunt-cli gulp static ionic jsdom-cli less mathjs q nodemon node-static ngist
@mauris
mauris / queue-ensure.php
Created Apr 28, 2014
Laravel Artisan Queue Ensurer - Set a cron job to run this file periodically to ensure that Laravel's queue is processing all the time. If the queue listener stopped, restart it!
View queue-ensure.php
<?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')) {
@mauris
mauris / NricUtility.php
Created Sep 8, 2013
A NRIC utility class implemented in PHP. For validating NRIC numbers or generating random NRIC numbers.
View NricUtility.php
<?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));
@mauris
mauris / routing.yml
Created May 25, 2013
Sample Routing YAML for Packfire Framework 2.1
View routing.yml
imports: null
prefix: null
routes:
home:
methods:
- get
- head
uri: "/{page}.{format}"
action: "Packfire\\Test\\Controller:action"
defaults:
@mauris
mauris / gist:5558889
Created May 11, 2013
Sample BitBucket payload for hook services
View gist:5558889
{
"canon_url": "https:\/\/bitbucket.org",
"commits": [
{
"author": "mauris",
"branch": "master",
"files": [
{
"file": "test",
"type": "added"
You can’t perform that action at this time.