Skip to content

Instantly share code, notes, and snippets.

View tomshaw's full-sized avatar
🎯
Focusing

Tom Shaw tomshaw

🎯
Focusing
View GitHub Profile
@jonlabelle
jonlabelle / string-utils.js
Last active July 8, 2024 21:19
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@tomshaw
tomshaw / Select.js
Created July 10, 2016 23:41
Basic React Select
"use strict";
var React = require('react');
var Select = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired,
@markhowellsmead
markhowellsmead / css-mixblendmode.js
Created September 28, 2016 14:35
Detect browser support for CSS' mix-blend-mode using JavaScript
if (typeof window.getComputedStyle(document.body).mixBlendMode === 'undefined') {
document.documentElement.className += " mix-blend-mode-no";
}
@ljharb
ljharb / array_iteration_thoughts.md
Last active July 27, 2024 16:17
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

'use strict';
// Dependencies
const gcloud = require('google-cloud', {
projectId: 'sara-bigquery',
keyfileName: 'keyfile.json'
});
const vision = gcloud.vision();
const fs = require('fs');
const async = require('async');
/*
Problem:
['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris']
// YOUR ALGORITHM
@bradtraversy
bradtraversy / docker-help.md
Last active July 9, 2024 10:18
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@tomshaw
tomshaw / content.js
Created September 26, 2019 11:01
Chrome extension scan web page and highlight key words.
// Thoroughly untested.
let searchTerms = ['law', 'software', 'news', 'health'];
let elems = document.querySelectorAll("h1, h2, h3, h4, h5, h6, li, p, a")
for (let i = 0, total = elems.length; i < total; i++) {
let element = elems[i];
if (element && element.innerText) {
let innerText = element.innerText;
for (let j = 0; j < searchTerms.length; j++) {
PS1='\[\033]0;WSL2 Bash\W\007\]' # set window title
PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[36m\]' # change to green
PS1="$PS1"'bash@bexgboost ' # user@host<space>
PS1="$PS1"'\[\033[31m\]' # change to brownish yellow
PS1="$PS1"'\W' # current working directory
source /usr/lib/git-core/git-sh-prompt
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;36m\]\u:\[\033[01;31m\]\w\[\033[33m\]\$(__git_ps1)\[\033[33m\]"