Skip to content

Instantly share code, notes, and snippets.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@ngocdaothanh
ngocdaothanh / gist:3764694
Created September 22, 2012 00:43
Scala Assignment: Recursion
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
@examinedliving
examinedliving / split_output.cmd
Last active January 11, 2020 05:34
Split Windows Path variable (or anything else) into seperate lines to view easily from command line.
:: This assumes you are running from command line. To run from batch script, add the next commented out line to the top of
:: your batch file. Also, in a batch file the % sign before the i should be doubled, .e.g. %%i.
:: batch file only - remove preceeding semicolons from the next line and insert in batch file.
:: SETLOCAL ENABLEDELAYEDEXPANSION
:: from command prompt only - add the next line
cmd /v:on
@lancelothk
lancelothk / gist:f8f4b635666cdb4cc895
Last active February 26, 2019 00:09
sed1line.txt
copy from http://sed.sourceforge.net/sed1line.txt
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
@nopjia
nopjia / splitPath.js
Last active November 7, 2022 16:22
The ultimate split path, with a single regex
/**
* The ultimate split path.
* Extracts dirname, filename, extension, and trailing URL params.
* Correct handles:
* empty dirname,
* empty extension,
* random input (extracts as filename),
* multiple extensions (only extracts the last one),
* dotfiles (however, will extract extension if there is one)
* @param {string} path
@andypotts
andypotts / snippet.md
Last active July 20, 2017 09:40 — forked from harthur/snippet.md
console.log() + var_dump() key bindings for Sublime Text. Cmd + Shift + L.

Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:

[
    { "keys": ["super+shift+l"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }, "context":
 [
@VincentLiu
VincentLiu / install_go_wsl.md
Last active June 29, 2020 17:53
Install Golang on WSL

How to set up Go on WSL, Go environment and hello world Go application

  1. install Go from here
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.10.linux-amd64.tar.gz
  1. set up development folders