Skip to content

Instantly share code, notes, and snippets.

View natescode's full-sized avatar
🏠
Working from home

Nate natescode

🏠
Working from home
View GitHub Profile
@natescode
natescode / stringToHTML.js
Created January 26, 2024 02:09
Parse Template String as HTML element
String.prototype.toHtml = function () {
let element = new DOMParser().parseFromString(this, 'text/html').body.firstChild;
return element;
};
@schacon
schacon / better-git-branch.sh
Created January 13, 2024 18:41
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@natescode
natescode / .gitconfig
Last active June 27, 2024 23:51
Git Aliases to make GIT easier to work with
[user]
email = your_email
name = your_username
[alias]
# view your global git config Aliases from CLI
aliases = config --get-regexp '^alias\\.'
# git clone
cl = !git clone
# Git shallow clone for large repos
clq= !git clone --depth=1
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
@aesmail
aesmail / control_flow.ex
Created May 29, 2020 16:12
Elixir deciding which control flow to use
# boolean values, use if
if expression, do: this(), else: that()
# non-boolean multi-value single expressions, use case
case expression do
value1 -> one()
value2 -> two()
value3 -> three()
_ -> anything_else()
end
@ashmoran
ashmoran / non_local_returns.rb
Created October 31, 2011 22:34
Proof of non-local returns in Ruby
# Some of the tests for this fail, in a way that's surprising to Python users...
# Why?
class List
def initialize(*elements)
@elements = elements
@elements.each do |e|
return if e.nil?
end
end