This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -mtime +30 # 30 天之前修改过的文件 | |
find . -type f -mtime -30 # 30 天内的文件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls | xargs -l asd echo asdf # ${filename}f 文件名后多了个"f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
sudo apt-get update | |
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \ | |
libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev \ | |
libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev | |
mkdir ~/ffmpeg_sources | |
which yasm && echo "yasm has installed" || sudo apt-get -y install yasm | |
which wget && echo "wget has installed" || sudo apt-get -y install wget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# Tool top 10 | |
# git 100 | |
# vim 49 | |
# xxx 21 | |
# | |
# Action top 10 | |
# git checkout master 231 | |
# vim index.html 192 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require './boot' rescue nil | |
conn = ActiveRecord::Base.connection | |
table_name = 'schema_migrations' | |
cols = conn.execute("show columns from #{table_name}").map {|row| row.first } | |
unless cols.include?('version') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Settings | |
class << self | |
Dir[Rails.root.join('config/settings/*')].each do |filepath| | |
filename = File.basename filepath | |
next unless filename =~ /^\w+\.ya?ml$/ | |
puts "Load config '#{filename}'" | |
setting_name = filename.gsub(/\.ya?ml/, '') | |
eval(%Q{ | |
def #{setting_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db_config = YAML.load_file('config/my_database.yml') | |
resolver = ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(db_config) | |
spec = resolver.spec(env) | |
conn_pool = ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack' | |
app = Proc.new do |env| | |
['200', {'Content-Type' => 'text/html'}, ['Hello, this is a rack app.']] | |
end | |
port = ENV['PORT'] || 8080 | |
Rack::Handler::WEBrick.run app, Port: port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = Proc.new do |env| | |
['200', {'Content-Type' => 'text/html'}, ['Hello, this is a rack app.']] | |
end | |
run app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Daemon.new.run do | |
# `echo "#{Process.pid} #{Time.now}" >> /tmp/daemon_ruby` | |
# end | |
require 'timeout' | |
require 'socket' | |
require 'logger' | |
require 'fileutils' |
OlderNewer