Skip to content

Instantly share code, notes, and snippets.

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 Mar 12, 2013
Download all e-mails in a specific folder into a single text file. Specific for Google Apps accounts.
View Main.java
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 Mar 12, 2013
Read ID3v2 tags from an MP3 file
View mp3tags.pl
#!/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
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.
View RegexTester.js
var isValidInt = function(str) {
var regex = /^\d+$/;
return regex.test(str);
};
@kentcdodds
kentcdodds / GitCommander.sh
Last active Dec 17, 2015
Git Command Reminder. For all the times I think "how do I do that again?"
View GitCommander.sh
#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
This is to help remind me how to do some useful UI things like centering elements in the window as the window size changes.
View ui-functions
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 Dec 18, 2015
Utility functions. Simple functions I don't want to forget.
View kent-util
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 Jun 18, 2013
Short methods to help with Java stuff
View JSchSSH.java
/************************************************
* 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 Jun 19, 2013
Utility methods for Java I don't want to think about ever again...
View Util.java
/**
* 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 Jun 20, 2013
Introduction to my Gist Blog
View KentsBlog.md

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 Dec 19, 2015
How to check whether an external resource loaded and load a local copy if it failed to load. See README.md
View README.md

Double Take Script Loader

This has been moved to an official Git repository