Skip to content

Instantly share code, notes, and snippets.

@jhjguxin
jhjguxin / nginx-403-forbidden-error-hosting-in-user-home-directory.md
Created August 12, 2013 05:40
nginx 403 forbidden error when server static file under user home directory
@jhjguxin
jhjguxin / gpg-tour.md
Created July 19, 2013 08:18
GPG 加密解密简明教程 </br> 作者: riku / 本文采用CC BY-NC-SA 2.5协议 授权

GPG 加密解密简明教程

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

名词解释

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

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

@jhjguxin
jhjguxin / Activate Office 2019 for macOS VoL.md
Created October 5, 2023 14:23 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref

@jhjguxin
jhjguxin / gx_app.rb
Last active October 4, 2023 14:58
Mongoid localized fields, and how use it
# encoding: UTF-8
class GxApp
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Sequence
store_in session: "gxservice"
field :name, type: String, default: "Guanxi.me"
field :version, type: String
@jhjguxin
jhjguxin / how-to-check-and-find-your-linux-os-version.md
Created August 1, 2013 11:15
HOW TO CHECK AND FIND YOUR LINUX OS VERSION?

Linux and Unix operating systems comes in a wide range of flavors often bundled as different distributions by different vendors. Every one of these distribution also comes with an often pre-defined and latest version of the Linux kernel. Sometimes you need to know the exact name and version of your operating system, machine as well as the kernel, be it to install the correct version of a software, find if a hardware is compatible or be it to upgrade your OS itself. There are several ways to check your operating system and linux kernel versions. As each distribution (or distros) are slightly different some of the commands might work in some distros while some maynot.

uname

uname is the linux command which prints out the name, versions and other details of the machine and kernel running on the machine. It is basically short for Unix Name. This is usually part of the core-utils package and should be available on almost all distros. There are several options available to print out just the kernel detail

@jhjguxin
jhjguxin / user_observer.rb
Created June 3, 2013 06:16
cache devise's current_user method, speed up page's load, used for guanxi_cms, Suitable for devise 2.x - 3.x, Rails 3.x
class UserObserver < Mongoid::Observer
def after_save(record)
expire_cache(record)
end
private
def expire_cache(record)
Rails.cache.delete("user:#{record.id}")
end
@jhjguxin
jhjguxin / creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
Created July 9, 2012 03:32
Creating nested resources in ruby on rails 3 and updating scaffolding links and redirection
@jhjguxin
jhjguxin / how_to_display_and_kill_zombie_processes.md
Last active December 20, 2022 19:32
Zombie processes are undead, scary killing them isn't so easy

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 October 27, 2015 07:18 — forked from niallsmart/linebreak.rb
Axlsx line break
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 July 13, 2022 10:37
通过show status 来优化MySQL数据库 from lxneng
  1. 查看MySQL服务器配置信息
mysql> show variables;
  1. 查看MySQL服务器运行的各种状态值
mysql> show global status;