Skip to content

Instantly share code, notes, and snippets.

View long-long-float's full-sized avatar
💭
☕ コーヒーが燃料デス

long_long_float long-long-float

💭
☕ コーヒーが燃料デス
View GitHub Profile
@long-long-float
long-long-float / gist:9051549
Created February 17, 2014 14:27
github markdown todo test

#ToDo List

  • task a
  • task b
  • task c
@long-long-float
long-long-float / gist:9311734
Created March 2, 2014 18:59
memory leak(win32 api)
#include <windows.h>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]){
while(true) {
@long-long-float
long-long-float / gist:11046484
Created April 18, 2014 14:17
rendering self in ejs
<script src="ejs.js"></script>
<script>
var unescapeHTML = function(str){
return str.replace(/&lt;/g, '<').replace(/&gt;/g, '>')
.replace(/&amp;/g, '&');
};
document.body.innerHTML = new EJS({text: unescapeHTML(document.body.innerHTML)}).render();
</script>
@long-long-float
long-long-float / gist:8229bbfdcb7527f9ff26
Last active August 29, 2015 14:02
niconico-anywhereのクライアント(ブックマークレット)
(function(){var c,messages,messages_buf,wheight,wwidth;c=function(a,b){var e;e=document.createElement('script');e.type='text/javascript';e.src=a;if(b){e.onloadDone=false;e.onload=function(){e.onloadDone=true;return b()};e.onReadystatechange=function(){if(e.readyState==='loaded'&&!e.onloadDone){e.onloadDone=true;return b()}}}if(typeof e!=='undefined'){return document.getElementsByTagName('head')[0].appendChild(e)}};messages_buf=[];c('https://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js',function(){var b,_ref;b=io.connect("http://"+((_ref=window.niconico_anywhere_host)!=null?_ref:"niconico-learning.herokuapp.com:80"));return b.on('new-message',function(a){return messages_buf.push(a)})});messages=[];wwidth=document.documentElement.clientWidth;wheight=document.documentElement.clientHeight;setInterval((function(){var a,i,index,msg,remove_list,s,_i,_j,_k,_len,_len1,_len2,_ref,_results;for(_i=0,_len=messages_buf.length;_i<_len;_i++){msg=messages_buf[_i];a=document.createElement('div');s=a.style;s
@long-long-float
long-long-float / convert.rb
Created February 1, 2015 07:19
文字列のサイコロ符号化(速度度外視)
# Usage: ruby convert.rb FILE
require 'zlib'
# サイコロの組み合わせ数
N = (2 + 4 + 4 + 2 + 2 + 4) * 3
def num2num_ary(num, base)
num_ary = []
while num != 0
@long-long-float
long-long-float / gen-toc.rb
Created December 22, 2015 13:42
Markdownの目次を作るスクリプト
#!/usr/bin/env ruby
TITLE_REGEXP = /(#+) (.+)/
text = File.read(ARGV[0]).split("\n")
numbers = []
counts = Array.new(6){ 0 }
prev_level = 0
text.each do |line|
@long-long-float
long-long-float / compile-and-compressed
Last active December 22, 2015 13:49
自動でフォームを埋めるブックマークレット
javascript:(function(){var d;d=function(a,b){var e;e=document.createElement('script');e.type='text/javascript';e.src=a;if(b){e.onloadDone=false;e.onload=function(){e.onloadDone=true;return b()};e.onReadystatechange=function(){if(e.readyState==='loaded'&&!e.onloadDone){e.onloadDone=true;return b()}}}if(typeof e!=='undefined'){return document.getElementsByTagName('head')[0].appendChild(e)}};d('//code.jquery.com/jquery-1.11.1.min.js',function(){var c,words;words=['hoge','fuga','piyo'];c=function(b){var i;return((function(){var a,_results;_results=[];for(i=a=1;1<=b?a<=b:a>=b;i=1<=b?++a:--a){_results.push(words[Math.floor(Math.random()*words.length)])}return _results})()).join(" ")};$('input').each(function(){var a,month,now,today;switch($(this).attr('type')){case'text':return $(this).val(c(3));case'number':return $(this).val(1);case'date':now=new Date();a=("0"+now.getDate()).slice(-2);month=("0"+(now.getMonth()+1)).slice(-2);today=now.getFullYear()+"-"+month+"-"+a;return $(this).val(today);case'radio':return $(th
@long-long-float
long-long-float / gist:8303087
Created January 7, 2014 17:33
convert C++ to UMLet
function join(c){
var ret = new Array();
for(var i = 1;i < arguments.length;i++){
ret.push(arguments[i]);
}
return ret.join(c);
}
var args = WScript.Arguments;
@long-long-float
long-long-float / gist:8303549
Created January 7, 2014 17:56
"return" function
#include <stdio.h>
#include <cassert>
void _return(){
__asm{
pop ebp //フレームポインタ回収
pop ebp //_returnから脱出
pop ebp //呼び出し元のフレームポインタ回収
ret
}
@long-long-float
long-long-float / gist:8317283
Created January 8, 2014 14:13
Maybe monad in ruby
class Maybe
def value
end
end
class Just < Maybe
attr_reader :value
def initialize(value)
@value = value