Skip to content

Instantly share code, notes, and snippets.

@voidfiles
voidfiles / join_text_url.py
Created February 15, 2011 07:09
Joins a piece of text with a url to form max length tweet
long_tweet = 'asdfasdf asd fasd fasdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdfasdf asdfasdfas dfasd fasd fasdf asdf asdf asdf asdf asdf asdf '
short_tweet = 'asdfasdf asd fasd fasdf asdf asdf asdf asdf asdf asdf asdf asdf'
url = "http://sia.tw/4fgs4"
def join_url(tweet, url):
max_tweet_length = 139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Z-Index Example</title>
<style>
@font-face {
font-family: 'Win95F';
src: url('data:application/font-woff2;base64,d09GMk9UVE8AAB7IAAoAAAAAfLQAAB54AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAADYHcRQZgAIpcATYCJAOFAAQGP21ldGGCBAWHeQcgG/17FeyYl7gdUKg+MzYSIWwchCaAJ1GUTdZM2f+fEtQxhLpXsjlMOBl1rtM5kVqBMp1XeGh4M/bhm1fyGODBICrJYyX3cIpIfVYz8+zf7k/1poo76F5SyxV35u42RuK58Pyzv//2ufiSI5FINEWNWcddrlPZZr353F4vNRtmfpL6FyCmfDO+2gEHHHZoxKaa7jrsXaZOHea+XXQOfP8/9vs9cxcVqniikQnZQ7JE62SzSFJJlfXTq1/snkEVLh3bgX9wrpvZrHU6h4r8an+wJ/mf+G0eKltj8Y0CE6MTzFphsWCV6tY3xQxWaSyijN4a1jYsZYEPgty2j1NBvFO5ztS8L7nCE3R9JjsC1hSKoT3X3uY/v7/vz137WW3kOP6K38nIPwlujGIbNkGXOwLg//99U20JOQ0Yh4DD0LlU0bhPcFDIsBzy6t0Td7+5d9mjCFAJA0VwEQ4h4M07M9/hM0P5S4sBznkkVa5S5dxVIbUt2bl0SRWdWndyVbjrtXoXfWko9Ixf8mAlKsgL1qjQb5oCz6Y4siXFEeB8+MN2upYd8LuBdoR/31iLxhoVBZhAB3bnZRRIIKn3s59aH/bm9DqFEgRElDEz/m5qk9vHmEbteKX0j35isACCAoJ0hS2/QNAEEf
@voidfiles
voidfiles / gist:1046748
Created June 25, 2011 18:33
Parsing Extractiv JSON Crawl Job Output
"""
Extractive is a cool new service that does some on the fly web
crawling, and machine learning stuff like Entity Extraction, Full
text extraction, and more things I don't even understand. There
on demand api was very easy to use, but I built my first crawl
job the other night, and had some trouble parsing the results.
I thought I would put this up so people can see how I fixed the
output.
"""
@yfakariya
yfakariya / MicrosoftExtensionsOptionsDeepDive.md
Created November 4, 2019 11:44
Deep dive of Microsoft.Extensions.Options in Japanese

Microsoft.Extensions.Options Deep Dive

最近は .NET Core の仕事をしています。

さて、ASP.NET Core を使っていると、とりあえず構成情報みたいなものは IOptions<TOptions> で受け取っておけみたいな雑な話を目にします。 一応 公式のドキュメント はあるのですが、正直読んでもよくわからない。柔軟なんだねー、なるほどねーみたいな感じになりました。なので、ここではできる限り(?)網羅的に解説してみようと思います。

  • IOptions<TOptions> って何?(TOptions を直接注入すればいいじゃん)
  • IOptionsSnapshot<TOptions> とかたくさんあってよくわかんない
  • オプションの動的更新に必要なものは?
@tauzen
tauzen / money.py
Last active May 5, 2024 17:23
Python DDD - Value Object idea. Immutable attributes, methods, structural equality.
from collections import namedtuple
class Money(namedtuple('Money', ['amount', 'currency'])):
def add(self, amount):
return Money(self.amount + amount, self.currency)
m = Money(20, 'USD')
print(m)
# Money(amount=20, currency='USD')
@voidfiles
voidfiles / gist:1390075
Created November 23, 2011 22:10
Flickr's Pre-script loading event handler code
(function(F) {
var registered_ids = {},
id_to_module_map = {},
interim_actions = {},
cleanup_actions = {},
clicked_ids = {},
queueing = true;
function register_id(id, callbacks, required_module) {
id = id.replace('*', '.*');
@voidfiles
voidfiles / flickr_action_queue.js
Created November 25, 2011 22:43
Flickrs actionQueue code isolated
(function(F) {
var registered_ids = {},
id_to_module_map = {},
interim_actions = {},
cleanup_actions = {},
clicked_ids = {},
queueing = true;
function register_id(id, callbacks, required_module) {
id = id.replace('*', '.*');
@voidfiles
voidfiles / gist:1394631
Created November 25, 2011 23:09
Flickr actionQueue fav handler
F.actionQueue.register('button-bar-fave', {
interim: function(id) {
var fave_button = document.getElementById(id);
if (fave_button.className.search(/fave/) === -1) {
fave_button.className = 'Butt ywa-track fave-button fave';
} else {
fave_button.className = 'Butt ywa-track fave-button';
}
},
cleanup: function(id) {
@voidfiles
voidfiles / flickr_favorite_button.html
Created November 25, 2011 23:22
Flickr Favorite Button
<a href="#" class="Butt ywa-track fave-button fave" id="button-bar-fave" data-ywa-name="Favorites star" onclick="return F.actionQueue.queue_click(this.id);" tabindex="4">
<span class="ie-hack">&nbsp;</span>
<span class="star"></span> &nbsp;Favorite
</a>
@voidfiles
voidfiles / gist:1394697
Created November 25, 2011 23:49
An article about flickrs pre-script event handler
Production Tear Down
How does flickr handle the problems of loading scripts asynchrounsly.
Wether, or not you are using an asynch loader, or you are puting your script loading at the bottom of your dom you have a problem. In some cases your scripts will load after the user has clicked on something that requires there to be a javascript function to handle the click.
If you have built out a fully accessible site you might have a non-js flow, but that is usually substandard if the user has javascript, and it just is taking to long for your scripts to load. What you need some way of handling events before all of your scripts have finished loading.
First we I am going to take a look at how flickr does this, and then I want to break down a more generic way of doing this.