Skip to content

Instantly share code, notes, and snippets.

View kentcdodds's full-sized avatar
🤓
working hard to make the world better with software

Kent C. Dodds kentcdodds

🤓
working hard to make the world better with software
View GitHub Profile
@kentcdodds
kentcdodds / Main.java
Created March 12, 2013 21:28
Download all e-mails in a specific folder into a single text file. Specific for Google Apps accounts.
package com.kentcdodds.gmailretriever.main;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@kentcdodds
kentcdodds / mp3tags.pl
Created March 12, 2013 23:58
Read ID3v2 tags from an MP3 file
#!/usr/bin/perl
use MP3::Tag;
$mp3 = MP3::Tag->new(@ARGV[0]); # create object
$mp3->get_tags(); # read tags
print "Attempting to print tags for @ARGV[0]\n";
@kentcdodds
kentcdodds / RegexTester.js
Created May 17, 2013 15:42
Common regex tests. I'll just put them here so I can easily copy them later when I don't want to make my brain figure it out again.
var isValidInt = function(str) {
var regex = /^\d+$/;
return regex.test(str);
};
@kentcdodds
kentcdodds / GitCommander.sh
Last active December 17, 2015 11:49
Git Command Reminder. For all the times I think "how do I do that again?"
#Set a new remote origin url
git remote set-url origin git://new.url.here
#Add an alternate remote:
git remote add <remote-name> <url>
#Make the server look just like local
git push -f <remote> <branch>
#Make local look just like the server
@kentcdodds
kentcdodds / ui-functions
Created May 20, 2013 13:33
This is to help remind me how to do some useful UI things like centering elements in the window as the window size changes.
var centerElement = function ($element) {
$element.css("position","absolute");
$element.css("top", Math.max(0, (($(window).height() - $($element).outerHeight()) / 2) + $(window).scrollTop()) + "px");
$element.css("left", Math.max(0, (($(window).width() - $($element).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
return $element;
}
/*
Invoke this like this:
$(window).resize(function() {
@kentcdodds
kentcdodds / kent-util
Last active December 18, 2015 00:09
Utility functions. Simple functions I don't want to forget.
var capitaliseFirstLetter = function(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
};
/*
* Detect IE. From http://stackoverflow.com/a/16657946
* ----------------------------------------------------------
* If you're not in IE (or IE version is less than 5) then:
* ie === undefined
* If you're in IE (>=5) then you can determine which version:
@kentcdodds
kentcdodds / JSchSSH.java
Created June 18, 2013 17:52
Short methods to help with Java stuff
/************************************************
* Execute commands
************************************************
*/
private String executeCommand(ChannelExec channel, String... commands)
throws IOException, JSchException {
InputStream in = channel.getInputStream();
StringBuilder output = new StringBuilder();
for (int i = 0; i < commands.length; i++) {
@kentcdodds
kentcdodds / Util.java
Created June 19, 2013 12:01
Utility methods for Java I don't want to think about ever again...
/**
* Simulates javascript's .join function.
*/
public static String combine(String glue, String... stringsToCombine) {
int arryLength = stringsToCombine.length;
if (arryLength == 0) {
return null;
}
StringBuilder out = new StringBuilder();
@kentcdodds
kentcdodds / KentsBlog.md
Created June 20, 2013 12:35
Introduction to my Gist Blog

Gist Blog by Kent Dodds

I have decided to stop using WordPress and move completely over to Gists and Google+. Whenever I want to make a post about code, I'll post it to Gist. Whenever I want to make another kind of post, I'll post it to Google+ with the hashtag #blogpost. Doing this will make life easier and I wont have to manage a CMS like WordPress or anything. It'll be great :) So what are you waiting for? Go ahead and read my Gist Blog and checkout my Google+ Blog Posts :)

@kentcdodds
kentcdodds / README.md
Last active December 19, 2015 10:29
How to check whether an external resource loaded and load a local copy if it failed to load. See README.md

Double Take Script Loader

This has been moved to an official Git repository