Skip to content

Instantly share code, notes, and snippets.

python -c "(lambda i, m, b: [print(i * (b ** e)) for e in range(0, m)])(<INTERVAL_SECONDS>, <MAX_ATTEMPTS>, <BACKOFF_RATE>)"
@smallstyle
smallstyle / gist:3965085
Created October 27, 2012 15:30
Kindle Personal Documentの一覧に一発削除用の「×」マークを付ける
jQuery(function($) {
jQuery('#orders-div').bind('DOMNodeInserted', function(event){
var t = jQuery(event.target);
if (t.hasClass('rowHeaderCollapsed')) {
var e = t.find('span.headerStatus');
e.append(jQuery('<a>').attr('href', e.attr('id').replace(/^Row.*_/,'javascript:Fion.deleteItem("deleteItem_') + '");return false;').text('×'));
}
});
});
@smallstyle
smallstyle / gist:1949167
Created March 1, 2012 11:25
tDiary: picasa.jsで写真の表示を最新のものから表示する
diff --git a/js/picasa.js b/js/picasa.js
index 378849f..dcabbaf 100644
--- a/js/picasa.js
+++ b/js/picasa.js
@@ -149,7 +149,7 @@ $(function () {
service.getPhotos(album.gphoto$id.$t, function (photos) {
$(loading.canvas).hide();
loading.stop();
- $.each(photos, function (j, photo) {
+ $.each(photos.reverse(), function (j, photo) {
@smallstyle
smallstyle / gist:1433903
Created December 5, 2011 15:14
utf8mb4 support
diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb
index 20ed442..8497ca0 100644
--- a/lib/mysql2/client.rb
+++ b/lib/mysql2/client.rb
@@ -87,6 +87,7 @@ module Mysql2
"ucs2" => Encoding::UTF_16BE,
"ujis" => Encoding::EucJP_ms,
"utf8" => Encoding::UTF_8,
+ "utf8mb4" => Encoding::UTF_8,
}
# -*- coding: utf-8 -*-
require 'pathname'
task "default" => ["show", "unlink", "symlink"]
HOME = Pathname.new("~")
dotfiles = FileList["dot.*"].map{|f| Pathname.new( f ) }
desc "処理対象のファイルを表示"
@smallstyle
smallstyle / gist:1055901
Created June 30, 2011 09:08
use proxy in heroku logs
diff --git a/lib/heroku/client.rb b/lib/heroku/client.rb
index 9080906..2cab092 100644
--- a/lib/heroku/client.rb
+++ b/lib/heroku/client.rb
@@ -376,8 +376,15 @@ Console sessions require an open dyno to use for execution.
puts get("/apps/#{app_name}/logs").to_s
else
uri = URI.parse(url);
- http = Net::HTTP.new(uri.host, uri.port)
@smallstyle
smallstyle / gist:1016735
Created June 9, 2011 13:35
HTML5 Canvas Sample Code
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas Sample</title>
</head>
<body>
<script>
<!--
var CanvasLoadingImage = function( rgb ) {
this.initialize( rgb );
@smallstyle
smallstyle / gist:955023
Created May 4, 2011 10:04
pogoplugfs initscript
#!/bin/sh
[ "$IFACE" != "lo" ] || exit 0
mount|while read fs on mp type fstype opts
do
if echo $fs | grep -q "gvfs-fuse-daemon"; then
username=`echo $opts | sed -E "s/.*user=([^,]+).*\)/\1/g"`
if [ "$username" ]; then
sudo -u "$username" sh -c "pogoplugfs --mountpoint /media/pogoplug &"