Skip to content

Instantly share code, notes, and snippets.

@mgng
mgng / resize_download_test.html
Last active August 29, 2015 14:05
canvas 使って画像リサイズしてダウンロードさせる
<p><button id="id_100x100_download">100x100でダウンロード</button></p>
<p><img id="id_original_image" src="/img/sample.jpg" alt="" /></p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
;$(function(){
'use strict';
$("#id_100x100_download").on("click.download", function(){
@mgng
mgng / memop.js
Last active August 29, 2015 14:05
jquery memo
// 先頭セミコロンは直前のプログラムを明示的に終わらせるためのおまじないみたいなもんだから別にかかなくてもいい
;$(function(){
// 当然 use strict
'use strict';
// jQuery オブジェクトは $ を付けて他の変数と区別
var $name = $("#id_name");
var name = $name.val();
@mgng
mgng / dd.css
Last active January 10, 2018 06:09
ドラッグドロップした画像をbase64で表示するサンプル
@charset "utf-8";
body{
margin:0;
padding:0;
}
img{
max-width: 100%;
}
@mgng
mgng / result.txt
Created June 17, 2014 08:16
Imagemagick で 画像リサイズと画質落としつつ gif アニメーションを作る
Version: ImageMagick 6.8.1-0 2012-12-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: OpenMP
#1 : 1.4550831317902
#2 : 0.72604203224182
#3 : 0.45802593231201
@mgng
mgng / rekognition_sample.js
Created May 22, 2014 03:00
Rekognition sample
$.ajax({
url : "http://rekognition.com/func/api/",
data : {
api_key : "YOUR API KEY",
api_secret : "YOUR API SECRET",
jobs : "face_aggressive_gender_emotion_age_race",
urls : "http://livedoor.blogimg.jp/onsokuch/imgs/a/5/a561eb29.jpg"
},
type : 'POST',
dataType: "json"
@mgng
mgng / instagrss_sample.php
Created April 10, 2014 00:25
instagrss_sample.php
<?php
$user_id = "parishilton";
$json = json_decode( file_get_contents( "http://instagram.com/{$user_id}/media" ) );
$results = array();
foreach( $json->items as $item ) {
$results[] = array(
"link" => $item->link,
"created_time" => $item->created_time,
"thumbnail_url" => $item->images->thumbnail->url,
@mgng
mgng / 1.php
Created March 7, 2014 05:18
imagick で ico 作成でエラー
<?php
$img = new \Imagick();
$img->readImageBlob( file_get_contents( "./test.jpg" ) );
$img->setFormat( "ico" );
// ↑ Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format ...
@mgng
mgng / array_from_base64_decode.php
Created February 4, 2014 05:11
base64文字列を配列形式にする
<?php
/**
* @param string $str
* @return array
*/
function array_from_base64_decode( $str ) {
$table = preg_split('//', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', -1, PREG_SPLIT_NO_EMPTY);
$data = array();
for( $i=0, $l=count($table); $i<$l; $i++) {
$data[$table[$i]] = $i;
@mgng
mgng / array_to_base64_encode.php
Created February 4, 2014 04:29
array -> base64_encode
<?php
/**
* @param array $a
* @return string
*/
function array_to_base64_encode( array $a ) {
$table = preg_split('//', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', -1, PREG_SPLIT_NO_EMPTY);
$l = count($a);
$m = $l % 3;
@mgng
mgng / recentshow.mp3.markdown
Last active February 26, 2022 12:20
convex level recentshow.mp3 set list