Skip to content

Instantly share code, notes, and snippets.

Avatar

jhjguxin jhjguxin

View GitHub Profile
@jhjguxin
jhjguxin / gpg-tour.md
Created Jul 19, 2013
GPG 加密解密简明教程 </br> 作者: riku / 本文采用CC BY-NC-SA 2.5协议 授权
View gpg-tour.md

GPG 加密解密简明教程

大家都知道,互联网上充斥着大量的明文传输方式,可以说绝对是不安全地带。那么,我们如何保证在不安全的互联网中更可靠的传输重要数据呢?个人认为最好的方式之一就是使用 GPG 工具进行加密。此文只是简单介绍了 GPG 的常规用法,重在推广和普及 GPG 加密工具,详细的使用请参见 GPG 手册。

名词解释

RSA / DSA / ElGamal : 是指加密算法

GPG :(全称 GnuPG ) 是一款非对称加密(PGP)的免费软件,非对称加密方式简单讲就是指用公钥加密文件,用私钥解密文件。如果你想给谁发送加密信息,首先你要得到他的公钥,然后通过该公钥加密后传给他,对方利用自已的私钥就可解密并读取文件了。

@jhjguxin
jhjguxin / creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
Created Jul 9, 2012
Creating nested resources in ruby on rails 3 and updating scaffolding links and redirection
View creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
@jhjguxin
jhjguxin / how_to_display_and_kill_zombie_processes.md
Last active Dec 20, 2022
Zombie processes are undead, scary killing them isn't so easy
View how_to_display_and_kill_zombie_processes.md

How to display and kill zombie processes

finding if zombies exist

  • execute the top command
  • one line is tasks:
    • Example output: Tasks: 63 total, 1 running, 61 sleeping, 0 stopped, 1 zombie

Who is zombie

@jhjguxin
jhjguxin / linebreak.rb
Created Oct 27, 2015 — forked from niallsmart/linebreak.rb
Axlsx line break
View linebreak.rb
require 'axlsx'
Axlsx::Package.new do |package|
workbook = package.workbook
workbook.add_worksheet do |sheet|
wrap = workbook.styles.add_style alignment: {wrap_text: true}
sheet.add_row ["Foo\r\nBar", "Foo\rBar", "Foo\nBar", "Foo\n\r\nBar"], style: wrap
end
package.serialize "linebreak.xlsx"
@jhjguxin
jhjguxin / mysql-status.md
Last active Jul 13, 2022
通过show status 来优化MySQL数据库 from lxneng
View mysql-status.md
  1. 查看MySQL服务器配置信息
mysql> show variables;
  1. 查看MySQL服务器运行的各种状态值
mysql> show global status;
@jhjguxin
jhjguxin / replace_words.rb
Created Jul 3, 2013
Read, edit, and write a text file line-wise using Ruby
View replace_words.rb
# http://stackoverflow.com/questions/4397412/read-edit-and-write-a-text-file-line-wise-using-ruby
# files = Dir.glob(File.dirname(__FILE__)+"/../app/**/*.rb")
files = Dir[Rails.root.join("app", "**/*.rb")]
files.each do |f_name|
# puts f_name
File.open(f_name, "r+") do |f|
old_pos = 0
f.each do |line|
@jhjguxin
jhjguxin / mongodb_replication_master.markdown
Last active Mar 14, 2022
how switch master/slave between replSet model on mongodb some prepare for migrate database from grandcloud to aliyun clound
View mongodb_replication_master.markdown
@jhjguxin
jhjguxin / rails3_with_dalli.md
Created Nov 19, 2013
Config Rails 3 with dalli(memcahed)
View rails3_with_dalli.md

Config Rails 3 with dalli(memcahed)

To install dalli in your Rails 3 app, simply add the following to your Gemfile and run bundle install.

# Gemfile
gem "dalli", "~> 2.6.4",   :platforms => :ruby

To setup Rails to use the Dalli client for production, add the following to config/environments/production.rb: