Skip to content

Instantly share code, notes, and snippets.

@jeffwesson
jeffwesson / bad-markup-semanticity
Last active August 29, 2015 14:04
This is a great example of bad markup. Each header should be simple text with CSS font styling for shadows and CSS background images based on media queries. All semanticity is lost in IBMs way of writing markup.
<!-- LEADSPACE_BEGIN -->
<div class="ibm-container" id="ibm-leadspace-head">
<div class="ibm-container-body" id="ibm-leadspace-body">
<div class="ibm-columns ibm-alternate" id="ibm-lead-1">
<div class="ibm-col-1-1">
<h1>
<a href="http://www.ibm.com/mobilefirstforios?lnk=ushpls1">
<img alt="IBM and Apple partnership" height="297" width="578" src="/images/portal/R745639D06637H07/4_07152014_text.png" class="ibm-no-mobile"/>
<img class="ibm-mobile" alt="IBM and Apple partnership" height="98" width="318" src="/images/portal/R745639D06637H07/4_07152014_mobile.png"/>
</a>
@jeffwesson
jeffwesson / PygLatin
Created August 16, 2014 09:00
A Python PygLatin Translator
# Suffix
suffix = 'ay'
# Vowels
vowels = ['a', 'e', 'i', 'o', 'u', 'y']
# Supplies
supplies = ['Backpack', 'Flashlight', 'Waterproof matches', 'Rambo knife', 'Six-shooter', 'Waterproof tarp', 'Water purification straw', 'Flint', 'Rope']
# Environments
@jeffwesson
jeffwesson / formatNumber
Last active August 29, 2015 14:20
Format a given number with thousands delimited by commas
function formatNumber(num) {
if (!isNaN(Number(num))) {
var numLength = num.toString().split('').length;
if (numLength % 3 !== 0) {
// do complex shit,
// but return 0 for now
return 0;
}
var regexString = '';
var formatTemplate = '';
@jeffwesson
jeffwesson / getWishlistTotal.js
Created August 4, 2015 06:38
WIP: Get subtotal for all items in a given amazon wishlist
var divs = document.getElementsByTagName("div");
var products = [];
for (var i = 0; i < divs.length; i ++) {
if (/^item_price_/.test(divs[i].id)) {
products.push(divs[i]);
}
}
var rawPrices = [];
var priceClass = /-price\b/;
function reverseString(str) {
var chars = str.split(""),
letterNum = 1,
start = "A".charCodeAt(0),
end = "Z".charCodeAt(0),
list = [];
function opposite(char) {
var oppCharCode,
re = /[A-Za-z]/g;
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@jeffwesson
jeffwesson / bubbleSort.js
Last active April 1, 2016 06:39
BubbleSort Algorithm
const bubbleSort = function (arr) {
let store = null;
let maxProfit = 0;
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length - 1; j++) {
if (arr[j] > arr[j + 1]) {
store = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = store;
}
@jeffwesson
jeffwesson / format-ssn.html
Created April 26, 2016 05:39
ssn formatter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input type="text" id="x" maxlength="11" pattern="\d{3}\-\d{2}\-\d{4}">
<script>
@jeffwesson
jeffwesson / buy-buy-baby-total.js
Created August 9, 2017 04:35
Sums items in a baby registry on Buy Buy Baby
Array.prototype.slice.call(document.querySelectorAll('.productRow .productContainer .productContent')).reduce((a, item) => {
let o = {};
o['requested'] = parseInt(item.querySelector('.requested').innerText.replace(/\D/g, ''));
o['purchased'] = parseInt(item.querySelector('.purchase').innerText.replace(/\D/g, ''));
o['price'] = parseFloat((item.querySelector('.rlpPrice') || item.querySelector('.toalpriceLtl')).innerText.replace(/[^\d\.]/g, ''));
a.push(o);
return a;
}, []).filter(item => item.requested !== item.purchased).reduce((s, item) => {
s += item.price * item.requested - item.purchased;
return s;

Keybase proof

I hereby claim:

  • I am jeffwesson on github.
  • I am jeffwesson (https://keybase.io/jeffwesson) on keybase.
  • I have a public key ASDKTllWxBegNZqvgbMit1xzixOrXwY-6_h6lYn4Om6KbAo

To claim this, I am signing this object: