Skip to content

Instantly share code, notes, and snippets.

@chuckbjones
chuckbjones / deploy.rb
Created August 22, 2012 07:51
Generate static html files at deploy time in Rails 3.x
# define a method to run rake tasks
def run_rake(task, options={}, &block)
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'production')
command = "cd #{current_path} && #{rake} #{task} RAILS_ENV=#{rails_env}"
run(command, options, &block)
end
@chuckbjones
chuckbjones / ppmread.c
Last active December 16, 2015 05:29
ppmread - display a pgma or ppm file using OpenGL.
/*****************************************************************************
* Charles Jones
* 2013-04-14
* ppmread - display a pgma or ppm file using OpenGL
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@chuckbjones
chuckbjones / linkchecker input
Last active December 20, 2015 20:59
Linkchecker error
<html>
<body>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=1466-822X&site=1">1</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0016-7363">2</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0435-3684&site=1">3</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0197-9183&site=1">4</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0020-7985">5</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0016-7398&site=1">6</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=1320-5331&site=1">7</a>
<a href="http://www.blackwellpublishing.com/journal.asp?ref=0305-0270&site=1">8</a>
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
# Forked from the original to do the opposite: Switch ssh repo urls to https
# Original here: https://gist.github.com/m14t/3056747
# Thanks to @m14t
#origin or upstream
REMOTE=${1-origin}
REPO_URL=`git remote -v | grep -m1 "^$REMOTE" | sed -Ene's#.*(git@github.com:[^[:space:]]*).*#\1#p'`
@chuckbjones
chuckbjones / qf.py
Created February 17, 2015 19:04
Quadratic Formula in Python
#!/usr/bin/env python
import math
import sys
def quad(a, b, c):
disc = b**2 - 4*a*c
if disc < 0:
return None, None
disc_sqrt = math.sqrt(disc)
res_p = ((-b + disc_sqrt) / (2*a))