Skip to content

Instantly share code, notes, and snippets.

View codeachange's full-sized avatar

noname codeachange

View GitHub Profile
@codeachange
codeachange / ssh_reverse_tunnel.sh
Last active September 29, 2017 16:04
ssh reverse tunnel
# ssh反向隧道,实现NAT穿透
# 在局域网内执行
# 把局域网内的 192.168.1.100:443 暴露到 138.47.99.99:19999
ssh -R 19999:192.168.1.100:443 [email protected]
# 暴露后的 138.47.99.99:19999 貌似只能本地访问,即 telnet localhost 19999 是通的,远程 telnet 138.47.99.99 19999 不通
# 如果只是做ssh跳板机,上面就够了,先ssh到138.47.99.99再ssh localhost -p 19999
# 如果要实现网页访问,即远程通过公网IP访问19999端口
# 安装
yum install postgresql-server postgresql-contrib
# 初始化
postgresql-setup initdb
# ident 改为 md5,ident是使用系统账号验证; md5使用单独的数据库账号
vi /var/lib/pgsql/data/pg_hba.conf
# 开机启动
  1. wget linux rpm
  2. yum install rpm
  3. run teamviewer setup
/*
From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
Generators compute their yielded values on demand, which allows them to efficiently
represent sequences that are expensive to compute, or even infinite sequences as
demonstrated above.
The next() method also accepts a value which can be used to modify the internal state
of the generator. A value passed to next() will be treated as the result of the last
yield expression that paused the generator.
// insert and return id
@Insert("INSERT INTO photo_category (uuid, album_uuid, name, status, addtime, modtime) VALUES (" +
"REPLACE(UUID(), '-', ''), #{albumUuid}, #{name}, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())")
@SelectKey(before = false, keyProperty = "id", statement = "SELECT LAST_INSERT_ID()", resultType = Integer.class)
void insert(PhotoCategoryDO item);
// return HashMap
@ResultType(value = java.util.HashMap.class)
HashMap getSumDismissionRate(@Param("companyId") String companyId, @Param("yearmo") Integer yearmo);
@codeachange
codeachange / mac-book-config.md
Created March 29, 2017 09:08
my-mac-book-config

software

  • Cinch 窗口最大化
@codeachange
codeachange / install-nwjs-on-mac-osx.md
Created March 21, 2017 17:17
install nwjs on MAC OSX
  • 下载SDK版文件 https://nwjs.io/
  • 解压后把 nwjs.app 移动到应用程序目录,其他的可以删了
  • 创建 alias alias nw="/Applications/nwjs.app/Contents/MacOS/nwjs"

Restrict SFTP users to home folder

Here is a guide for setting up SFTP users who’s access is restricted to their home directory.

Add the following to the end of the /etc/ssh/sshd_config file:

Subsystem sftp internal-sftp

# This section must be placed at the very end of sshd_config
@codeachange
codeachange / java_rsa.java
Created December 5, 2016 03:40
RSA encrypt and decrypt in JAVA
package tests;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.PrivateKey;
@codeachange
codeachange / str-helper.php
Created May 31, 2016 10:21 — forked from irazasyed/str-helper.php
PHP: Wildcard String Match Checker - Laravel 4
<?php
/**
* Ported from Laravel 4 for external usage.
*/
function is($pattern, $value) {
if ($pattern == $value) return true;
$pattern = preg_quote($pattern, '#');