Skip to content

Instantly share code, notes, and snippets.

View cxfksword's full-sized avatar

cxfksword

  • China
  • 12:25 (UTC +08:00)
View GitHub Profile
// Please write an sequence list implements the interface with the required
// time complexity described in the comments. The users can add the same
// element as many times as they want, but it doesn't support the null item.
// You can use any types in .NET BCL but cannot use any 3rd party libraries.
// PS: You don't need to consider the multi-threaded environment.
interface void IMyList<T> : IEnumerable<T>
{
// O(1)
// Add an item at the beginning of the list.
void AddFirst(T item);
@cxfksword
cxfksword / RemoveMultipleSpaces.cs
Created March 28, 2012 17:35 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
if (baseStr == null)
throw new ArgumentNullException("baseStr");
@cxfksword
cxfksword / gist:8883795
Created February 8, 2014 13:34
C#中执行windows显示桌面命令
public static bool ToggleDesktop()
{
var success = true;
Type shellType = Type.GetTypeFromProgID("Shell.Application");
if (shellType != null)
{
try
{
object shellObject = Activator.CreateInstance(shellType);
shellType.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, shellObject, null);
#!/bin/bash
# How to install Graphite as a user on CentOS 5.5 (with neither internet access and root account)
# --------------------------------------------------------------------------------
# Tomasz Kalkosiński - refaktor.blogspot.com
#
# Graphite is a Scalable Realtime Graphing (http://graphite.wikidot.com/)
# This script is based on two excellent tutorials:
# http://community.webfaction.com/questions/10038/how-to-install-pycairo-in-python27-thanks
@cxfksword
cxfksword / get_user_home.php
Created March 20, 2014 10:07
get user home path in php cli
function getUserHomePath() {
if (isset($_SERVER['HOME'])) {
return $_SERVER['HOME'];
}
if (PHP_OS == 'WINNT') {
return getenv('USERPROFILE');
} else {
return getenv('HOME');
}
@cxfksword
cxfksword / syscall
Last active August 29, 2015 14:03
golang 在windows上执行syscall调用dll相关资料
//http://golang.org/src/pkg/syscall/dll_windows.go
//http://golang.org/src/pkg/runtime/syscall_windows_test.go?h=int
//http://golang.org/src/pkg/syscall/syscall_windows.go
//http://wendal.net/2013/0406.html
//http://outofmemory.cn/code-snippet/3006/golang-call-API-liechu-window-suo-exist-run-process
// char -> byte
// char* -> *byte
// wchar_t/LCHAR -> uint16
// wchar_t/LPCHAR -> *uint16
// LPARAM -> uintptr
@cxfksword
cxfksword / backadmin.md
Last active August 29, 2015 14:04
管理后台开发类库
server
{
listen 8000;
index index.html index.htm index.php;
root /data/wwwroot/XuanAdmin/current;
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
@cxfksword
cxfksword / logrotate.sh
Last active August 29, 2015 14:06
nginx logrotate日志滚动处理
#!/bin/bash
# 更改nginx日志为带日期的文件名
log_dir="/var/log/jbmon/backup/apache"
new_dir="/var/log/jbmon/backup/apache"
date_dir=`date +%Y%m%d%H -d '-1 hours'`
yearstr=`date +%Y%m%d`
FILES=${log_dir}/*.log
for f in ${FILES}
@cxfksword
cxfksword / sublime_user_setting
Last active March 9, 2016 02:21
sublime text配置
{
"color_scheme": "Packages/User/SublimeLinter/Seti_monokai (SL).tmTheme",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
"*.o",