Skip to content

Instantly share code, notes, and snippets.

@janx
janx / fetchsub.py
Created July 27, 2011 02:31
Feching subtitles on shooter.cn
#!/usr/bin/python2
USAGESTR = """Usage: fetchsub.py [-l langcode] videofile1 [videofile2 ...]
langcode: chn [default]
eng
sub file will saved in the same directory of each videofile
XXXXXXX.mkv 's sub files will named as:
XXXXXXX.chn.0.srt, XXXXXXX.chn.1.srt, XXXXXXX.chn.2.srt
"""
"""Author: sevenever
@janx
janx / slanger_nginx_lb.conf
Created May 5, 2014 05:09
Use nginx as load balancer for Slanger
upstream slanger_ws {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
server 127.0.0.1:8004;
server 127.0.0.1:8005;
server 127.0.0.1:8006;
server 127.0.0.1:8007;
server 127.0.0.1:8008;
}
@janx
janx / About.markdown
Last active January 28, 2023 15:36
Memory leak research on OpenStruct and #define_method.

OpenStruct and #define_method

#define_method will create a closure, without careful use it could cause memory leak, as pointed out here.

OpenStruct use #define_method to create accessors dynamically, we suspect that will cause memory leak.

So I create two scripts to prove it, however the result shows the opposite: OpenStruct doesn't leak memory.

open_struct_leak.rb

1. Open https://conwaylife.com/
2. Clear the viewer
3. Copy the code below and paste the code in by "Settings -> Open Clipboard"
```
x = 28, y = 15, rule = B3/S23
2$b6o3b2o4b2o3b6o$2o8b2o4b2o3b6o$2o8b2o2b4o3b2o3b2o$2o8b2o2b2o5b2o3b2o
$2o8b6o5b6o$2o8b4o7b6o$2o8b6o5b2o3b2o$2o8b2o2b2o5b2o3b2o$2o8b2o2b4o3b
2o3b2o$2o8b2o4b2o3b6o$b6o3b2o4b2o3b6o!
```
4. Set theme to "Inverse" in "Settings -> Themes".
LoadModule pagespeed_module /usr/lib/httpd/modules/mod_pagespeed.so
# Only attempt to load mod_deflate if it hasn't been loaded already.
<IfModule !mod_deflate.c>
LoadModule deflate_module /usr/lib/httpd/modules/mod_deflate.so
</IfModule>
<IfModule pagespeed_module>
SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
ModPagespeed on
@janx
janx / analog_clock.html
Created September 2, 2011 13:04
html5 svg analog clock
<!DOCTYPE HTML>
<html>
<head>
<title>Analog Clock</title>
<script>
function updateTime() { // Update the SVG clock
var now = new Date();
var sec = now.getSeconds();
var min = now.getMinutes();
var hour = (now.getHours() % 12) + min/60;
{
 "amount": "Bytes[8]" // serialized integer
}
pub struct CellOutput {
pub capacity: Capacity,
pub data: Vec<u8>,
pub lock: Script,
pub type_: Option<Script>,
}
class CTxOut
{
public:
CAmount nValue;
CScript scriptPubKey;
...
}
@janx
janx / centos-bitcoind-guide.markdown
Last active May 8, 2019 05:27
Install bitcoind on CentOS 6.5

##RPM Packages##

sudo yum install qt-devel protobuff-devel qrencode-devel

##Switch to user bitcoind##

sudo useradd bitcoind
sudo su - bitcoind
mkdir bitcoind

mkdir bitcoind/deps