Skip to content

Instantly share code, notes, and snippets.

View CharlyJazz's full-sized avatar
🧭
I may be slow to respond.

Carlos Azuaje CharlyJazz

🧭
I may be slow to respond.
View GitHub Profile
require 'rubygems'
require 'sinatra'
require 'datamapper'
require 'dm-paperclip'
require 'haml'
require 'fileutils'
APP_ROOT = File.expand_path(File.dirname(__FILE__))
DataMapper::setup(:default, "sqlite3://#{APP_ROOT}/db.sqlite3")
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jacobjoaquin
jacobjoaquin / midi_to_freq_chart.c
Created November 27, 2010 17:28
Generates a chart of MIDI notes and associated frequencies
/* MIDI to Frequency Chart
* Jacob Joaquin <jacobjoaquin@gmail.com>
* csoundblog.com
*
* Based on Listing 1.2 of The Audio Programming Book
* Edited by Richard Boulanger and Victor Lazzarini
* Chapter 1 - Programming in C
* Richard Dobson
*/
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@bytesource
bytesource / tweetclone_sequel.rb
Created November 19, 2012 14:06
"Tweetclone" Twitter clone using Sequel (database schema taken from "Cloning Internet Applications with Ruby")
# CREATE DATABASE tweetclone WITH ENCODING 'UTF-8'
require 'sequel'
require 'logger'
# CONNECTION ================================
DB = Sequel.connect(ENV['DATABASE_URL'] ||'postgres://postgres:password@localhost/tweetclone')
# Logging SQL Queries
DB.loggers << Logger.new($stdout)
@jjulian
jjulian / backbone-carousel.html
Created November 24, 2012 23:19
A simple carousel implemented with a single Backbone view
@parth1020
parth1020 / Google Maps Simple Multiple Marker Example
Created January 8, 2013 07:04
Google Maps Simple Multiple Marker Example
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@stuaxo
stuaxo / wb_to_dict.py
Last active August 26, 2022 01:20
Output an excel workbook as a python dict.Information about the formatting/colour of cells is lost - which is OK if the sheet is sensible. Individual rows are output horizontally.Types are converted to python types.This is not comprehensive + just enough for the sheet I happen to be working with today.
import datetime
import xlrd
from pprint import PrettyPrinter
def trim_nones(li):
""" remove trailing Nones from a list """
while li and li[-1] is None:
li.pop()
@reorx
reorx / hash_ring.py
Last active August 18, 2022 14:59
Consistent hash implementation in Python.
# -*- coding: utf-8 -*-
"""
hash_ring
~~~~~~~~~~~~~~
Implements consistent hashing that can be used when
the number of server nodes can increase or decrease (like in memcached).
Consistent hashing is a scheme that provides a hash table functionality
in a way that the adding or removing of one slot
does not significantly change the mapping of keys to slots.
@chenglou
chenglou / gist:40b75d820123a9ed53d8
Last active March 13, 2024 12:14
Thoughts on Animation

Interesting part (unmounting & API) is at the end if you're not interested in the rest =).

Stress Tests

This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.

  1. Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.

  2. Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch