This file contains hidden or 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
[unix_http_server] | |
file=/tmp/supervisor.sock | |
;username = dongwm | |
;password = 123 | |
[inet_http_server] | |
port = 0.0.0.0:5000 | |
username = dongwm | |
password = 123 |
This file contains hidden or 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
(function() { | |
// Adding upload button to Trix toolbar on initialization | |
document.addEventListener('trix-initialize', function(e){ | |
trix = e.target; | |
toolBar = trix.toolbarElement; | |
// Creation of the button | |
button = document.createElement("button"); | |
button.setAttribute("type", "button"); | |
button.setAttribute("class", "attach"); |
This file contains hidden or 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
function postForm(path, params = {}) { | |
const form = document.createElement('form'); | |
form.setAttribute('method', 'post'); | |
form.setAttribute('action', path); | |
Object.keys(params).forEach((key) => { | |
if (params.hasOwnProperty(key)) { | |
const hiddenField = document.createElement('input'); | |
hiddenField.setAttribute('type', 'hidden'); | |
hiddenField.setAttribute('name', key); | |
hiddenField.setAttribute('value', params[key]); |
This file contains hidden or 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
// 使用 userAgent 判断是否微信内置浏览器 | |
if( navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 || typeof navgator.wxuserAgent !== "undefined" ) { | |
return true; | |
} |
This file contains hidden or 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
module ActiveRecord::Persistence::ClassMethods | |
def create!(attributes = nil, &block) | |
if attributes.is_a?(Array) | |
attributes.collect { |attr| create!(attr, &block) } | |
else | |
object = new(attributes, &block) | |
[:save,:create].each { |cb| object.class.reset_callbacks cb } | |
object.save(validate: false) | |
object |
This file contains hidden or 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
module ActiveRecord | |
class Base | |
def self.cache_key | |
Digest::MD5.hexdigest "#{scoped.maximum(:updated_at).try(:to_i)}-#{scoped.count}" | |
end | |
end | |
end |
This file contains hidden or 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
sql = File.read(sql_file) | |
statements = sql.split(/;$/) | |
statements.pop if statements.last.blank? | |
ActiveRecord::Base.transaction do | |
statements.uniq.each { |statement| execute(statement.gsub(/\n/, '')) } | |
end |
This file contains hidden or 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 d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | |
find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} |
This file contains hidden or 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
# Function to print strftime results | |
def print_strftime_formats(a,cur_date) | |
a.each do |format| | |
b = "%#{format}" | |
output = cur_date.strftime(b) | |
puts "t.strftime('#{b}'), => #{output}" | |
end | |
end | |
a = ('a'..'z').to_a |
This file contains hidden or 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/sh | |
_ver='2.1.6' | |
if [ -z "$V" ]; then | |
_ver='2.1.6' | |
else | |
_ver=$V | |
fi | |
ruby-install --rubies-dir /usr/local/rubies ruby $_ver |
NewerOlder