Skip to content

Instantly share code, notes, and snippets.

@yasuoza
yasuoza / gist:1858167
Created February 18, 2012 08:12
Bing translation API based on JSONP
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Microsoft Translate</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function () {
$('#trans').on('click', function (e) {
e.preventDefault();
var loading = $('p#loading').toggle(),
@yasuoza
yasuoza / index.html
Created February 20, 2012 07:43
jQuery Ticker code
<ul id="ticker">
<li class="bd">
<p id="slide">
<span>
2012/01/24&nbsp;
<a href="http://www.google.com">text00</a>
</span>
<span>
2011/11/08&nbsp;
@yasuoza
yasuoza / gist:1868414
Created February 20, 2012 08:25
User Agent distinction
function is_mobile () {
var useragents = [
'iPhone', // Apple iPhone
'iPod', // Apple iPod touch
'Android', // 1.5+ Android
'dream', // Pre 1.5 Android
'CUPCAKE', // 1.5+ Android
'blackberry9500', // Storm
'blackberry9530', // Storm
'blackberry9520', // Storm v2
@yasuoza
yasuoza / converter.rb
Created June 10, 2012 05:10
Retina image converter
require 'rubygems'
require 'RMagick'
convertedCnt = 0
ARGV.each do |filename|
img_type = File.extname(filename).downcase
if (img_type==".png")||(img_type==".jpg")||(img_type==".tif")
ext = File.extname(filename)
base = File.basename(filename,ext)
@yasuoza
yasuoza / retina_image_resizer.rb
Created June 10, 2012 06:04
Resize retina images.
#!env ruby
require 'rubygems'
require 'RMagick'
images_dir = ARGV[0]
if images_dir == nil
puts "Error! Input images directory"
exit
end
@yasuoza
yasuoza / image_checker.pl
Created June 10, 2012 10:39
Image file exist checker.
#!env perl
use strict;
use warnings;
use feature qw/say/;
use Text::CSV_XS;
use DateTime;
#CSV file
@yasuoza
yasuoza / image_renamer.rb
Created June 13, 2012 06:47
Convert normal image name to retina image name
#!env ruby
require 'rubygems'
require 'fileutils'
images_dir = ARGV[0]
if images_dir == nil
puts "Error! Input images directory"
exit
@yasuoza
yasuoza / index.html
Created July 1, 2012 06:38
Lazy social button loading
<!DOCTYPE html>
<html>
<head>
<title>Lazy share button</title>
</head>
<body>
<h3>MouseOver below this label.</h3>
<h4>URL: <a href="http://jquery.com">http://jquery.com</a></h4>
<div class="lazy-share-widget" id="sharing-ENTRY_ID" style="height:460px;width:320px">
@yasuoza
yasuoza / graph.txt
Created August 6, 2012 07:22
Nine Algorithms that Changed the Future -Random surfer trick algorithm-
0 1
1 4
2 0
3 0
4 0
@yasuoza
yasuoza / application.rb
Created August 16, 2012 08:32
Rails customize error Message HTML
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
errors = Array(instance.error_message).join(',')
%(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
end