Skip to content

Instantly share code, notes, and snippets.

View mimosa's full-sized avatar
🏔️

Howl王 mimosa

🏔️
View GitHub Profile
@vemarav
vemarav / console.js
Last active October 22, 2020 03:21
Build rails like console in nodejs
/**
* add console.js at ther root of your app
* Modify to make it more helpful for your project
* > Note: `esm` adds ES6 support in Node
* In package.json
* ...
* "scripts": {
* "start": "nodemon -r esm ./server.js"
* "console": "node -r esm --experimental-repl-await console",
* }
@kares
kares / slow_query_log.rb
Last active March 23, 2022 09:40
ActiveRecord slow query logging in Rails ... setup using: config.slow_query_log_threshold_in_ms = 500
require 'active_record/log_subscriber'
class SlowQueryLog < ActiveSupport::LogSubscriber
if Rails.configuration.respond_to?(:slow_query_log_threshold_in_ms)
if @@threshold = Rails.configuration.slow_query_log_threshold_in_ms
@@threshold = @@threshold.to_i == 0 ? nil : @@threshold.to_i
end
else
@@threshold = nil
@sebastianmarkow
sebastianmarkow / caddy
Last active February 3, 2021 17:15
caddy web server openrc startup script
#!/sbin/openrc-run
description="Caddy web server"
description_reload="Reload configuration"
extra_started_commands="reload"
: ${CADDY_CONF:=/etc/caddy/Caddyfile}
: ${CADDY_PIDFILE:=/var/run/caddy.pid}
: ${CADDY_USER:=caddy}
class Logger
private_class_method :new
@@instance = nil
def info(msg)
puts msg
end
def self.instance
@@instance = new unless @@instance
@itsderek23
itsderek23 / Dockerfile
Created August 27, 2013 02:09
Example Docker File to start a Rails app located in a local ./docker-rails directory.
# docker build -t="rails" .
FROM ubuntu:12.04
RUN apt-get update
## MYSQL
RUN apt-get install -y -q mysql-client libmysqlclient-dev
## RUBY
@gongo
gongo / Gemfile
Last active February 14, 2018 22:14
Capybara の稼働状況を animation gif として保存するようなやつ
source 'https://rubygems.org'
gem 'capybara'
gem 'rake'
gem 'selenium-webdriver'
gem 'json'
gem 'rmagick'
@huacnlee
huacnlee / _form.html.erb
Created August 21, 2012 10:55
UpYun 表单上传验证信息 helper 方法,用于生成 input tag
<form action="http://v0.api.upyun.com/rbtest/" method="post" enctype="multipart/form-data">
<%= upyun_form_input_tag(:return_url => new_post_path) %>
<input type="file" name="file" />
<button type="submit">上传图片</button>
</form>
@relistan
relistan / compress_requests.rb
Last active April 18, 2023 23:54 — forked from subdigital/compress_requests.rb
Rack Middleware to automatically unzip gzipped/deflated POST data
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@szimek
szimek / presentation.md
Created January 24, 2012 09:51
HTTP caching in Rails

HTTP caching

Kinds of caches

  • Browser
  • Proxy
  • Gateway

TODO Difference between proxy and gateway caches.