Skip to content

Instantly share code, notes, and snippets.

View brandondurham's full-sized avatar

Brandon Durham brandondurham

View GitHub Profile
@brandondurham
brandondurham / lowercase-filenames.sh
Created September 20, 2023 17:48
Lowercase all filenames in a directory.
for f in *; do mv "$f" "$f.tmp"; mv "$f.tmp" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done
@brandondurham
brandondurham / install-app-icons.sh
Created December 10, 2021 21:05
Add custom icons to several apps at once.
#!/usr/bin/env bash
# You will need to update app names, paths to apps, and the location of the
# custom app icons. Also, each app includes a `has_copied` var, and each one
# should be 1 higher than the previous. Lastly, the conditional on line 32
# should be updated to match the value of the last `has_copied`. That will
# trigger a restart of the Dock to ensure the new icons are picked up.
#
# There is likely a MUCH smarter way to pull this off. I welcome
# recommendations and optimizations!
@brandondurham
brandondurham / gist:5e127344f3fea6be5f78442966837879
Created July 30, 2018 02:57
CSS: List using a counter that starts with “0” and uses “decimal-leading-zero”
/* CSS */
.Chapters {
column-count: 2;
counter-reset: toc -1;
}
.Chapter {
counter-increment: toc;
list-style-type: none;
@brandondurham
brandondurham / Blog_decorator.js
Last active May 28, 2017 21:04
Higher-order component to ensure all static, same-domain links loaded from external sources use the router method
// To use with your component as a decorator:
import React from 'react';
import styles from './styles.css';
import Internalize from 'components/InternalLinks';
@Internalize
export default class BlogContent extends React.Component {
static propTypes = {
content: PropTypes.static.isRequired
@brandondurham
brandondurham / 0_reuse_code.js
Created March 8, 2017 16:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@brandondurham
brandondurham / swipeFunc.js
Last active August 30, 2024 03:21 — forked from localpcguy/swipeFunc.js
Updated swipe script for React
import React, { Component } from 'react';
import update from 'react-addons-update';
export default class App extends Component {
state = {
touches: {
touchstart: {
x: -1,
y: -1
import React, {Component, PropTypes} from 'react';
import Hammer from 'react-hammerjs';
import classNames from 'classnames';
export default class ScrollPanel extends Component {
static propTypes = {
items: PropTypes.array,
menuStyle: PropTypes.string,
selectedItem: PropTypes.number,
@brandondurham
brandondurham / styles.less
Last active June 24, 2024 14:48
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@brandondurham
brandondurham / convert_spaces_to_tabs.sublime-macro
Last active March 17, 2020 02:33
Convert indentation from 2 spaces to tabs in Sublime Text
// Convert 2 spaces to tabs in Sublime Text
// To add a key binding, go to "Sublime Text » Preferences » Key Bindings - User" and add the following line:
// { "keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/convert_spaces_to_tabs.sublime-macro"} }
// Change the `super+;` shortcut accordingly.
[
{
"args": {
"setting": "tab_size",
"value": 2
javascript:
__cnt__=0;
__buttons__=jQuery(".content-main .user-actions-follow-button");
__length__=__buttons__.length;
__interval__=setInterval(function () {
el=jQuery(__buttons__[__cnt__]);
if (__cnt__ === __length__) {
alert("All done!");
clearInterval(__interval__);
}