Skip to content

Instantly share code, notes, and snippets.

View yiquncode's full-sized avatar

Alvin yiquncode

  • Tokyo
View GitHub Profile
@yiquncode
yiquncode / gist:710012
Created November 22, 2010 13:58
top100down
#!/bin/sh
for i in `curl $1 |grep mp3 | awk -F\" '{print $2}'|uniq`
do
wget --limit-rate=300k --referer='http://www.top100.cn/download/download.aspx?Productid=kcadnctughhdkcbogy' -U 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12' $i
done
<head>
<title><%= h(yield(:title) || "Untitled") %></title>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'jquery.1.3.2.min' %>
<%= yield(:head) %>
</head>
<% title "Crop Avatar" %>
<% content_for (:head) do %>
<%= stylesheet_link_tag "jquery.Jcrop" %>
return nil if uploaded_file.nil?
extension = File.extname(uploaded_file.original_filename).downcase
@queued_for_write[:original] = to_tempfile(uploaded_file)
instance_write(:file_name, "#{Time.now.strftime("%Y%m%d%H%M%S")}#{rand(1000)}#{extension}")
instance_write(:content_type, uploaded_file.content_type.to_s.strip)
instance_write(:file_size, uploaded_file.size.to_i)
instance_write(:fingerprint, generate_fingerprint(uploaded_file))
instance_write(:updated_at, Time.now)
@yiquncode
yiquncode / localhost.conf
Created December 19, 2010 04:49
nginx反向代理,存在安全问题
#解决办法
location /phpmyadmin {
auth_basic "Tell me who you are";
auth_basic_user_file passwd/htpasswd;
proxy_pass http://apache;
}
@yiquncode
yiquncode / gist:755455
Created December 26, 2010 14:52
用户欢迎邮件
private
def send_welcome_email
UserMailer.welcome_registration(self).deliver
end
def resize
@mypic = User.find(current_user.id)
img = Magick::Image::read(@mypic.avatar.path).first #----> [BUG] Segmentation fault
img.crop!(::Magick::CenterGravity,20,130,276,276,true)
img.write @mypic.avatar.path(:medium)
redirect_to :action => 'pic'
end
@yiquncode
yiquncode / gist:759912
Created December 30, 2010 15:43
Uninstall directadmin in centos5.5
#i got some paths info from http://www.directadmin.com/paths.html and http://www.directadmin.com/forum/showthread.php?threadid=3365
#welcome to join and add more for uninstall them
#Notice:You have to shutdown some service setup by directadmin before you restart the server.
#http://www.zhangyiqun.net
rm -rf /etc/cron.d/directadmin_cron
rm -rf /usr/local/directadmin
rm -rf /etc/virtual
cd /home
@yiquncode
yiquncode / gist:760976
Created December 31, 2010 12:35
Git代码同步
#线上
#获取代码
git clone ...
#获取更新
git pull
#如果在线上修改了代码,要推回
git push
#线上代码和git版本库冲突
#Your local changes to ... would be overwritten by merge
git fetch --all
@yiquncode
yiquncode / gist:861820
Created March 9, 2011 07:19
Fix cpanel master domain
#1.Replace "artidea.me" to your master domain
#2.Replace "blog" to the path that you want via through "www.artidea.me"
RewriteCond %{HTTP_HOST} ^(www.)?artidea.me$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@yiquncode
yiquncode / gist:863702
Created March 10, 2011 07:26
RUBY POST PURE
def my_method
#do something with the data/model
my_connection = Net::HTTP.new('www.target.com', 80)
reponse = my_connection.post(path_within_url, data)
#do something with response if you want
end