Skip to content

Instantly share code, notes, and snippets.

@nurse
nurse / pid2line.rb
Last active December 27, 2018 08:51
Show source files and line numers of given process's threads
#!/usr/bin/env ruby
#
# pid2line.rb
#
# Show source files and line numers of given process's threads
#
# This script works only on Linux.
# https://gist.github.com/nurse/0619b6af90df140508c2
#
*** client/mysql.cc.orig 2015-09-18 23:24:43.000000000 +0900
--- client/mysql.cc 2015-11-26 19:42:19.469000382 +0900
***************
*** 1128,1130 ****
static void mysql_end_timer(ulong start_time,char *buff);
! static void nice_time(double sec,char *buff,bool part_second);
extern "C" sig_handler mysql_end(int sig);
--- 1128,1130 ----
static void mysql_end_timer(ulong start_time,char *buff);
! static void nice_time(ulong sec,char *buff,bool part_second);
# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる
@mala
mala / postMessageLogger.user.js
Created December 9, 2013 14:51
便利user.js
window.addEventListener("message", function(e){ console.log(e) });
#!/usr/bin/env perl
use strict;
use warnings;
use lib 'extlib/lib/perl5';
use DBIx::Sunny;
use Parallel::ForkManager;
use File::Temp qw/tempfile/;
use Time::HiRes qw/gettimeofday tv_interval/;
@xaicron
xaicron / border.js
Created June 10, 2012 17:17
canvas border line
var JSX = {};
(function () {
/**
* copies the implementations from source interface to target
*/
function $__jsx_merge_interface(target, source) {
for (var k in source.prototype)
if (source.prototype.hasOwnProperty(k))
target.prototype[k] = source.prototype[k];
@jboner
jboner / latency.txt
Last active May 10, 2024 14:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

CRubyのGCの構造改革

やりたいこと

以下の6つの機能を分離し、簡単に切り替えられるようにしたい。

  1. OSからのメモリアロケータ
  • OSからメモリアロケートする部分のAPI
  1. Rubyのヒープ管理
  • ヒープの設定を保持
<meta content="record, sounds, share, sound, audio, tracks, music, soundcloud" name="keywords" />
<meta content="Listen to Madhouse (Forss vs Borg Interlude live 2005) by Forss: Crazy interlude we used to play live back in '05 | Create, record and share the sounds you create anywhere to friends, family and the world with SoundCloud, the world's largest community of sound creators." name="description" />
<link href="http://sandbox-soundcloud.com/forss" rel="author" />
<meta content="width=device-width" name="viewport" />
<meta content="chrome=1" name="X-UA-Compatible" />
<meta content="iframe" name="medium" />
<meta content="soundcloudplayer:sound" property="og:type" />
<meta content="player" property="twitter:card" />
<meta content="http://sandbox-soundcloud.com/forss/madhouse-forss-vs-borg-interlude-live-2005" property="og:url" />
<meta content="Madhouse (Forss vs Borg Interlude live 2005)" property="og:title" />
#!perl
use strict;
use warnings;
use Net::Google::Calendar;
use Config::Pit;
use DateTime;
use Email::MIME;
use Data::Dumper;
use HTTP::Date ();
use FindBin;