Skip to content

Instantly share code, notes, and snippets.

View zjhiphop's full-sized avatar
🎯
Focusing

newboy zjhiphop

🎯
Focusing
  • cloud-tea
  • USA
View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@slevithan
slevithan / xregexp-lookbehind2.js
Created April 14, 2012 21:06
Simulating lookbehind in JavaScript (take 2)
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp.
// Captures within lookbehind are not included in match results. Lazy
// repetition in lookbehind may lead to unexpected results.
(function (XRegExp) {
function prepareLb(lb) {
// Allow mode modifier before lookbehind
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb);
return {
@mckamey
mckamey / README.md
Created June 13, 2012 23:08
Polyfill for touch dblclick
@ryin
ryin / tmux_local_install.sh
Last active April 23, 2024 01:06
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@mattetti
mattetti / gist:3798173
Last active April 16, 2023 03:09
async fetching of urls using goroutines and channels
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"https://splice.com/",
@kates
kates / index_1.html
Last active December 11, 2015 04:19
optimizing js
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function add(){
for (var i = 0; i < 500; i++) {
$('<div style="background-color: #A68585;margin: 2px 0;width: 100px;height: 30px;">' + i + '</div>').appendTo('.box');
}
}
@ckimrie
ckimrie / loadScript.js
Last active July 24, 2018 11:06
Lightweight script loader with callback
/**
* Lightwright JS Loader
*
* @author Christopher Imrie
*
* @param {String} name URL to JS file
* @param {Function} cb Callback function
* @return {null}
*/
function loadScript(/** string */ name, /** Function*/ cb) {
@garryyao
garryyao / git-bundle
Created October 15, 2013 07:46
Shell script to issue git command for each troopjs sub module in bundle repo.
#!/bin/bash
# Issue arbitary git command for each of the sub modules.
# E.g. git-bundle checkout feature/docs
# Check out the feature/docs branch for each of the sub module.
function print_header
{
printf '%.0s-' {1..30} && echo
echo $1
printf '%.0s-' {1..30} && echo
@zjhiphop
zjhiphop / js-extend.js
Last active May 8, 2016 10:15
Different type of JS Extend
//Simple Prototype extend
var extend = (function () {
var f = function(){};
return function (c, p) {
f.prototype = p.prototype;
c.prototype = new f;
c._super = p.prototype;
c.prototype.constructor = c;
}
})();
@flackend
flackend / CDPATH.md
Last active February 22, 2022 21:57
Instructions for setting up CDPATH completions on Mac.

CDPATH

Overview

This will allow you to include additional directories to what cd will look at for completions. From the bash man page:

The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command.

Usage