Skip to content

Instantly share code, notes, and snippets.

View therabidbanana's full-sized avatar

David Haslem therabidbanana

  • Pathstream
  • San Francisco
View GitHub Profile
@therabidbanana
therabidbanana / how_to_tsv.md
Created January 22, 2022 17:05
How to TSV a google sheet

How to make a Google Sheet published as TSV

Step 1

Publish the sheet to the web via share menu

Screen Shot 2022-01-22 at 9 02 32 AM

Step 2

What's in a Website?

A Short Look at What Makes Up a Website

Have you ever seen a website and wondered how it was made? How does a programmer even get started building one? Well, wonder no longer - I'm going to give you a quick rundown of the building blocks for a modern website.

When you access a website via your web browser, you are connecting to another computer that gives you back a set of files that make up the website. This other computer is referred to as a "server" because it serves your browser (the

@therabidbanana
therabidbanana / fix_counts.rb
Created February 3, 2013 03:30
Migration example for our mongo
require './config/boot'
Dtime::Users::User.find_each do |user|
user.set({
follower_count: user.follower_ids.size,
following_count: user.followed_user_ids.size
})
end
desc 'clears cache'
task 'cache:clear' => 'environment' do
warn "Clearing cache.... #{$cache.flush}"
warn "Removing cache.... #{`rm -rf tmp/body`}"
end
@therabidbanana
therabidbanana / README.md
Created September 20, 2012 17:03
Allows generating signed PUT urls.

Usage:

s3 = AWS::S3.new(...) 
s3.buckets['bucket-name'].objects['object-name.jpg'].url_for(:write, content_type: 'image/jpeg')

Generates a signed request allowing a PUT /bucket-name/object-name.jpg with an image file, so that an HTTP PUT can be used instead of a presigned_post request with HTTP POST and a bunch of hidden fields.

@therabidbanana
therabidbanana / readme.md
Created August 15, 2012 15:50
Identity Map for backbone models

I read this trick on the Soundcloud blog: http://backstage.soundcloud.com/2012/06/building-the-next-soundcloud/

You can return an existing object from a javascript constructor to avoid creating a new object. I'm using this as an identity map - one instance per id. Adapted to Coffeescript and adding a feature to update the existing class with any new information (me.set(data)), it looks something like user.coffee.

You have to copy-paste the simple return super constructor into every child class. Without this the code breaks. Not sure how to solve this issue.

class Dtime.View extends Backbone.View
# Call cleanup before removing completely,
# unbind events from this and all children
leave: ->
@cleanup?()
@unbindFromAll()
@remove()
@_leaveChildren()
@_removeFromParent()
@therabidbanana
therabidbanana / README.md
Created August 1, 2012 15:19
Working with dtime api with Javascript and no jquery dependency

Code overview

To interaction with the dtime API via Javascript, you need to be able to chain together API calls in a straightforward manner.

Hypermedia APIs rely on state machine logic - given a current state, there are a number of transitions you can make (Valid HTTP verbs on the available rels)

In the code, transition(current_state, rel, opts) is our way to transition.

@therabidbanana
therabidbanana / application_controller.rb
Created July 11, 2012 14:41 — forked from gmoeck/some_controller.rb
Simplified version of the application design I'm heading toward (actually in Sinatra, but that doesn't really matter here)
class ApplicationController
# Sharing the setup of processors, since many actions will use them
# - thinking of switching this out for a facade
def trigger_processor(name, listening_controller)
processor_klass = processors[name]
processor = processor_klass.new(params)
processor.add_listener(EventNotifier.new)
processor.add_listener(listening_controller)
processor.process(current_user)
end
@therabidbanana
therabidbanana / README.md
Created May 15, 2012 20:09
Example request to dtime api

In this case, the API endpoint is dev-api.dtime.com.

http get https://dev-api.dtime.com

See a JS fiddle example:

http://jsfiddle.net/qV5kd/