This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* | |
* MCrypt API available online: | |
* http://linux.die.net/man/3/mcrypt | |
*/ | |
#include <mcrypt.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local client_ip = ngx.req.get_headers()["X-Forwarded-For"] | |
client_ip = string.match((client_ip or ngx.var.remote_addr), '[%d%.]+') | |
local passed = false | |
for allowed_ip in string.gmatch(ngx.var.allowed_ips, '([%d%.]+)') do | |
if client_ip == allowed_ip then | |
passed = true | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~* /img/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ { | |
set $h $2; | |
set $w $3; | |
if ($h = "0") { | |
rewrite /img/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ /img/$1.$4 last; | |
} | |
if ($w = "0") { | |
rewrite /img/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ /img/$1.$4 last; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chown root.root /path/to/application | |
chmod u+s /path/to/application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(1){ | |
int ret = read(fd, buf, len); | |
if(ret == -1){ | |
if(errno == EINTR){ | |
continue; | |
}else if(errno == EAGAIN){ | |
// 根据你和调用者的约定, 返回一个数值告诉它再次重试 | |
// 一般是结合 select/epoll 等 IO 多路复用函数 | |
} | |
exit(-1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gofuliwo.logserver; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
/** | |
* Hello world! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.security.MessageDigest; | |
public class TestCheckSum { | |
public static void main(String args[]) throws Exception { | |
String datafile = "c:\\INSTLOG.TXT"; | |
MessageDigest md = MessageDigest.getInstance("SHA1"); | |
FileInputStream fis = new FileInputStream(datafile); | |
byte[] dataBytes = new byte[1024]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Simple Redis init.d script conceived to work on Linux systems | |
# as it does use of the /proc filesystem. | |
REDISPORT=6379 | |
EXEC=/usr/local/bin/redis-server | |
CLIEXEC=/usr/local/bin/redis-cli | |
PIDFILE=/var/run/redis_${REDISPORT}.pid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
int main() | |
{ | |
// The hex code that should be converted ... | |
std::string hexCode; | |
std::cout << "Please enter the hex code: "; | |
std::cin >> hexCode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.urlParam = function(name){ | |
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); | |
if (results==null){ | |
return null; | |
} else{ | |
return decodeURIComponent(results[1]) || 0; | |
} | |
} |