Skip to content

Instantly share code, notes, and snippets.

@period331
period331 / test.py
Created Jul 17, 2020
命令行布局管理器 Python命令行下多行刷新
View test.py
# -*- coding:utf8 -*-
import time,sys
def progressbar():
print 'Loading...'
print "[+] start to build...."
height = 4
for i in range(0, 100):
if i > 0:
sys.stdout.write(u'\u001b[1A')
time.sleep(0.1)
View daemon_example.py
""" An example of a Linux daemon written in Python.
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
The changes are:
1 - Uses file open context managers instead of calls to file().
2 - Forces stdin to /dev/null. stdout and stderr go to log files.
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file.
4 - Omits try/excepts if they only wrap one error message w/ another.
@period331
period331 / fpm.d目录下的www.conf
Last active Apr 25, 2016
nginx-php开发环境配置
View fpm.d目录下的www.conf
;;;;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
; 只关注需要修改的配置;
;;;;;;;;;;;;;;;;;;;;;;;
; 以登陆用户的用户名和分组,避免权限问题
user = baocaixiong
group = staff
; The address on which to accept FastCGI requests.
View Nginx-Config-Pitfalls.md

原文

警告:请务必读完本文!全篇读完!

无论新老用户,都有可能掉进陷阱。 下面我们列出了常见的问题,并解释如何解决他们。 在 Freenode IRC 的 #nginx 频道,我们经常看到这些问题。

[TOC]

View nginx.sh
# /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
View proc.py
from multiprocessing import Process
import os
import time
import setproctitle
setproctitle.setproctitle('subprocess')
def targ(x):
setproctitle.setproctitle('subprocess_' + str(x))
print '这是一个进程任务' + str(os.getpid())
@period331
period331 / proc.py
Created Dec 11, 2013
python subProcess problem
View proc.py
# coding: utf8
from multiprocessing import Process
import os
import time
import setproctitle
setproctitle.setproctitle('subprocess')
def targ(x):
View gist:cd268e049616a762dfc5
#import <Foundation/Foundation.h>
@interface FKFruit : NSObject
@property(nonatomic, assign) double weight;
@property(nonatomic, assign) int a;
-(void) info;
@end
@period331
period331 / EqualTest.m
Created Dec 9, 2014
== and isEqual Objective-C
View EqualTest.m
#import <Foundation/Foundation.h>
int main(int argc, char * argv[])
{
@autoreleasepool {
NSString * str1 = @"hello";
NSString * str2 = [NSString stringWithFormat:@"hello"];
NSLog(@"str1 == str2 ??; %d", (str1 == str2)); // 输出 0