Skip to content

Instantly share code, notes, and snippets.

@holin
holin / geminstall
Last active March 21, 2019 11:45
Install mysql2 gem for some special condition
I had this issue. Hope you have xcode command line installed. I had to to install some missing header files by
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
then
"Not really, just gem uninstall mysql2 and bundle install to install it back."
@holin
holin / configuration.rb
Created January 12, 2019 03:56
Configuration model
module Telegram
module Bot
class Configuration
attr_accessor :adapter
def initialize
@adapter = Faraday.default_adapter
end
end
end
@holin
holin / pre-commit
Created December 18, 2018 13:33
pre-commit hooks
#!/bin/sh
# This is a work-around to get GitHub for Mac to be able to run `node` commands
# https://stackoverflow.com/questions/12881975/git-pre-commit-hook-failing-in-github-for-mac-works-on-command-line
PATH=$PATH:/usr/local/bin:/usr/local/sbin
RESTORE='\033[0m'
RED='\033[00;31m'
YELLOW='\033[00;33m'
BLUE='\033[00;34m'
@holin
holin / init.d-sh
Created November 8, 2018 15:32
init.d
#!/usr/bin/env bash
### BEGIN INIT INFO
# Provides: wechat_message_bot
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the wechat_message_bots at boot
# Description: Enable at boot time.
### END INIT INFO
@holin
holin / print.css
Created October 1, 2018 01:40 — forked from anonymous/print.css
/**
* Print Stylesheet fuer Deinewebsite.de
* @version 1.0
* @lastmodified 16.06.2016
*/
@media print {
/* Inhaltsbreite setzen, Floats und Margins aufheben */
/* Achtung: Die Klassen und IDs variieren von Theme zu Theme. Hier also eigene Klassen setzen */
@holin
holin / us-state-post-code-map.rb
Created August 28, 2018 07:42
us-state-post-code-map.rb
~~~ruby
{"Alabama"=>"AL", "Alaska"=>"AK", "Arizona"=>"AZ", "Arkansas"=>"AR", "California"=>"CA", "Colorado"=>"CO", "Connecticut"=>"CT", "Delaware"=>"DE", "District of Columbia"=>"DC", "Florida"=>"FL", "Georgia"=>"GA", "Hawaii"=>"HI", "Idaho"=>"ID", "Illinois"=>"IL", "Indiana"=>"IN", "Iowa"=>"IA", "Kansas"=>"KS", "Kentucky"=>"KY", "Louisiana"=>"LA", "Maine"=>"ME", "Maryland"=>"MD", "Massachusetts"=>"MA", "Michigan"=>"MI", "Minnesota"=>"MN", "Mississippi"=>"MS", "Missouri"=>"MO", "Montana"=>"MT", "Nebraska"=>"NE", "Nevada"=>"NV", "New Hampshire"=>"NH", "New Jersey"=>"NJ", "New Mexico"=>"NM", "New York"=>"NY", "North Carolina"=>"NC", "North Dakota"=>"ND", "Ohio"=>"OH", "Oklahoma"=>"OK", "Oregon"=>"OR", "Pennsylvania"=>"PA", "Rhode Island"=>"RI", "South Carolina"=>"SC", "South Dakota"=>"SD", "Tennessee"=>"TN", "Texas"=>"TX", "Utah"=>"UT", "Vermont"=>"VT", "Virginia"=>"VA", "Washington"=>"WA", "West Virginia"=>"WV", "Wisconsin"=>"WI", "Wyoming"=>"WY ", "American Samoa"=>"AS", "Guam"=>"GU", "Marshall Islands"=>"MH"
@holin
holin / set-up-l2tp-ipsec-vpn-on-debian.md
Last active June 12, 2017 02:19 — forked from mietek/set-up-l2tp-ipsec-vpn-on-debian.md
Set up L2TP/IPsec VPN on Debian

Set up L2TP/IPsec VPN on Debian

Set up IPsec

Set up networking

@holin
holin / react-native.md
Created June 9, 2017 08:44
react native

EventEmitter

http://www.ghugo.com/react-native-event-emitter/

var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');

RCTDeviceEventEmitter.emit('change',text);

RCTDeviceEventEmitter.addListener('change',function(text){ me.setState({ text : text

@holin
holin / docker.md
Last active April 28, 2017 08:27
docker

remove not use container docker ps --filter "status=exited" | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm

restart policy sudo docker run -d --restart on-failure -p 8910:8910 --add-host testkj.aixuexi.com:101.200.88.81 phantomjs-ubuntu /bin/phantomjs --webdriver=8910

@holin
holin / composer.rake
Last active December 23, 2020 10:09
monit rails rake task
namespace :app do
desc "排版工作"
task :composer, [:start, :end] => :environment do |task, args|
keep_loop = true
puts "rake app:composer run. I have PID #{Process.pid}"
`echo "#{Process.pid}" > #{Rails.root}/tmp/composer.pid`
`echo "#{Process.ppid}" > #{Rails.root}/tmp/composer.ppid`