Skip to content

Instantly share code, notes, and snippets.

View halida's full-sized avatar

Halida halida

View GitHub Profile
@halida
halida / convert1.rb
Last active August 29, 2015 14:13
Convert video to preview gif like those xxx websites, using libav-tools and imagick
filename = 'a.mp4'
target_path = '../processing'
(1..8).each do |i|
t = i * 60
target_file = File.join(target_path, "#{i}.jpg")
`avconv -i #{filename} -ss #{t} -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 '#{target_file}'`
end
image_files = File.join target_path, '*.jpg'
`convert -delay 50 -loop 0 #{image_files} #{filename}.gif`
@halida
halida / bsearch.rb
Created May 8, 2014 14:26
ruby bsearch vs index
require 'benchmark'
a = (1..1000).to_a
lookup = 100000.times.map{(rand*1000).to_i}
puts "for index"
puts Benchmark.measure {
lookup.each{ |i| a.index(i) }
mylib.close_to_tray = ->
gui = require('nw.gui')
win = gui.Window.get()
tray = null
win.on 'close', ->
this.hide()
tray = new gui.Tray({ icon: 'icon.jpg' })
@halida
halida / run.sh
Created February 25, 2014 02:16
god 启动执行脚本
#!/bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
### END INIT INFO
//-*-coding:utf-8-*-
//----------------------------------------------------------
// module: 1132
//----------------------------------------------------------
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

服务器创建后初始化

用root登陆,修改root密码:

passwd

创建用户

@halida
halida / gist:7177873
Created October 27, 2013 04:05
net-ssh issue
This file has been truncated, but you can view the full file.
11:58:24 write 0.000010 ruby
11:58:25 read 0.510431 W ruby
11:58:25 write 0.000010 ruby
11:58:25 ioctl 0.000027 W ruby
11:58:25 open lida/.rvm/gems/ruby-2.0.0-p247/gems/coderay-1.0.9/lib/coderay/tokens_proxy.rb 0.000036 ruby
11:58:25 fcntl 0.000002 ruby
11:58:25 fstat64 0.000004 ruby
11:58:25 fstat64
@halida
halida / client.d
Last active December 15, 2015 22:00
import std.stdio;
import std.socket;
import std.string;
import std.conv;
import std.random;
import std.outbuffer;
import core.thread;
int main() {
auto s = new TcpSocket();
@halida
halida / slides.md
Last active December 15, 2015 08:09 — forked from greatghoul/slides.md

name: inverse layout: true class: center, middle, inverse

#EasyOJ [linjunhalida]

我们为什么要作另外一个OJ?


layout: false

@halida
halida / gist:3130364
Created July 17, 2012 16:14
resque bug
class Outbox
@queue='v_redis'
def self.perform(userid,msgid)
$v_redis.set('ok',msgid+"*******")
get(userid,msgid)
end
def get(msg,msgid)
end