Skip to content

Instantly share code, notes, and snippets.

@hecomi
hecomi / gist:5734680
Created June 8, 2013 09:39
はてダに SlideShare はるヤツ
<iframe src="http://www.slideshare.net/slideshow/embed_code/15231713" width="597" height="486" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"> </iframe>
@hecomi
hecomi / emscriptened.js
Last active December 18, 2015 01:48
C のコード: "int main() { return 0; } " と "#include <stdio.h> int main() { puts("hello, world!"); return 0; } " を em++ で JS に変換した結果の比較です。
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
// The environment setup code below is customized to use Module.
// *** Environment setup code ***
var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
@hecomi
hecomi / blink1_notifier.rb
Last active December 14, 2015 15:29 — forked from siyo/blink1_notifier.rb
blink(1) eartuqake.gem plugin to blink by each user's icon color
# -*- coding: utf-8 -*-
# blink(1) eartuqake.gem plugin to blink by each user's icon color
#
require 'rubygems'
require 'rmagick'
def getRGB(url)
@rgb ||= {}
if (@rgb["#{url}"].nil?)
image = Magick::Image.read(url).first.resize!(1, 1)
require 'rubygems'
require 'rmagick'
width = 100
height= 100
url = 'https://si0.twimg.com/profile_images/3345985110/ce68eba70a439a797006d8451dbe51a7_bigger.gif'
image = Magick::Image.read(url).first
image.resize!(1, 1)
color = image.get_pixels(0, 0, 1, 1)[0];
"====================================================================================================
" OS
"====================================================================================================
" {{{
let s:is_win = has('win32') || has('win64')
let s:is_mac = has('mac') || system('uname') =~? '^darwin'
let s:is_linux = !s:is_mac && has('unix')
" }}}
"====================================================================================================
@hecomi
hecomi / gr-plus-hatena_0.1.0_gk.user.js
Last active December 11, 2015 08:19
Google Reader ではてブ数/コメントを見るスクリプト( https://code.google.com/p/gr-puls-hatena/ )に対して、人力検索はてなで議論されている内容( http://q.hatena.ne.jp/1265127611 )を適用し、かつボタンを押さなくても自動的にコメントが表示されるようにしたバージョンです。
// ==UserScript==
// @name GoogleReader plus Hatena
// @namespace http://zero-code.com/category/googlereader_puls_hatena
// @description GoogleReader上にはてなブックマークのコメントを表示する
// @author zero-code
// @version 0.1.0
// @include http://www.google.*/reader/*
// @include https://www.google.*/reader/*
// @exclude *.css
// @exclude *.js
@hecomi
hecomi / globalip.js
Last active December 11, 2015 00:38
SOAP で Global IP をルーターから取得する奴
var http = require('http');
var data = '<?xml version="1.0"?>' +
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
'<s:Body>' +
'<u:GetExternalIPAddress xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">' +
'</u:GetExternalIPAddress>' +
'</s:Body>' +
'</s:Envelope>';
var phantom_sync = require('phantom-sync');
var phantom = phantom_sync.phantom;
var sync = phantom_sync.sync;
var cheerio = require('cheerio');
sync(function() {
var ph = phantom.create();
page = ph.createPage();
// ページが読み込まれたら page.onCallback を呼ぶ
@hecomi
hecomi / ViewController.mm
Last active December 10, 2015 11:28
Boost.Thread + Boost.Asio で thread 中で io_service.run() すると落ちる…;;
//
// ViewController.m
// AsioTest
//
// Created by hecomi on 2012/12/31.
// Copyright (c) 2012年 hecomi. All rights reserved.
//
#import "ViewController.h"
#include <dispatch/dispatch.h>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/thread.hpp>
#include <boost/system/system_error.hpp>
#include <iostream>
using namespace std;
namespace asio = boost::asio;
using boost::asio::ip::tcp;