Skip to content

Instantly share code, notes, and snippets.

View dotspencer's full-sized avatar

Spencer Smith dotspencer

View GitHub Profile
@dotspencer
dotspencer / add-env.md
Last active March 28, 2023 13:58
Three ways to add env variables to a running docker container

1. Add to image at build-time

in .gitlab-ci.yml:

docker build --build-arg VAR_NAME="$VAR_NAME"

$VAR_NAME references a stored env variable from Gitlab CI settings.

in Dockerfile:

@dotspencer
dotspencer / multiple-keys-gitlab.md
Last active March 7, 2024 15:01
Multiple Gitlab accounts with multiple ssh keys

Gitlab won't allow reuse of a public ssh key for multiple accounts. To get around this you need to create a second ssh key for the second account.

Create or modify your ~/.ssh/config file:

# normal                                                                                                                                                                  
Host gitlab.com-work_username
     HostName gitlab.com
     PreferredAuthentications publickey
 IdentityFile ~/.ssh/id_rsa
@dotspencer
dotspencer / people-index.json
Last active May 10, 2019 20:15
SWAPI all people [backup]
[
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-1.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-2.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-3.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-4.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-5.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-page-6.json",
"https://gist.githubusercontent.com/dotspencer/10f9e59cbccfd7b12b9a663a56c41f92/raw/0c2ad72be6c634f822131832f59d0eccdd6655cc/people-
@dotspencer
dotspencer / people.json
Created May 10, 2019 16:38
SWAPI people [backup]
{
"count": 87,
"next": "https://swapi.co/api/people/?page=2",
"previous": null,
"results": [
{
"name": "Luke Skywalker",
"height": "172",
"mass": "77",
"hair_color": "blond",
@dotspencer
dotspencer / films.json
Created May 10, 2019 16:34
SWAPI films [backup]
{
"count": 7,
"next": null,
"previous": null,
"results": [
{
"title": "A New Hope",
"episode_id": 4,
"opening_crawl": "It is a period of civil war.\r\nRebel spaceships, striking\r\nfrom a hidden base, have won\r\ntheir first victory against\r\nthe evil Galactic Empire.\r\n\r\nDuring the battle, Rebel\r\nspies managed to steal secret\r\nplans to the Empire's\r\nultimate weapon, the DEATH\r\nSTAR, an armored space\r\nstation with enough power\r\nto destroy an entire planet.\r\n\r\nPursued by the Empire's\r\nsinister agents, Princess\r\nLeia races home aboard her\r\nstarship, custodian of the\r\nstolen plans that can save her\r\npeople and restore\r\nfreedom to the galaxy....",
"director": "George Lucas",
@dotspencer
dotspencer / film-photos.json
Last active May 10, 2019 16:21
SWAPI photos for films
{
"4": "https://i.stack.imgur.com/5BJM3.png",
"2": "https://i.stack.imgur.com/EPTIX.png",
"1": "https://i.stack.imgur.com/ZTmBv.png",
"3": "https://i.stack.imgur.com/SHFz9.png",
"6": "https://i.stack.imgur.com/UhaOO.png",
"5": "https://i.stack.imgur.com/Nyp7G.png",
"7": "https://i.stack.imgur.com/QjkjZ.png"
}
@dotspencer
dotspencer / priority-queue.js
Last active February 21, 2019 05:39
javascript priority queue
var priorityQueue = {
first: null,
};
var nodeLookup = {};
function enqueue(name, factor) {
const node = nodeLookup[name];
// already exists in queue
@dotspencer
dotspencer / gist:a5d9a5a77c5c1eb696ad6b66c2b3b976
Created February 20, 2019 06:06
Setting up wireless printing on HP LaserJet P1102w
  1. Connect printer via USB to a Windows computer.
  2. In Windows Explorer find out the drive letter of the auto mounted HP disk
  3. Run cmd as "administrator" and type the drive letter to switch to that drive. i.e. e: and hit enter.
  4. Running dir should show SISetup.exe. If so, type SISetup.exe and hit enter.
  5. Go through the setup process and select "setup wireless" for the printer.
  6. Enter wireless network name and password and continue installation.
  7. Once complete it will prompt you to set up eprint services. Agree to this prompt.
  8. Examine your network to find the ip address of the now connected printer.
  9. Enter the ip address into your browser to connect to access it's configuration via it's embedded web server.
  10. Check the firmare version and compare it to the latest version: Google search hp laserjet p1102w firmware and download and run the firware update tool.
@dotspencer
dotspencer / copy.js
Created February 11, 2019 20:35
Simple copy from button click
document.querySelector('button').addEventListener('click', () => {
copyText('nice link');
});
function copyText(text) {
const input = document.createElement('input');
input.value = text;
document.body.appendChild(input);
@dotspencer
dotspencer / private-npm.md
Last active December 24, 2018 23:03
Setting up a private npm module using Gitlab

.babelrc needs to be converted to a babel.config.js file instead. This will allow webpack and babel to transpile the linked code and fix the "build failed SyntaxError unexpected token" problem. Further explanation: https://babeljs.io/docs/en/config-files#project-wide-configuration

Add the dependency into package.json as follows (the v1.0 can be whatever tag you'd like):

"dependencies": {
    "shared-react": "git+https://gitlab+deploy-token-###:[email protected]/<group-or-user>/<package-name>#v1.0",
    ...
}

You'll also need to generate a deploy token to fill in the placholders in the url above. Go to the repo in Gitlab and then select Settings > Repository > Deploy Token. Create a new token with the name "npm" and check the "react_repository" checkbox.