Skip to content

Instantly share code, notes, and snippets.

@leplay
leplay / gist:8595855
Last active January 4, 2016 08:29 — forked from JosephPecoraro/shell-execution.rb
Ways to execute a shell script in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@leplay
leplay / formatDate.js
Last active September 19, 2019 09:18 — forked from eikes/date.format.js
format date / es6 / case style
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
* and leplay <https://gist.github.com/leplay/e9fafa24e29d8bfe5688>
*
* Accepts a date, a mask, or a date and a mask.
// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));