Skip to content

Instantly share code, notes, and snippets.

Eric Miller SimplGy

Block or report user

Report or block SimplGy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SimplGy
SimplGy / renameToHash.sh
Last active Aug 21, 2019
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
View renameToHash.sh
#!/bin/bash
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
# TODO: look at paralellization for perf boost
#
# Constants
#
CHAR_COUNT=12
BLOCK_COUNT=6
@SimplGy
SimplGy / addFileToGit.js
Last active Aug 16, 2019
Usage: `addFileToGit(foo.txt, "some file contents")`. Uses the "octokit" to add a single file to your gitub repo. Adapted from a Ruby guide by http://mattgreensmith.net
View addFileToGit.js
const Octokit = require('@octokit/rest'); // https://octokit.github.io/rest.js/
// Customize this stuff:
const auth = 'your-key-generated-in-github-ui'; // PRIVATE!
const owner = 'repo-owner';
const repo = 'your-repo-name';
// Constants
const userAgent = 'git commiter v1';
const ref = 'heads/master';
@SimplGy
SimplGy / node-get-file-contents.js
Last active May 4, 2019
Node - get the contents of all the files in DIR
View node-get-file-contents.js
const fs = require('fs')
const path = require('path')
const DIR = 'input/';
const readFile = name => fs.readFileSync(name);
(async () => {
const files = fs.readdirSync(DIR)
.filter(s => s.match(/\.csv$/)) // only .csv files -- change to whatever you want.
@SimplGy
SimplGy / sort-object-keys.ts
Last active Mar 16, 2019
sort keys of an object using an array index as rank, with TypeScript
View sort-object-keys.ts
export interface SomeShape {
b: string,
c: string,
a: string,
}
// Specify your sort order here
const rank: Array<keyof SomeShape> = ['a', 'b', 'c'];
export function sortedKvpString(obj: SomeShape) {
@SimplGy
SimplGy / keybindings.json
Created Nov 11, 2018
VSCode keybindings
View keybindings.json
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+down",
"command": "-editor.action.copyLinesDownAction",
@SimplGy
SimplGy / count-dom-words.js
Last active Nov 5, 2018
This counts up all the words (innerText) at each level of the dom tree.
View count-dom-words.js
// Procedure:
countWords(document.body);
/*
* Count the text inside each element.
* Parents include all the words of their children.
View ExternalUrl.ts
@Injectable({providedIn: 'root'})
export class ExternalUrlService implements CanActivate {
canActivate({ data }: ActivatedRouteSnapshot): boolean {
window.open(data.externalUrl, '_blank');
return false;
}
}
@SimplGy
SimplGy / anchorize-jekyll-headings.js
Last active Jun 8, 2018
For every heading in your page, this adds a little anchor link `#` that you can click to get a permalink to the heading. No dependency on jQuery or anything else. Requires that your headings already have an `id` attribute set (because that's what jekyll does)To use it, just drop it in the layout you use for your blog pages. You can style `.deepL…
View anchorize-jekyll-headings.js
(function(){
'use strict';
/*
Create intra-page links
Requires that your headings already have an `id` attribute set (because that's what jekyll does)
For every heading in your page, this adds a little anchor link `#` that you can click to get a permalink to the heading.
Ignores `h1`, because you should only have one per page.
The text content of the tag is used to generate the link, so it will fail "gracefully-ish" if you have duplicate heading text.
*/
@SimplGy
SimplGy / keymap.cson
Created Apr 15, 2018
IntelliJ style keybindings for the Atom text editor
View keymap.cson
'atom-text-editor':
'cmd-backspace': 'editor:delete-line'
'cmd-up': 'editor:move-line-up'
'cmd-down': 'editor:move-line-down'
'cmd-d': 'editor:duplicate-lines'
@SimplGy
SimplGy / shades-and-lights.scss
Created Jan 22, 2018
Utility colors for SCSS
View shades-and-lights.scss
// Lights (white as a transparency)
$light10: rgba(255, 255, 255, 0.10);
$light20: rgba(255, 255, 255, 0.20);
$light30: rgba(255, 255, 255, 0.30);
$light40: rgba(255, 255, 255, 0.40);
$light50: rgba(255, 255, 255, 0.50);
$light60: rgba(255, 255, 255, 0.60);
$light70: rgba(255, 255, 255, 0.70);
$light80: rgba(255, 255, 255, 0.80);
You can’t perform that action at this time.