Skip to content

Instantly share code, notes, and snippets.

View jasonleonhard's full-sized avatar

jasonleonhard jasonleonhard

View GitHub Profile
# 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" |
Verifying that +un5t0ppab13 is my openname (Bitcoin username). https://onename.io/un5t0ppab13
<!doctype html>
<html>
<head>
<title>Tabbed Form</title>
<style type="text/css">
/*-----------------CSS-------------------*/
body {
width: 500px;
margin: auto;
// 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
@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
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: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
@jasonleonhard
jasonleonhard / gist:5f0e672ee57207a36f2b
Last active August 29, 2015 14:22
Google Calendar Improved
/* GOOGLE CALENDAR Improved
You use google calendar right? Try this for fun (it is really quick):
open google chrome,
type command-Shift-C,
hit escape twice to see the console,
then paste this whole message in
and hit enter:
You can then hit command-shit-i to remove the console....
Just refresh if you don't like it... and it will go away. */

Keybase proof

I hereby claim:

  • I am un5t0ppab13 on github.
  • I am un5t0ppab13 (https://keybase.io/un5t0ppab13) on keybase.
  • I have a public key whose fingerprint is 608B EEC9 C5C2 EA49 7890 4A13 5B60 D4D7 8F68 6673

To claim this, I am signing this object:

@jasonleonhard
jasonleonhard / gist:4a7eaf639f376e076bea
Created June 24, 2015 23:14
CREATE A NEW REPO IN GITHUB OR BITBUCKET QUICKLY
NewRepo(){ # NewRepo RepoName5 ~/RepoLocalPath5/ g or # NewRepo Repo1 ~/RepoLocal1/ b
mkdir $2 ;
cd $2 ;
echo $1 | pbcopy ;
echo "$1 $2 $3 un5t0ppab13" >> $3.txt ; # create new file$3 with text"$1$2$3"
if [ -a "g.txt" ] ; then
open 'https://github.com/new/' ;
elif [ -a "b.txt" ] ; then
open 'https://bitbucket.org/repo/create' ;
fi ;