Skip to content

Instantly share code, notes, and snippets.

@chuckbjones
chuckbjones / deploy.rb
Created Aug 22, 2012
Generate static html files at deploy time in Rails 3.x
View deploy.rb
# 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
View fix_github_https_repo.sh
#/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'`
View linkchecker input
<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>
@chuckbjones
chuckbjones / ppmread.c
Last active Dec 16, 2015
ppmread - display a pgma or ppm file using OpenGL.
View ppmread.c
/*****************************************************************************
* 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 / qf.py
Created Feb 17, 2015
Quadratic Formula in Python
View qf.py
#!/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))
View ForegroundLinearLayout.java
/*
* 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