Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@mala
mala / twitter_crawl.pl
Created May 10, 2020 14:21
一個前の記事用に書いた Twitter Profile 収集するやつ
use strict;
use Net::Twitter;
use MongoDB;
my $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
consumer_key => "xxx",
consumer_secret => "xxx",
access_token => "xxx",
access_token_secret => "xxx",
@mala
mala / CVE-2019-5418_is_RCE.md
Last active February 7, 2021 04:25
Rails の CVE-2019-5418 は RCE (Remote code execution) です

最初期 - 開発人数: 1人, リリース前

このフェーズはほぼすべてのことが唯一の開発メンバーのスキルとマインド次第で決まるので、チームとしてできることは極めて少ないです。また、この段階のプロジェクトはリリース前に捨てる可能性もあるので、導入コストの高い開発ツールはまだ必要ありません。

  • バージョン管理をしている
  • リポジトリへのアクセス権を広げた(上長やチームメイト、開発基盤的な組織に権限を渡しておく)
  • CIをセットアップし、最低限ビルドだけしている
  • コーディングスタイルガイドを用意した
  • (Androidの場合).idea/codeStyleSettings.xml を用意してスタイルガイドに沿ってフォーマットできるようにした
@chansen
chansen / results.txt
Created November 16, 2015 19:47
Faster UTF-X validation (~ 50% - 300% faster)
perl: 5.022000 (darwin 14.5.0)
ar.txt: code points: 14308 (U+0000..U+007F: 2698 U+0080..U+07FF: 11610)
Rate core this
core 26873/s -- -33%
this 39928/s 49% --
el.txt: code points: 58748 (U+0000..U+007F: 13560 U+0080..U+07FF: 45150 U+0800..U+FFFF: 38)
Rate core this
@calid
calid / 00-preamble.md
Last active October 3, 2022 10:45
ZeroMQ Perl Performance Comparison: FFI vs XS bindings

ØMQ Perl Performance Comparison: FFI vs XS bindings

Comparison of the performance of FFI vs XS zeromq bindings. For FFI the ZMQ::FFI bindings are used, first using FFI::Raw on the backend and then using FFI::Platypus. For XS ZMQ::LibZMQ3 is used.

Comparison is done using the zeromq weather station example, first by timing wuclient.pl using the various implementations, and then by profiling wuserver.pl using Devel::NYTProf. When profiling the server is changed to simply publish 1 million messages and exit.

@artturik
artturik / gist:a15d890dcfedfe8af813
Last active August 14, 2022 13:38
Convert PhantomJs cookies to NetScape HTTP cookie file format
// Convert PhantomJs cookies to NetScape HTTP cookie file format
// NOTE: It dose not create NetScape HTTP cookie file, this function return only cookie file contents
// NOTE: PhantomJs do not store "host only" cookie param, all cookies will have "host only" param set to false (line 15)
// I use this function to export PhantomJs cookies to CURL cookiejar file
// This is modified version of EditThisCookie cookie_helpers.js cookiesToString function
// USAGE: phantomJsCookiesToNetScapeString(phantom.cookies);
var phantomJsCookiesToNetScapeString = function(cookies) {
var string = "";
string += "# Netscape HTTP Cookie File\n";
@karupanerura
karupanerura / benchmark.pl
Last active August 29, 2015 14:01
Router::R3 benchmark
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.018002;
use autodie;
use Benchmark qw(:all);
use Router::Boom;
use Router::Boom::Method;
use Router::Simple;
@nicktoumpelis
nicktoumpelis / git-make-empty-root.sh
Last active July 3, 2024 18:28
Create an empty initial commit
git checkout --orphan temp_master
git rm -rf .
git commit --allow-empty -m 'Make initial root commit'
git rebase --onto temp_master --root master
git branch -D temp_master
@gfx
gfx / foo.pl
Last active September 17, 2017 21:57
正規表現リテラルがあると便利な例。これを文字列操作メソッドで解決するとなるとかなり難しいと思われますがどうでしょう。 また、正規表現リテラルがなくてもじっさいにはあまり変わりないのですが、 \S ではなく \\S と書かなければならなかったりして注意しなければならない点が増えます。
#!perl
use 5.10.0;
use strict;
use warnings;
my $localhost = join '|', map { quotemeta } 'localhost', '127.0.0.1';
my $s = "http://localhost/foo http://127.0.0.1/bar http://127_0_0_1/foo/bar/baz";
my @matched = $s =~ m{ http:// (?:$localhost) / \S+ }xg;