Skip to content

Instantly share code, notes, and snippets.

@cyanife
cyanife / readme.md
Created July 24, 2018 00:34
Django redirect to original page after post

You can add a next field to your form, and set it to request.path. After you processed your form you can redirect to the value of this path.

template.html

<form method="POST">
    {% csrf_token %}
    {{ form }}
    <input type="hidden" name="next" value="{{ request.path }}">
    <button type="submit">Let's Go</button>
@cyanife
cyanife / README.md
Last active July 19, 2018 12:37
[ Using nginx with docker-compose ] #nginx #docker

in nginx.conf:

remind that in a nginx docker container 127.0.0.1 or localhost means the container itself.

nginx container consider all other container as individual hosts in the same network.

when a container's internal port is exposed to a host port, the "host" means docker's physical host operation system, not nginx's container!

so we can't use proxy-pass like "proxy-pass : 127.0.0.1:8080" because nginx docker will recognize "127.0.0.1" as itself.

@cyanife
cyanife / autobak.cmd
Last active October 22, 2017 06:49
Minecraft autobackup script(with Bandizip, Windows 10 SimpCHN)
@ECHO OFF
SETLOCAL
::Minecraft backup script
::(ORIGIN)You need to install 7-Zip first. It can be found here: http://www.7-zip.org/
::(REMASTARED) Using Bandizip instead.
::Please check the path section first before running!
::---------------------------------------------------------------------------------------------------------------------------------------------------------
::Path section
@cyanife
cyanife / bash-invocation.md
Created June 14, 2016 09:22 — forked from yegle/bash-invocation.md
Bash Shell启动方式与RC脚本

Bash Shell启动方式与rc脚本

Shell的不同分类

根据启动Bash Shell的方式不同,对Shell有两种分类方式

登录Shell与非登录Shell

根据Shell的启动方式不同,可以将Shell分为

@cyanife
cyanife / Shadowsocks服务端性能优化.md
Created April 7, 2016 07:21
Shadowsocks服务端性能优化

#Shadowsocks服务端性能优化(CentOS6)

##ss加密算法 常用算法aes-256-cfb速度较慢,在路由器等arm平台表现不佳。 用于arm平台时,采用算法rc4-md5即可。 "method":"rc4-md5" 为加速加密速度,安装m2crypto

yum install m2crypto
@cyanife
cyanife / CentOS_shadowsocks_cyanife
Last active April 7, 2016 06:52
[SHELL]CentOS_SS-libev_install_script
#!/bin/bash
#===============================================================================================
# System Required: CentOS6.x (32bit/64bit)
# Description: Install Shadowsocks-libev server for CentOS 6.X
# Author: Cyanife <[email protected]>
# Note: Modified from tennfy<[email protected]>'s debian script, thanks!
#===============================================================================================
clear
echo "###################################################################"
@cyanife
cyanife / C#_console_unicode
Last active February 29, 2016 13:13
[C#] Write Unicode character in windows console.
using System.Runtime.InteropServices;
using System.IO;
namespace foo
{
class bar
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleOutputCP(int newcp);
static void Main(string[] args)