Skip to content

Instantly share code, notes, and snippets.

View timdorr's full-sized avatar
🚪

Tim Dorr timdorr

🚪
View GitHub Profile
*:hover {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
@timdorr
timdorr / disco.js
Last active May 3, 2018 22:08
Disco mode!
function disco() {
var elements = document.getElementsByTagName('*');
for (var i = elements.length - 1; i >= 0; i--) {
var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
elements[i].style.color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
var r = Math.floor(Math.random()*256);
@timdorr
timdorr / tesla_stream_reader.rb
Created November 14, 2013 21:28
Stream data from Tesla's API to TempoDB
class TeslaStreamReader
def initialize(email, password)
@tesla_api = TeslaApi.new(email, password)
end
def stream_to_tempodb
loop do
@tesla_api.vehicles.first.wake_up
car = @tesla_api.vehicles.first
@timdorr
timdorr / IRB.rb
Created November 25, 2013 19:38
A basic self-referential friendship model in Rails 4.0.1
2.0.0p247 :002 > u = User.create!(name:"test")
(0.4ms) BEGIN
SQL (44.1ms) INSERT INTO "users" ("created_at", "name", "updated_at") VALUES ($1, $2, $3) RETURNING "id" [["created_at", Mon, 25 Nov 2013 19:35:06 UTC +00:00], ["name", "test"], ["updated_at", Mon, 25 Nov 2013 19:35:06 UTC +00:00]]
(0.8ms) COMMIT
=> #<User id: 1, name: "test", created_at: "2013-11-25 19:35:06", updated_at: "2013-11-25 19:35:06">
2.0.0p247 :003 > u.friends
User Load (2.2ms) SELECT "users".* FROM "users" INNER JOIN "friendships" ON "users"."id" = "friendships"."friend_id" WHERE "friendships"."user_id" = $1 [["user_id", 1]]
=> #<ActiveRecord::Associations::CollectionProxy []>
@timdorr
timdorr / deploy.rake
Created June 19, 2014 23:11
Rollbar Deploy Rake Task
namespace :deploy do
desc "Tell Rollbar about the deploy"
task :rollbar => :environment do
git_revision = `git log -n 1 --pretty=format:"%H"`
git_user = `git log -1 --pretty=%an`
git_message = `git log -1 --pretty=%B`
res = HTTParty.post("https://api.rollbar.com/api/1/deploy/", body: {
access_token: Rollbar.configuration.access_token,
environment: "production",
@timdorr
timdorr / keybase.md
Created September 18, 2014 14:25
keybase.md

Keybase proof

I hereby claim:

  • I am timdorr on github.
  • I am timdorr (https://keybase.io/timdorr) on keybase.
  • I have a public key whose fingerprint is 96B2 2FEB 89BC BA32 C41B 6161 990C 41F1 D712 B089

To claim this, I am signing this object:

@timdorr
timdorr / railsconf_schedule.rb
Last active August 29, 2015 14:19 — forked from sionide21/railsconf_schedule.rb
Make the Schedule Items at http://railsconf.com/schedule clickable to add to your Google Calendar
var authuser = 2; // Change if you have multiple Google accounts logged in. This is zero-indexed.
$("<script/>", {type: "text/javascript", src: "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"}).appendTo(document.body);
$(".session-content a").on("click", function() { event.stopPropagation(); });
$(".session-content").on("click", function() {
var session = $(this),
title = session.find(".session-title"),
details = title.find("a")[0].href,
speaker = session.find(".speaker-name"),
@timdorr
timdorr / fetch_data.js
Created November 13, 2015 16:36
Prefetching Data Decorator
import React, { Component, PropTypes } from 'react';
import hoistStatics from 'hoist-non-react-statics';
const { shape, func } = PropTypes;
let initialRender = true;
export function rendered() {
initialRender = false;
}
@timdorr
timdorr / .gitconfig
Created January 26, 2016 15:57
.gitconfig aliases
[alias]
st = status -sb
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
up = !git fetch origin && git rebase origin/master
mup = !git fetch origin && git merge origin/master
done = "!git checkout master && git pull && git fetch -p && git branch --merged | grep -Pv '\\*|master' | xargs -n 1 git branch -d"
@timdorr
timdorr / reroutes.js
Last active January 27, 2016 21:40
An idea for a new kind of router in React.
import App from 'components/App'
import Page1 from 'components/Page1'
import Page2 from 'components/Page2'
import Tab1 from 'components/Tab1'
import Tab2 from 'components/Tab2'
export default const routes = (
<App path="/">
<Page1 path="page1">
<Tab1 path="tab1" />