Skip to content

Instantly share code, notes, and snippets.

var cv = document.getElementById('cv');
var c = cv.getContext('2d');
var txtDiv = document.getElementById('txt');
var fileBtn = document.getElementById("up-button");
var img = new Image();
img.src = 'a.jpg';
img.onload = init; // 图片加载完开始转换
fileBtn.onchange = getImg;
// 根据灰度生成相应字符
# valid
aws cloudformation validate-template --template-body file://MyStack.json
# create stack
aws cloudformation create-stack --template-body file://Mystack.json --stack-name MyFirstStack
# create stack with parameter
aws cloudformation create-stack --template-body file://CloufFormationSample.json --stack-name MyFirstStack --parameters ParameterKey=KeyNameParameter,ParameterValue=HogeKeyPair
# update stack
@ultimate010
ultimate010 / init-server.sh
Created August 3, 2015 11:00
init-server.sh
# Install usefull software
sudo yum install -y aws-cli gcc git emacs vim tmux screen htop iotop iptraf curl
# Install lib for build python
sudo yum install -y openssl openssl-devel zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel patch
# Change sysctl
sudo sed -i 's/fs.file-max.*//' /etc/sysctl.conf
sudo sh -c 'echo "fs.file-max = 65535" >> /etc/sysctl.conf'
sudo sed -i 's/net.core.somaxconn.*//' /etc/sysctl.conf
@ultimate010
ultimate010 / nginx_init.sh
Created August 4, 2015 02:45
nginx_init.sh
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@ultimate010
ultimate010 / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ultimate010
ultimate010 / pptpd
Created August 4, 2015 10:11
pptpd
rpm -Uvh http://download.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm
yum -y install ppp pptpd
cp /etc/pptpd.conf /etc/pptpd.conf.bak
cat >/etc/pptpd.conf<<EOF
option /etc/ppp/options.pptpd
logwtmp
localip 10.0.10.1
remoteip 10.0.10.2-254
EOF
@ultimate010
ultimate010 / vpnsetup.sh
Last active August 29, 2015 14:26 — forked from hwdsl2/.MOVED.md
IPsec L2TP VPN Auto Install Script for Ubuntu 14.04 & 12.04 and Debian 8 & 7
#!/bin/sh
#
# Amazon EC2 user-data file for automatic configuration of IPsec/L2TP VPN server
# on a Ubuntu or Debian instance. Tested with Ubuntu 14.04 & 12.04 and Debian 8 & 7.
# With minor modifications, this script *can also be used* on dedicated servers
# or any KVM- or XEN-based Virtual Private Server (VPS) from other providers.
#
# DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC! THIS IS MEANT TO BE RUN WHEN
# YOUR AMAZON EC2 INSTANCE STARTS!
#
# Basic Strongswan ikev2 server setup
* paltform: atlantic.net ubuntu 14.04 x64
* the commands below are run with root account
## Strongswan
```
apt-get install strongswan
apt-get install iptables iptables-persistent
```
#!/usr/bin/expect -f
set timeout -1
if { ${argc} < 2 } {
send_user "Usage:\n"
send_user "\t${argv0} PASSWORD \[USER@\]HOST \[COMMAND1 \[; COMMAND2\] ...\]\n"
send_user "\n"
send_user "Default USER is current login\n"
send_user "Without any COMMAND, will get an interactive shell on the remote.\n"
send_user "With COMMAND(s), it will be run on the remote, and return the last command's status.\n"
sudo chown root:wheel /usr/local/bin/htop
sudo chmod u+s /usr/local/bin/htop