Skip to content

Instantly share code, notes, and snippets.

View Demeter's full-sized avatar

demeter Demeter

  • 22:54 (UTC -07:00)
View GitHub Profile
@Demeter
Demeter / textWidth.js
Created February 3, 2014 17:11 — forked from gka/textWidth.js
Approximating the width of a string in JavaScript
var textWidth = (function() {
function charW(w, c) {
if (c == 'W' || c == 'M') w += 15;
else if (c == 'w' || c == 'm') w += 12;
else if (c == 'I' || c == 'i' || c == 'l' || c == 't' || c == 'f') w += 4;
else if (c == 'r') w += 8;
else if (c == c.toUpperCase()) w += 12;
else w += 10;
return w;
}
I took the top suggestion out of google suggest, try it for yourself.
http://www.google.com/webhp?complete=1&hl=en
does god... exist
why are religions... different
why are jews... hated
why are muslims... so violent
why are christians... so judgemental
why are buddhists... vegetarian
why cant we.. be friends
@Demeter
Demeter / sothebys.rb
Created September 17, 2011 00:41 — forked from henrik/sothebys.rb
Sotheby's full-size image ripper
#!/usr/bin/env ruby
# Sothebys full-size image ripper.
# Gets the full-size images from the lots listed after __END__.
# By Henrik Nyh <http://henrik.nyh.se> 2010-12-23 under the MIT license.
require "open-uri"
# We get an error page if we do not specify a user agent.
USER_AGENT = "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)"
@Demeter
Demeter / ip-uploader.py
Created September 18, 2011 05:16 — forked from PHLAK/ip-uploader.py
Connects to whatismyip.com, obtains your external IP address and uploads a text file containg the IP to a chosen FTP server. Requires Python to run.
#! /usr/bin/env python
import httplib
import sys
import os
import ftplib
# File IP will be output to
file="ip.txt"
# Replace server, user, and password with your login information
@Demeter
Demeter / file.md
Created September 18, 2011 05:31 — forked from quirkey/file.md
From Tessy to everyone

Hello How are you today, I hope all is well with you .I am sorry to worry you with my proposal for a relationship with you, but I know that you will grant my request in good faith and understanding, My name is Tessy I just went through your profile today at (github.com) and i have no options than letting you know that i am interested in having a relationship with you, I will also like to Know you the more, you can send an email to my email address so that I can send you more details about my self including my picture. I believe we can move from here. But bear in mind that love has no colors barrier, no educational back ground barrier, no socio-economic barrier, religious, language, nationality or distance barrier, the only important thing there is love. I am waiting for your mail to my email address above. Yours sincerely.

Tessy,

@Demeter
Demeter / user_flask_appengine.py
Created September 19, 2011 23:54 — forked from code/user_flask_appengine.py
googappapiflaskIDs
from flask import g, session
from google.appengine.api import users
class GuestUser(object):
def email(self):
return None
def nickname(self):
return 'Guest'
@Demeter
Demeter / unshortenurl.py
Created September 20, 2011 00:14 — forked from zhasm/unshortenurl.py
Restore shortened URLs
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
@Demeter
Demeter / stackoverflow_tagged_quest.php
Created October 14, 2011 18:12 — forked from lplume/stackoverflow_tagged_quest.php
mini wrapper web based, look for questions w/ tagged and min score given
<?php
/*
* uri param to this "web script"
* q = tag values split by a semicol
* minscore = min score (int)
*
* it's a lil bit nasty, but can modify so easy, the same to turn into a shell script
*/
$url = "http://api.stackoverflow.com/1.0/questions?tagged=".urlencode($_GET["q"]);
@Demeter
Demeter / data.yml
Created October 14, 2011 18:20
Populate the database
# 5000 users for populating database.
# names taken from http://www.census.gov/genealogy/names/names_files.html
#
# def user_data
# $user_data ||= YAML.load_file('data.yml').collect{|permalink, u| u }
# $user_data[rand($user_data.size)]
# end
eduardo-yuhas:
:email: eduardo.yuhas@example.com
Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
Extended version of same pattern:
(?xi)
\b
( # Capture 1: entire matched URL