Skip to content

Instantly share code, notes, and snippets.

View jasonleonhard's full-sized avatar

jasonleonhard jasonleonhard

View GitHub Profile
@jasonleonhard
jasonleonhard / gist:f4c05ab712388c878bc0
Created May 20, 2015 16:26
rails whitespace syntax error
# this one will not work, it creates a syntax error
class ArticlesController < ApplicationController
def new
end
  
def create
render plain: params[:article].inspect
  end
end
p() {
if [[ $1 ]]; then
ps aux | grep -i $1
else
ps aux | less
fi
}
alias cpu='top -o cpu -s 8 -n 11'
@jasonleonhard
jasonleonhard / gist:f2e38b91c791b2acdbe6
Created April 3, 2015 16:12
stopwatch or countdown
countdown() {
[[ -z $1 ]] && seconds=60 || seconds=$1
since=$(date +%s)
remaining=$seconds
while (( remaining >= 0 ))
do
printf "\r%-10d" $remaining
sleep 0.5
remaining=$(( seconds - $(date +%s) + since ))
done
// This will match an email given any string
// note even my ' in the string was fine ;D
var re = /[\w]+@[\w-]+\.[\w]+/g;
var str2 = "my email is not optikalefx@me.com it's actually devbrights@gmail.com";
var myArray = str2.match(re);
myArray
//search inside just a target <tag> in DevTools console using RegEx
<!doctype html>
<html>
<head>
<title>Tabbed Form</title>
<style type="text/css">
/*-----------------CSS-------------------*/
body {
width: 500px;
margin: auto;
Verifying that +un5t0ppab13 is my openname (Bitcoin username). https://onename.io/un5t0ppab13
# Simple calculator
function calc() {
local result="";
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')";
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |