Skip to content

Instantly share code, notes, and snippets.

var setTextMeasure = function (contentElement, targetMeasure, maxSize, minSize) {
if (!contentElement) contentElement = document.createElement('p');
if (!targetMeasure) targetMeasure = 66;
if (!maxSize) maxSize = 16;
if (!minSize) minSize = 9;
var sizer = contentElement.cloneNode();
sizer.style.cssText = 'margin: 0; padding: 0; color: transparent; background-color: transparent; position: absolute;';
@gruber
gruber / gist:647224
Created October 26, 2010 16:26 — forked from dpk/gist:646570
Slight tweaks to dpkendal's script. Gives the BBEdit document a name (rather than "untitled <integer>", and skips the \n to \r stuff, which I don't think is necessary in recent versions of BBEdit.
tell application "Safari"
set _source to do JavaScript "window.document.documentElement.outerHTML" in document 1
set _name to name of document 1
end tell
tell application "BBEdit"
make new text window with properties ¬
{contents:_source, source language:"HTML", name:"Generated source: " & _name}
select insertion point before character 1 of text window 1
@jacobian
jacobian / models.py
Created February 15, 2011 18:11
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
@jcroft
jcroft / grid.sass
Created March 21, 2011 18:09
The grid component from my personal front-end framework. Brief demo here: http://jeffcroft.com/static/misc/grid_frameworks.mov
// REQUIRED VARS. Defaults to a 950px wide, 24-column grid that has 30px wide units and 10px wide
// gutters. If you do the fluid grid, then this 950/24/30/10px size will become the maximum size.
$grid_type: fixed !default
$grid_columns: 24 !default
$grid_column_width: 30 !default
$grid_gutter_width: 10 !default
// GENERATED VARS. You can ignore these.
$grid_full_width: $grid_columns * $grid_column_width + $grid_columns * $grid_gutter_width - $grid_gutter_width
$grid_column_width_percent: ($grid_column_width / $grid_full_width * 100) * 1%
@fling
fling / gist:956189
Created May 4, 2011 22:32
page control css
#pagewrapper {
position:absolute;
z-index:1;
top: 15px; bottom:0;
width:724px;
overflow:hidden;
height: 974px;
}
#pageflip {
@philnelson
philnelson / minetweet.php
Created August 3, 2011 18:12 — forked from gavinblair/minetweet.php
script that periodically checks the minecraft server log, and tweets when players log in/out
<?php
//run via cron every 2 minutes
$log_location = "/users/minecraft/minecraft/";
$web_viewable_location = "/var/www/gotham.extrafuture.com/public_html/";
$bot_email = "gotham@extrafuture.com";
$twittermail_account = "";
//Get the log file
@hayespotter
hayespotter / webkitten.sh
Created August 17, 2011 15:04 — forked from tomhodgins/webkitten.sh
Update WebKit to latest nightly build for OS X
#! /bin/sh
echo "Welcome to WebKitten, the WebKit updater"
echo "This process may take a few minutes"
mkdir ~/.webkitten
cd ~/.webkitten
# This sets a variable named 'LATEST' that is the
# value of the latest webkit download for OS X
LATEST=`curl -s "http://nightly.webkit.org" | sed -n 's/.*http/http/'p | sed -n 's/dmg.*/dmg/'p | sed -n 1p`
@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@NZKoz
NZKoz / aa_instructions.md
Created May 2, 2012 03:07
Back Up All Your Gmail
  • Install getmail (aptitude install getmail4)
  • Set Up Your Imap Server (tl;dr)
  • getmail
  • ruby date_based_archive.rb ~/Maildir/.Archive
{ scopeName = 'mythic';
fileTypes = ( 'mythics', 'mythicc' );
patterns = (
{ name = 'comment.block.mythic';
match = '^ (.+)';
captures = { 1 = { name = 'comment.block.mythic'; }; };
},
{ name = 'markup.heading.mythic';
match = '^(.+)\:$';
captures = { 1 = { name = 'markup.heading.mythic'; }; };