Skip to content

Instantly share code, notes, and snippets.

View halida's full-sized avatar

Halida halida

View GitHub Profile
//-*-coding:utf-8-*-
//----------------------------------------------------------
// module: 1132
//----------------------------------------------------------
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
@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
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 / 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) }
@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 / chef.sh
Last active August 29, 2015 14:16
Install chef
#!/bin/sh
# run
# curl http://ow.ly/JI3j3 | sh
mkdir -p /tmp/chef-install && cd /tmp/chef-install
wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chefdk_0.4.0-1_amd64.deb
sudo dpkg -i *.deb
cd && rm -rf /tmp/chef-install
@halida
halida / covert.rb
Created March 6, 2015 06:41
Create GIF preview for Videos, and a summarized html page
def make_preview_html
preview_path = 'preview'
styles = """
body .blk {
margin: 0 10px 10px 0;
display: inline-block;
}
body .blk img {
width: 160px;
@halida
halida / auto_reply_holiday.js
Last active January 24, 2017 06:53
gmail auto reply schedule
function autoReply() {
var scheduled_date = [
'2016-12-19', '2016-12-20',
];
var auto_reply = "I am out of office. Your email will not seen until Monday morning.";
var now = new Date();
var today = now.toISOString().slice(0, 10); // today format: '2017-01-01'
var label = GmailApp.getUserLabelByName('auto-replyed') || GmailApp.createLabel('auto-replyed');
@halida
halida / rails_haterslist.conf
Created June 1, 2017 13:33
Manage rails process by systemd
# copy from https://github.com/macournoyer/thin/pull/184#issuecomment-191119259
[Unit]
Description=haterslist
After=syslog.target network.target
[Service]
Type=forking
User=production
Group=production
今天我把母亲赶出了家门
updated on Tue May 30, 2017 22:00 by 扬帆远航 via 一个哲学家的财务自由之路
Translate article
就在今天上午,我把母亲赶出了家门,我感到如释重负,因为我已经忍受了这么多年,觉得自己实在不该再忍了,就做出了这样的决定。
我这里把前因后果谈一谈,其最初的缘由,我已经在另一篇文章《我家是如何从富裕走向赤贫的》做过叙述,这里主要讲近几年发生的事情。