Skip to content

Instantly share code, notes, and snippets.

View ryan5500's full-sized avatar

Tomoaki Sano ryan5500

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
$(function() {
//invoke here when dom is ready
alert($('#main').text());
});
</script>
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
$(function() {
alert($('div').filter('.hide').text());
alert($('div').find('.hide').text());
});
</script>
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
//which is called early, ajaxStop or load?
$(function() {
$('#log').ajaxStop(function() {
$(this).text('trigger ajaxStop');
alert($('#result').text()); //this method is later
@ryan5500
ryan5500 / drop_test.html
Created April 20, 2010 19:36
jquery-ui droppable bug
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="drop_test.js"></script>
<style>
#ans_container {
width: 400px;
height: 400px;
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript">
$(function() {
var zoom_ratio = 1;
//set original coords
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript">
$(function() {
var zoom_ratio = 1;
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript">
$(function() {
$('#content').offset({top: $('#view_window').width() / 2, left: $('#view_window').height() / 2});
$('#view_window').click(function(event) {
@ryan5500
ryan5500 / panning.html
Created May 1, 2010 09:05
zooming interface prototype
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript">
$(function() {
var zoom_ratio = 1;
$('#content').offset({top: $('#view_window').width() / 2, left: $('#view_window').height() / 2});
@ryan5500
ryan5500 / dom_object.js
Created May 12, 2010 08:01
DOM <-> Object bridge with jQuery.fn.extend (Alex Sexton's way)
(function($) {
//papa crock's code
if (typeof Object.create !== 'function') {
Object.create = function(o) {
var F = function(){};
F.prototype = o;
return new F();
};
}
@ryan5500
ryan5500 / main.rb
Created January 19, 2012 02:39
get ruby process pid using pty lib
#!/usr/bin/env ruby
# conding: utf-8
#
# this script shows pid which contains 'ruby'
#
require 'pty'
cmd = 'ps aux | grep ruby'
PTY.spawn(cmd) do |reader, writer, pid|