Skip to content

Instantly share code, notes, and snippets.


Nik Sumeiko niksumeiko

View GitHub Profile
niksumeiko / git.color
Last active August 29, 2015 13:55
Git command to enable colors for all git commands in Mac OSX Terminal.
View git.color
# By executing this command in your Mac OSX Terminal, all git commands will have
# colors, so you're more comfortable reading git produced output.
git config --global color.ui true
View git.snapshot
# This script will make a webcam snapshot every commit. The jpg file will have
# the commit id as the filename.
# This script requires imagesnap. Install with: 'brew install imagesnap'
# Put this file in the '.git/hooks/' name it 'post-commit' and chmod it by:
# 'chmod +x .git/hooks/post-commit'
niksumeiko /
Created April 22, 2014 13:12
JavaScript exercise that requires to create credit card input fields validation functions.
* @fileoverview Utils Interface credit card validation methods.
* @author (Wind Tammer)
utils = {};
/** @type {Object<Function>} */ = {};
niksumeiko / promises-chaining.js
Last active August 29, 2015 14:23
Promises chaining that solves "callbacks hell"
View promises-chaining.js
'use strict';
var Promise = require('promise');
function build() {
return new Promise(function(fulfill, reject) {
niksumeiko / sum-function-arguments.js
Created June 30, 2015 08:03
Sums up function arguments
View sum-function-arguments.js
* Sums up all given arguments.
* @param {...*} var_args Numbers or numbers alike to sum up.
* Numbers will be added as is, numbers in strings (e.g. '123.45')
* will be converted to numbers and added. NaNs are skipped.
* @return {number} The sum of number arguments.
function sum(var_args) {
var args = [];
View emailcustomencoder.php
function tep_rewrite_email($content) {
$email_patt = '([A-Za-z0-9._%-]+)\@([A-Za-z0-9._%-]+)\.([A-Za-z0-9._%-]+)';
$mailto_pattern = '#\<a[^>]*?href=\"mailto:\s?' . $email_patt . '[^>]*?\>[^>]*?<\/a\>#';
$rewrite_result = '<span class="mailme">\\1 AT \\2 DOT \\3</span>';
$content = preg_replace($mailto_pattern, $rewrite_result, $content);
$content = preg_replace('#' . $email_patt . '#', $rewrite_result, $content);
niksumeiko / emailpatter.js
Created May 27, 2013 14:15
Very simple, but perfectly working, email JavaScript validation pattern.
View emailpatter.js
if (!/\S+@\S+\.\S+/.test("")) {
// Invalid email address
niksumeiko / object.equals.js
Last active December 18, 2015 12:19
JavaScript function that I am using to compare 2 JavaScript object without taking in mind prototypes of these objects.
View object.equals.js
// Function that compares 2 objects
function equals(obj1, obj2, skip) {
var i, l;
if ( typeof obj1 === "object" && typeof obj2 === "object") {
obj1 = JSON.stringify(obj1);
obj2 = JSON.stringify(obj2);
if (skip && skip.length) {
obj1 = JSON.parse(obj1);
niksumeiko / git.stash
Created June 17, 2013 18:43
Use 'git stash [, pop]' to commit to the proper GIT branch when discovered that you have made local changes in an inappropriate branch.
View git.stash
# Sometimes we discover that local changes we have made in our GIT project
# are not related to the branch we currently work in.
# So we need to switch the propoer branch before committing the changes.
# 'git stash [, pop]' is going to solve the problem easily.
# 1. While you have uncommitted changes, 'stash' them to create a temporary
# commit of the current state of the working copy (both cached and
# uncached files) and to revert the working copy to the current HEAD:
git stash
niksumeiko / utils.getRandomInteger.js
Last active December 18, 2015 15:48
JavaScript function that returns a random integer within specified range of integers (eg from 0 to 167).
View utils.getRandomInteger.js
// Returns a random integer between min and max.
function getRandomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;