Skip to content

Instantly share code, notes, and snippets.

View JesseHerrick's full-sized avatar

Jesse Herrick JesseHerrick

View GitHub Profile
@JesseHerrick
JesseHerrick / gist:5893906
Created June 30, 2013 04:56
Perfect CSS Center
.centered {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
@JesseHerrick
JesseHerrick / replace.cpp
Last active December 19, 2015 12:19
A simple replace example written in C++. Plus... fancy error control!
#include <iostream>
#include <string>
using namespace std;
// declare main function with argv abilities
int main(int argc, char* argv[]) {
// first string
string statement;
@JesseHerrick
JesseHerrick / gist:6025141
Created July 17, 2013 22:32
Formula for vertically centering things with CSS.
.center {
width: 500px;
position: absolute;
left: 50%;
margin-left: -250px; /* Exactly half of the width. */
}
/*
Full Formula:
margin-left = width/2 if left = 50%
@JesseHerrick
JesseHerrick / gist:6118385
Created July 31, 2013 00:46
Get URL parameters.
var params = function () {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}()
@JesseHerrick
JesseHerrick / it's_dynamite!.txt
Last active December 22, 2015 14:29
The notes for my presentation on dynamite.
Intro:
- Name + Music
# Quote!
"If I have a thousand ideas and only one turns out to be good, I am satisfied." - Alfred Nobel
- One good idea is better than none!
- About Dynamite
- Created by Alert Nobel
- Yes, he also instituted the Nobel Peace Prize.
@JesseHerrick
JesseHerrick / _config.yml
Created October 13, 2013 18:54
Example config file for jekyll-ftp.
name: Your New Jekyll Site
markdown: redcarpet
pygments: true
username: UserName
server_url: ftp.myserver.com
remote_dir: /public_html
@JesseHerrick
JesseHerrick / exec.js
Created October 20, 2013 02:36
Execute a shell command with Node.js.
// Code:
var exec = require('child_process').exec;
var execute = function(command, callback){
exec(command, function(error, stdout, stderr){ callback(stdout); });
};
// Example:
execute("git --version", function(version){
console.log(version);
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JesseHerrick
JesseHerrick / googl.rb
Created November 9, 2013 01:56
Basic HTTParty post command.
require 'json'
require 'httparty'
class Googl
include HTTParty
base_uri "https://www.googleapis.com"
headers "Content-Type" => "application/json"
def self.shorten(url)
post("/urlshortener/v1/url", :body => {:longUrl => url}.to_json)["id"]
@JesseHerrick
JesseHerrick / gist:7649549
Created November 25, 2013 21:51
Fix ZSH error with RVM.
rm -f ~/.zcompdump