Skip to content

Instantly share code, notes, and snippets.

@timw4mail
timw4mail / time.js
Created February 8, 2013 21:59
Bookmarket for calculating time differences
javascript:(function(doc){
"use strict";
var $ = function(id){
return doc.getElementById(id);
};
var html = '<div id="tc_form_wrapper"> \
<input type="number" id="tch1" size="3" /> : <input type="number" id="tcm1" size="3" /> \
<button id="tc_plus">+</button> \
@timw4mail
timw4mail / loops.php
Created October 9, 2013 18:24
Loops and references
<?php
// Normal foreach loop
foreach($foo as $bar)
{
...
}
// Foreach with reference
foreach($foo as &$bar)
@timw4mail
timw4mail / images.php
Created November 4, 2013 21:20
mal-api script for theme images
<?php
function do_curl($url, $options=array())
{
$cookie = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init($url);
//Use the user's User Agent and Cookies
$opts= array(
CURLOPT_USERAGENT => "Tim's List Image Updater",
CURLOPT_COOKIEJAR => $cookie,
@timw4mail
timw4mail / custom_error_handler.php
Created December 18, 2013 21:22
Catching errors
<?php
/**
* Function to run on script shutdown
* -used to catch most fatal errors, and
* display them cleanly
*
* @return void
*/
function shutdown()
@timw4mail
timw4mail / GetSet.php
Created April 16, 2014 19:51
Trait for naive getter/setter methods
<?php
/**
* Trait to get rid of naive getter/setter boilerplate
*/
trait GetSet
{
/**
* Dynamically create getters/setters
@timw4mail
timw4mail / .osx
Created June 12, 2014 18:13
OS X dotfile
# ~/.osx — http://mths.be/osx
###############################################################################
# General UI/UX #
###############################################################################
# Menu bar: disable transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Always show scrollbars
@timw4mail
timw4mail / .zshrc
Created October 29, 2014 20:02
zsh config
# correction
setopt correctall
#prompt
autoload -U promptinit
promptinit
prompt clint
@timw4mail
timw4mail / ex16-extra-credit.c
Created February 4, 2015 21:34
Learn C the hard way
#include <stdio.h>
typedef struct {
char *name;
int age;
int height;
int weight;
} Person;
Person Person_create(char *name, int age, int height, int weight)
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@timw4mail
timw4mail / Javascript ES6|ES2015.md
Created October 26, 2016 13:54
Overview of useful new Javscript features

JavaScript ES6/ES2015

Block scope

  • let - assigns a new variable that can be overwritten with any type

  • const - assigns a new variable that can not be overwritten; however, non-scalar values can be modified (immutable variables, not really traditional constants)

Functions can also be block-scoped