Skip to content

Instantly share code, notes, and snippets.

View hiromitz's full-sized avatar

Hiro Miyanishi hiromitz

View GitHub Profile
@hiromitz
hiromitz / s3link.php
Last active August 29, 2015 13:56
Generate Expiring Amazon S3 Link with Custom File Name
@hiromitz
hiromitz / jquery.escapeHTML.js
Created September 24, 2010 03:47
escape html
;(function($){
$.escapeHTML = function(val) {
return $("<div/>").text(val).html();
};
})(jQuery);
@hiromitz
hiromitz / Abstract.php
Created November 16, 2010 02:04
Abstract Model class
<?php
/**
* Abstract Model class
*/
abstract class Abstract
{
/**
* stored values
@hiromitz
hiromitz / rss.php
Created November 17, 2010 11:01
Simple RSS Reader
<?php
/**
* Simple RSS Reader
*/
$url = 'http://hiromitz.jimdo.com/rss/blog';
$rss = @simplexml_load_file($url);
foreach($rss->channel->item as $item) {
echo "<h2>". $item->title. "</h2>";
echo "<div>". $item->description. "</div>";
@hiromitz
hiromitz / rss4atom.php
Created November 17, 2010 10:54
Simple RSS Reader for ATOM
<?php
/**
* Simple RSS Reader for ATOM
*/
$url = 'http://feeds.feedburner.com/github'; // feed url
$rss = @simplexml_load_file($url);
foreach($rss->entry as $entry) {
echo "<h2>". $entry->title. "</h2>";
@hiromitz
hiromitz / alc-bookmarklet.js
Created November 26, 2010 06:34
bookmarklet for alc translation
// javascript:
(function(w, d){
var t = (d.selection) ? d.selection.createRange().text :
(d.getSelection) ? d.getSelection() :
(w.getSelection) ? w.getSelection() : '';
(t == '') && (t = w.prompt('翻訳する文字を入力して下さい。', ''));
t ? w.open('http://eow.alc.co.jp/' + encodeURI(t) + '/UTF-8/', '_blank', '') : {};
})(window, document);
@hiromitz
hiromitz / delegate.js
Created December 9, 2010 03:35
delegator
/**
* delegate
* @param {Object} o target object
* @param function m target method
*/
function delegate(o, m){
return function(){
return m.apply(o, arguments);
}
}
@hiromitz
hiromitz / jquery.plugin.js
Created May 13, 2011 02:50
jQuery Plugin Template
;!function($) {
var pluginName = 'myPlugin';
$[pluginName] = function(el, op) {
this.options = op = $.extend({}, {
// default options here
}, op);
this.el = el;
};
@hiromitz
hiromitz / s3signurl.php
Created November 15, 2013 05:30
Generate Expiring Amazon S3 Link with Custom File Name
$client = array(
'key' => '<key>',
'secret' => '<secret>'
);
$expires = 5; // In minutes
// output signed URL string
echo el_s3_getTemporaryLink($client['key'], $client['secret'], 'bucket', '<path:file-MD5>', '<filename>', $expires);