Skip to content

Instantly share code, notes, and snippets.

View leopku's full-sized avatar

Song Liu leopku

View GitHub Profile
@anthonyrisinger
anthonyrisinger / proftpd.conf.head
Created September 6, 2012 04:03
PAM/Postgres/Django/ProFTPd example
# /etc/stuff/proftpd.conf.head
Port 22022
SQLConnectInfo [email protected] user pass
# service run as ...
User nobody
Group nogroup
# effective ftp user
@jordansissel
jordansissel / logstash-mysql-query-parse.md
Last active June 7, 2021 21:10
parsing mysql's query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '

@mimosz
mimosz / .gitignore
Last active October 14, 2022 04:28
京东商品价格解析
.DS_Store
@shmatov
shmatov / deploy.rake
Created November 15, 2012 13:17
rails + mina + unicorn
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
@jimhj
jimhj / controller.rb
Created December 18, 2012 10:32
极简验证码生成 ImageMagick & MiniMagick
require 'mini_magick'
class CustomAdmin::MiniCaptchaController < CustomAdmin::ApplicationController
before_filter :clear_captcha_session, :only => :mini_captcha
#!/bin/bash
#
# requirements:
# - ImageMagick: http://www.imagemagick.org/script/binary-releases.php#macosx
# - image_optim: https://github.com/toy/image_optim
# - a scp supported host with ssh key paired
# setting up the enviroment
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
@vishaltelangre
vishaltelangre / auto_install_sublime_packages.markdown
Last active May 24, 2021 15:15
[Automate Packages Installation in Sublime Text 2] -- Automatically install Sublime Text 2 packages (some necessary ones, w/o fucking crap ones which makes sublime alike hell!)
  • To install packages, every time pressing ' ctrl+shift+pPackage Control: Install Package is very cumbersome task... right?

  • After fresh installation of ST2, open it and ctrl+` and hit enter after pasting below line [(1)][1]:

  import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
  • Restart ST2.

  • Open terminal, and navigate to Sublime's dir under your home folder by below command and create file w/ name Package Control.sublime-settings there in:

@phildionne
phildionne / bootstrap_link_renderer.rb
Last active December 18, 2015 12:48
WillPaginate link renderer for Twitter Bootstrap. Use in Sinatra/Padrino.
@zhangyuan
zhangyuan / gist:5932220
Last active April 6, 2021 01:53
使用 CarrierWave 和 MiniMagick 合成多张图片、写文字

合成多张图片

以下只适合 v3.5.0 即以前的版本。v3.6.0 以后,对选项增加了 shellescape 减少了命令行注入的风险。

ImageMagick 的 composite 命令可以合成图片,但是一次只能合成两张。如果需要合成多张图片,得用 convert 命令和 -composite 选项。MiniMagick 的push方法,可添加选项和参数(就像在命令行操作一样)。下是一个合成多张图片的 CarrierWave 的 process 示例。

  def composite_images
    manipulate! do |img|
      img.combine_options(:convert) do |c|
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet