Skip to content

Instantly share code, notes, and snippets.

View ninja-webdev's full-sized avatar

Joe2 Palala ninja-webdev

View GitHub Profile
@ninja-webdev
ninja-webdev / a-better-git-log.md
Created March 5, 2020 02:50
a better git log

Source: https://coderwall.com/p/euwpig/a-better-git-log

It's simple. Just type in:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

I guess that's a bit too long, eh? Let's just make an alias. Copy and paste the line below on your terminal:

@ninja-webdev
ninja-webdev / subtree.php
Created December 28, 2019 06:55
subtrees in php
<?php
class Node {
public $info;
public $left;
public $right;
public $level;
public function __construct($info) {
$this->info = $info;
$this->left = NULL;
$this->right = NULL;
@ninja-webdev
ninja-webdev / getJars.js
Created June 2, 2017 05:19
6 Jars computation
function getJarPercentages(){
var totalBudget = process.argv[2];
console.log("55% of totalBudget is " + totalBudget * 0.55);
console.log("5% of totalBudget is " + totalBudget * 0.05 + " (GIV)");
console.log("10% of totalBudget is " + totalBudget * 0.10);
}
if(process.argv[2]) {
getJarPercentages();
@ninja-webdev
ninja-webdev / git_pull_script.sh.md
Created June 1, 2017 05:31 — forked from jpalala/git_pull_script.sh.md
create a simple deploy script by issuing git pull on the directory of the folder

#simple- cd to directory with the git initialized and pull origin develop or master echo "Running deployment" cd /var/www/html git pull origin develop echo "Repo updated with develop"`

@ninja-webdev
ninja-webdev / python_bst.py
Created March 9, 2017 14:39 — forked from bshyong/python_bst.py
Python BST implementation
class BSTnode(object):
"""
Representation of a node in a binary search tree.
Has a left child, right child, and key value, and stores its subtree size.
"""
def __init__(self, parent, t):
"""Create a new leaf with key t."""
self.key = t
self.parent = parent
self.left = None
@ninja-webdev
ninja-webdev / egg.js
Created March 2, 2017 13:39 — forked from wldcordeiro/egg.js
The Egg programming language from Eloquent JS Chapter 11
function parseExpression(program) {
program = skipSpace(program);
var match, expr;
if (match = /^"([^"]*)"/.exec(program)) {
expr = {type: "value", value: match[1]};
} else if (match = /^\d+\b/.exec(program)) {
expr = {type: "value", value: Number(match[0])};
} else if (match = /^[^\s(),"]+/.exec(program)) {
expr = {type: "word", name: match[0]};
@ninja-webdev
ninja-webdev / backup.sh
Created February 2, 2017 10:14
general backup script
BAK="/bkp"
GZIP="$(which gzip)"
NOW=$(date +"%d-%m-%y_%T_%Z")
[ ! -d "$BAK" ] && mkdir -p "$BAK"
FILE=$BAK/backup$NOW.tar
FOLDERTOBACKUP=/var/www/
echo "Tarring the folder $FOLDERTOBACKUP to $FILE Please wait ..."