Skip to content

Instantly share code, notes, and snippets.

View tylor's full-sized avatar

Tylor Sherman tylor

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Plaintext Passwords</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#password').keyup(function() {
$('#plaintext').text($('#password').val());
});
Ruby bitwise swap:
a = 10
b = 3
print (a ^ b ^ a), "\n" # 3
print (b ^ a ^ b), "\n" # 10
PHP bitwise swap:
71579 photos * (2592 * 1944 px) * (2.4 inches/sqrt(240^2 + 320^2)) = 2164054206 inches = 54967 km = 1.4 times around the Earth
Number of public Flickr photos * Nokia N82 camera resolution * Nokia N82 screen pixel density
So, if you were to line up the pixels from Roland's camera next to each other and display them on a Nokia N82 screen, they would circle the Earth 1.4 times.
@tylor
tylor / searchlight_graphael_hbar_support.patch
Created May 12, 2011 18:35
Give yhahn/searchlight_graphael horizontal bar charts, depends on http://drupal.org/node/1155710
diff --git plugins/searchlight_graphael_box.inc plugins/searchlight_graphael_box.inc
index 60116c1..34394c9 100644
--- plugins/searchlight_graphael_box.inc
+++ plugins/searchlight_graphael_box.inc
@@ -30,6 +30,7 @@ class searchlight_graphael_box extends boxes_box {
'#options' => array(
'pie' => t('Pie'),
'bar' => t('Bar'),
+ 'hbar' => t('Horizontal Bar'),
'line' => t('Line'),
@tylor
tylor / gather.js
Created September 6, 2011 21:29
Log Translink bus data
/**
* Quick and dirty snippet to log bus information provided by Translink mobile pages like: http://nb.translink.ca/StopMap/50322
* Run using: $ node gather.js > log.js
*/
var exec = require('child_process').exec;
var last;
// Grab the ASP.NET_SessionId from a browser cookie.
var session = '...';
@tylor
tylor / wktFromZip.php
Created September 29, 2011 22:10
Simple PHP class to get shapefile rows using ogr
<?php
/**
* Could also look at parsing shapefiles manually: http://en.wikipedia.org/wiki/Shapefile#Shapefile_shape_format_.28.shp.29
*/
class wktFromZip {
function __construct($fid) {
// Extract zip file to tmp.
$file = file_load($fid);
@tylor
tylor / multilingual_box.inc
Created October 9, 2011 04:00
Extend boxes box, implement hook_boxes_plugins().
<?php
/**
* Simple custom text box.
*/
class multilingual_box extends boxes_box {
/**
* Implementation of boxes_content::options_defaults().
*/
public function options_defaults() {
@tylor
tylor / README.txt
Created October 25, 2011 19:20
JSLint validation in Textmate
Quick and dirty JSLint validator for Textmate:
1. Install node and npm
2. Install jslint module: npm install -g jslint
3. Create a new command named jslint for Javascript in the Bundle Editor
- Input: 'Entire Document'
- Output: 'Show as Tool Tip'
- Activation: Key Equivalent, something like Command+j
- Command(s), probably have to change your node path:
@tylor
tylor / qr.php
Created November 24, 2011 19:27
Get an email anytime someone visits this page
<?php
if (!isset($_COOKIE['mailed'])) {
$to = '[email protected]';
$subject = 'QR code was used!';
$body = print_r($_SERVER, true);
if (mail($to, $subject, $body)) {
setcookie("mailed", true);
}
}
?>
@tylor
tylor / results.txt
Created January 9, 2012 06:57
Try DanielRapp/twss.js against The Office
true - How about a big round of applause for Mr. Dwight Schrute. This is huge.
true - Come on, let's gangbang this thing and go home.
true - Hold it in your mouth if you can't swallow.
true - It was easy to get in but impossible to rise up.
false - And you were directly under her the entire time?
true - Come again.
true - I need two men on this.
false - You're hardly my first.
true - The thought of popping one of your beets into my mouth makes me want to vomit.
true - Does the skin look red and swollen.