Skip to content

Instantly share code, notes, and snippets.

View lulalala's full-sized avatar

lulalala lulalala

View GitHub Profile
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active September 29, 2024 08:31
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@joepie91
joepie91 / vpn.md
Last active October 6, 2024 08:38
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@drush
drush / delayed_job_threads.rb
Last active July 13, 2020 13:17
Run Delayed Job Worker as a Thread in Web Process
# Only run in server process, not console or rake tasks
if !Rails.const_defined?('Console') && !($0 =~ /rake$/) && !Rails.env.test?
Rails.application.config.after_initialize do
(1..2).each do |thread_id|
Thread.new {
Thread.current[:thread_name] = "DJ Web Worker Thread #{thread_id}"
ActiveRecord::Base.connection_pool.with_connection do |conn|
dj = Delayed::Worker.new
Rails.logger.warn "Starting #{Thread.current[:thread_name]}"
@telent
telent / gist:9742059
Last active May 8, 2024 11:36
12 factor app configuration vs leaking environment variables
App configuration in environment variables: for and against
For (some of these as per the 12 factor principles)
1) they are are easy to change between deploys without changing any code
2) unlike config files, there is little chance of them being checked
into the code repo accidentally
3) unlike custom config files, or other config mechanisms such as Java
@caasi
caasi / maple_future_0.txt
Created February 17, 2014 08:59
十五年前,前輩先進們討論著 BBS 的未來。
作者 Thor (淡出) 看板 plan
標題 Maple未來發展
時間 Fri Jul 24 09:47:41 1998
───────────────────────────────────────
只是隨便取個聳動的標題而已:ppp
現在 bbtpd.c opus還沒寫完就消失了,
我在想直接接下去寫會不會對他大不敬呀?:P
@Bertg
Bertg / spawn_methods.rb
Created January 10, 2014 13:18
This version of spawn methods removes the dangerous behaviour where rails 3.2 (after 3.2.13) clobbers conditions.
raise "Remove patch after rails 3.2" if Rails.version =~ /\A4/
# copy of lib/active_record/relation/spawn_methods.rb
# Because updating to this version 3.2.16 might change the behaviour of some of our queries,
# we took a copy of this class and remove the behaviour where
module ActiveRecord
module SpawnMethods
def merge(r)
return self unless r
return to_a & r if r.is_a?(Array)
@afeld
afeld / gist:5704079
Last active November 27, 2023 15:43
Using Rails+Bower on Heroku
require 'rest-core'
module RestCore
middleware = Class.new
middleware.module_eval do
def initialize app
@app = app
end
def call env, &k
@nbibler
nbibler / gist:5307941
Last active August 26, 2024 20:44
A .powrc file which works with RVM's .rvmrc or .ruby-version (+ .ruby-gemset) configuration files.
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi