Skip to content

Instantly share code, notes, and snippets.

View kebman's full-sized avatar
Playing Ponkatris

kebman kebman

Playing Ponkatris
View GitHub Profile
@kebman
kebman / namespace.js
Last active August 27, 2015 20:59
How to easily create a namespace in JavaScript to avoid polluting global space
// Check if the namespace 'KEB' is available globally
if (!KEB) {
// If it is, then assign an object to the 'KEB' variable, and you have your namespace!
var KEB = {};
}
// Write a variable (attribute) to the namespace
KEB.name = "KEB";
// Write a function (method) to the namespace
@kebman
kebman / backup.sh
Last active September 23, 2015 22:08
Simple shell script to make a folder-to-folder backup of local projects to Dropbox
#!/bin/bash
# Simple folder-to-folder backup of local projects to Dropbox
CORRECTPATH="/home/username/Desktop/local_projects"
CHECKPATH=$(pwd)
if [ $CHECKPATH = $CORRECTPATH ]; then
cp -a ./* ~/Dropbox/local_projects_backup
echo "Backup success! :)"
else
@kebman
kebman / Promise.html
Last active September 23, 2015 23:19
Simple example of a JavaScript Promise
<!DOCTYPE html>
<html>
<head>
<title>Promises in HTML5 + ES6</title>
<meta charset="utf-8">
</head>
<body>
<header>
<h1>Promises in HTML5 + ES6</h1>
</header>
@kebman
kebman / checkFileDupes.js
Created October 2, 2015 02:12
Check for duplicate files with Node.js
// find duplicate files with Node.js, cuz, you know, it's useful
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require('fs'));
var crypto = require('crypto');
var path = require('path');
var pathA = "."; // folder you're in, wherever that might be
var pathB = "/path/to/the/directory/you/want/to/compare/it/to"; // yes, yes, argv, etc, but I haven't bothered yet, ok!
@kebman
kebman / bitflipper.html
Last active October 7, 2015 09:55
A web page showcasing simple flipping of binary bits and the numerical representation of that byte
<!DOCTYPE html>
<html>
<head>
<title>Bits and bytes</title>
<meta charset="utf-8">
<style type="text/css">
#form input {
width:1em;
}
td {
@kebman
kebman / tictoc.html
Created December 23, 2015 02:38
Simple Tic Toc in HTML5
<!DOCTYPE html>
<html>
<head>
<title>Tic Toc</title>
<meta charset="utf-8">
</head>
<body>
<header>
<h1>Tic Toc</h1>
</header>
@kebman
kebman / callback.html
Created February 2, 2016 14:47
JavaScript Callback Example
<!DOCTYPE html>
<html>
<head>
<title>Example of using callbacks in JavaScript</title>
<meta charset="utf-8" />
<style type="text/css"></style>
</head>
<body>
<header>
<h1>Simulation of delayed callback functionality</h1>
@kebman
kebman / dragbox.html
Last active February 17, 2016 23:01
Example of a freely draggable box element made with HTML5 and JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Movable Element</title>
<meta charset="utf-8">
<style type="text/css">
#testBox {
/* define shape and colour */
width: 50px; height: 50px;
background-color: #ddd;
@kebman
kebman / standardDeviation.html
Last active March 23, 2016 13:12
Tutorial on how to get the Standard Deviation of a set of numbers using JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Standard Deviation</title>
<meta charset="utf-8">
<style type="text/css"></style>
</head>
<body>
<header>
<h1>Standard Deviation</h1>
@kebman
kebman / .bash_profile
Last active December 24, 2016 03:41
The bash profile for my Terminal in Mac OS X Sierra
export PATH=/usr/local/mysql/bin:$PATH
export PS1="\u \\$ \[$(tput sgr0)\]"
alias nj='cd /Users/username/Dropbox/node'
alias home='cd ~'