Skip to content

Instantly share code, notes, and snippets.

@danharper
danharper / TimeZones.php
Last active July 5, 2016 22:10
Generates a list of all timezone identifiers, with their offset & made (slightly) more human-readable
<?php
class TimeZones {
/**
* @return array
*/
public function generate()
{
$identifiers = DateTimeZone::listIdentifiers();
// https://twitter.com/ReactJSTraining/status/743567989434286080
// https://codepen.io/ReactJSTraining/pen/MeePdW?editors=0010
const { render, findDOMNode } = ReactDOM
////////////////////////////////////////////////////////////
// Only code you need to change is inside this component
class PinToBottom extends React.Component {
static propTypes = {
@danharper
danharper / example.php
Created January 23, 2014 11:51
Laravel/Eloquent Single Table Inheritance Trait
<?php
class Category extends Eloquent {
use EloquentSingleTableInheritenceTrait;
protected function singleTableInheritanceMpa()
{
return [
1 => 'InventoryCategory',
@danharper
danharper / BorderedInput.js
Last active May 16, 2016 20:31
BorderedInput, with Material design style focus animation. Preview: https://i.imgur.com/Fek7rXF.gif
// note there may be a better way to abuse flexbox than this :)
var React = require('react-native')
var { View, TextInput } = React
var BorderedInput = React.createClass({
getInitialState() {
return { i: 0 }
},
export type Options = {
blockSelector: () => string,
linkSelector: (id: string) => string,
classToToggle?: () => string,
toggleClass?: (el: Element, isInView: boolean, classToToggle: string) => void,
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="main"></div>
<?php
$x = false or true;
// => true
var_export($x);
// => false

$y = false || true;
// => true
var_export($y);
@danharper
danharper / download.sh
Created August 9, 2013 11:45
Download all UoP graduation photos from July 19th at 2:30. Switch the initial number for other days.
wget https://www.successphotography.com/traceimagefreepp.php?gpr=131196571000{1..9}&gpi= && \
wget https://www.successphotography.com/traceimagefreepp.php?gpr=13119657100{10..99}&gpi= && \
wget https://www.successphotography.com/traceimagefreepp.php?gpr=1311965710{100..342}&gpi=
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@danharper
danharper / classifier.js
Last active December 17, 2015 11:39
Portsmouth University Classification Calculator
/*
run with:
portsmouthClassifier.classify(marks);
*/
var portsmouthClassifier = (function() {
var totalCredits = function(year) {
return _.reduce(year, function(memo, unit) {
return memo + unit.credits;