Skip to content

Instantly share code, notes, and snippets.

View jaymzcd's full-sized avatar
🍜
Maybe cooking some pad thai

jaymz campbell jaymzcd

🍜
Maybe cooking some pad thai
View GitHub Profile
@jaymzcd
jaymzcd / header_check.php
Created June 22, 2012 15:54
Load a url and check headers for rough 'is it ok' use
<?php
$headers = get_headers($_GET['url']);
$resp = explode(' ', $headers[0])[1];
$OK_CODES = array('200', '301', '302', '303', '307');
if(in_array($resp, $OK_CODES)) {
echo "<h1>URL IS OK</h1>";
@jaymzcd
jaymzcd / volumefader.js
Created May 25, 2012 13:56
Quick'n'Easy HTML5 volume fader on audio tag
var CONFIG = {
snd: '#sound', // jquery selector for element
fadeout_time: 100, // miliseconds for volume change
fadeout_step: 0.1, // amount to reduce by
max_volume: 1 // change to limit maximum
}
function volumeFader(end_volume, step, time, callback) {
var current_volume = $(CONFIG.snd)[0].volume;
<style type="text/css" media="screen">
body {
background: #000;
width: 1000px;
margin: 0 auto;
overflow: hidden;
}
</style>
<body>
D/AndEngine(12299): AndengineSimple.onResumeGame @(Thread: 'main')
D/SurfaceFlinger( 96): Layer::requestBuffer(this=0xa4aaf8), index=1, pid=12299, w=800, h=480 success
E/AndroidRuntime(12299): FATAL EXCEPTION: GLThread 10
E/AndroidRuntime(12299): java.lang.ExceptionInInitializerError
E/AndroidRuntime(12299): at org.andengine.opengl.vbo.attribute.VertexBufferObjectAttributeFix.glVertexAttribPointer(VertexBufferObjectAttributeFix.java:39)
E/AndroidRuntime(12299): at org.andengine.opengl.vbo.attribute.VertexBufferObjectAttributes.glVertexAttribPointers(VertexBufferObjectAttributes.java:50)
E/AndroidRuntime(12299): at org.andengine.opengl.shader.ShaderProgram.bind(ShaderProgram.java:126)
E/AndroidRuntime(12299): at org.andengine.opengl.shader.PositionColorTextureCoordinatesShaderProgram.bind(PositionColorTextureCoordinatesShaderProgram.java:89)
E/AndroidRuntime(12299): at org.andengine.opengl.vbo.VertexBufferObject.bind(VertexBufferObject.java:160)
E/AndroidRuntime(12299): at org.andengine.entity.sprite.S
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
[11:20][bowser][jaymz][~/development/www/sneekapedia]$ bundle
bash: bundle: command not found
[11:20][bowser][jaymz][~/development/www/sneekapedia]$ gem install bundler -v '~> 1.0.0'
Fetching: bundler-1.0.22.gem (100%)
Successfully installed bundler-1.0.22
1 gem installed
Installing ri documentation for bundler-1.0.22...
Installing RDoc documentation for bundler-1.0.22...
[11:20][bowser][jaymz][~/development/www/sneekapedia]$ bundle -v
Bundler version 1.1.3
@jaymzcd
jaymzcd / gist:2036652
Created March 14, 2012 13:58
cowsay.md
_________________________________
/ have you created the functional \
\ specification? /
---------------------------------
\ _
\ (_)
\ ^__^ / \
\ (oo)\_____/_\ \
(__)\ ) /
@jaymzcd
jaymzcd / sumifcolor.js
Created March 12, 2012 11:20
Sum a column in google doc spreadsheet if it matches a certain background color
function sumIfColor() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var nrows = sheet.getMaxRows();
var color_cell = Browser.inputBox("Cell with background color to use?");
var output_cell = Browser.inputBox("Output cell? (Eg. D3)");
var color_match = sheet.getRange(color_cell).getBackgroundColor();
benchmark for large instance:
HTML transferred: 65036704 bytes
Requests per second: 217.08 [#/sec] (mean)
Time per request: 460.653 [ms] (mean)
Time per request: 4.607 [ms] (mean, across all concurrent requests)
Transfer rate: 2819.80 [Kbytes/sec] received
and on our micro one:
@jaymzcd
jaymzcd / admin.py
Created February 27, 2012 11:20 — forked from ohrstrom/admin.py
event plugin / django-cms
from django.contrib import admin
from dummy.models import *
class EventAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['title']}),
('Date information', {'fields': ['date_start', 'date_end']}),
]