Skip to content

Instantly share code, notes, and snippets.

tls:
certificates:
- certFile: /configuration/certs/domain.com.crt
keyFile: /configuration/certs/domain.com.key
@lazybios
lazybios / install-ruby.sh
Created May 29, 2022 10:56 — forked from hopsoft/install-ruby.sh
Install ruby with rbenv and jemalloc on ubuntu
sudo apt-get update
sudo apt-get install libjemalloc-dev
RUBY_CONFIGURE_OPTS='--with-jemalloc' rbenv install 2.6.3
# test (look for jemalloc warnings)
MALLOC_CONF=invalid_flag:foo ruby -v
@lazybios
lazybios / custom_logger.rb
Created May 6, 2022 10:31 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@lazybios
lazybios / gist:9b3c5dc54f38dca2de73af1a4e0b4b54
Created October 11, 2021 12:36 — forked from bsodmike/gist:1369419
Subdomain Routing with Rails 3.1

Implement Routing for Subdomains

Rails 3.0 introduced support for routing constrained by subdomains.

A subdomain can be specified explicitly, like this:

match '/' => 'home#index', :constraints => { :subdomain => 'www' } 
@lazybios
lazybios / redis_factory.lua
Created May 22, 2018 11:52 — forked from karminski/redis_factory.lua
lua redis factory for lua-resty-redis, can work with nginx + nginx-lua-module or openresty.
--[[
redis_factory.lua
Redis factory method.
You can also find it at https://gist.github.com/karminski/33fa9149d2f95ff5d802
@version 151019:5
@author karminski <code.karminski@outlook.com>
@license MIT
@lazybios
lazybios / gist:e130d3d67f55e554c3a222418ecde1d0
Created November 30, 2017 13:33 — forked from fitzyyf/gist:5276821
Python 通过SSH执行远程命令
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# See http://www.cnblogs.com/ma6174/archive/2012/05/25/2508378.html
import pexpect
import paramiko
import threading
import yaml
function getShareMetas(){var title="",description="",image="";var title_element=document.querySelector('meta[property=\"wechat:title\"]');if(title_element){title=title_element.getAttribute(\"content\")}else{title=document.title}var description_element=document.querySelector('meta[property=\"wechat:description\"]');if(description_element){description=description_element.getAttribute(\"content\")}else{description=document.getElementsByName(\"description\")[0].content}var image_element=document.querySelector('meta[property=\"wechat:image\"]');if(image_element){image=image_element.getAttribute(\"content\")}else{image=document.getElementsByTagName(\"img\")[0].src}return'{\"title\":\"'+title+'\",\"description\":\"'+description+'\",\"image\":\"'+image+'\"}'};
@lazybios
lazybios / polymorphic_ass_grape_entity
Created February 14, 2017 06:49 — forked from ordoghl/polymorphic_ass_grape_entity
Polymorphic association in a grape entity
require_relative 'customer.rb'
require_relative 'contact.rb'
require_relative 'agent.rb'
module Api
module V1
module Entities
class Ticket < Grape::Entity
expose :id
@lazybios
lazybios / wr703n-openwrt.md
Created June 26, 2016 07:55 — forked from simpx/wr703n-openwrt.md
wr703n刷openwrt配置、记录
/* ------------------------------
Author: Fred Wu
------------------------------ */
// colours
$error_colour: #e3302c;
$primary_colour: #0e3399;
$primary_colour_h: darken($primary_colour, 15%);