Skip to content

Instantly share code, notes, and snippets.

View clamstew's full-sized avatar
🤷

Clay Stewart clamstew

🤷
View GitHub Profile
@clamstew
clamstew / index.js
Created March 7, 2022 04:58
trying out the Dictionary and isInDict() function from youtube video
const Mocha = require('mocha');
const assert = require('assert');
const mocha = new Mocha();
// Bit of a hack, sorry!
mocha.suite.emit('pre-require', this, 'solution', mocha);
/*
from: https://www.youtube.com/watch?v=yju4zwKSriI
@clamstew
clamstew / Pig Latin Translator.js
Last active February 28, 2022 03:12
Found a problem on coderpad for pig latin translator
var Mocha = require('mocha');
var assert = require('assert');
var mocha = new Mocha();
mocha.suite.emit('pre-require', this, 'solution', mocha);
//===============
const stringOne = "pig";
const stringTwo = "pig latin";
const stringThree = "Pig Latin";
const longerPhrase = "Clay goes to the park to look for acorns."
@clamstew
clamstew / index.html
Created January 19, 2021 07:26 — forked from kahole/index.html
*scratch*.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>*scratch*</title>
<style>
body {
font-family: Hack, Menlo, Monaco, 'Droid Sans Mono', 'Courier New', monospace;
white-space: pre;

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@clamstew
clamstew / github-to-bitbucket
Created January 24, 2020 17:40 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@clamstew
clamstew / show_git_branches_for_subfolders.sh
Created October 4, 2019 04:22
show_git_branches_for_subfolders.sh - so you can see what branches each git project folder is on in a parent folder
#!/bin/bash
# from https://unix.stackexchange.com/questions/183361/get-git-branch-from-several-folders-repos
# function git_branches()
# {
if [[ -z "$1" ]]; then
echo "Usage: $0 <dir>" >&2
return 1
fi
import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { TOGGLE } from "./UiReducer";
const Toggle = () => {
const ui = useSelector(state => state.ui);
const dispatch = useDispatch();
return (
<div>
<div>{JSON.stringify(ui)}</div>
@clamstew
clamstew / react-change-logger.js
Created May 14, 2019 23:08
detect prop changes in react apps for debugging
MyComp extends PureComponent {
lastProps = {};
whatChanged() {
Object.keys(this.props)
.filter(key => {
return this.props[key] !== this.lastProps[key];
})
.map(key => {
console.log("changed property:", key, "from", this.lastProps[key], "to", this.props[key]);
});
@clamstew
clamstew / Api.js
Last active March 7, 2019 07:00
A module to make hacker news requests
import axios from 'axios';
// Default API will be your root
const API_ROOT = process.env.URL || 'http://localhost:3000/';
const TIMEOUT = 20000;
const HEADERS = {
'Content-Type': 'application/json',
Accept: 'application/json',
};
@clamstew
clamstew / New South Tech Blog Post.md
Last active January 21, 2019 02:47
New South Tech Blog Post

jQuery .data() object and HTML5 data- attributes

Post on December 29, 2012 by Clay Stewart tagged: code samples, data-attributes, html5, jquery

Play with the final result of this post on this fiddle and fork it: http://jsfiddle.net/BmXWv/

I’ve been toying around with adding data-* attributes to my DOM to carry certain information on page load that can be picked up with javascript functions for certain user actions or in ajax calls, and I had trouble finding good resources for this out on the internet.

On finally conquering this .data() function (getting & setting data with it), I thought I would add to the conversation with a blog post in case others out there on the interwebs are having similar issues. This jsFiddle http://jsfiddle.net/drZmc/ spurred on my final result.