Skip to content

Instantly share code, notes, and snippets.

View ixqbar's full-sized avatar
💭
I may be slow to respond.

Well ixqbar

💭
I may be slow to respond.
View GitHub Profile
@ixqbar
ixqbar / AES.c
Last active August 29, 2015 14:24 — forked from bricef/AES.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>
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
@ixqbar
ixqbar / gist:6bb416cbee17e9f4c2ef
Created July 16, 2015 09:00
ngx_http_image_filter_module
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;
}
chown root.root /path/to/application
chmod u+s /path/to/application
while(1){
int ret = read(fd, buf, len);
if(ret == -1){
if(errno == EINTR){
continue;
}else if(errno == EAGAIN){
// 根据你和调用者的约定, 返回一个数值告诉它再次重试
// 一般是结合 select/epoll 等 IO 多路复用函数
}
exit(-1);
@ixqbar
ixqbar / gist:f68bc8ea9a7086f7259b
Created July 30, 2015 09:38
java之class array
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!
@ixqbar
ixqbar / gist:835f3fb9718ad01f00d3
Created August 28, 2015 01:53
java md5sum file
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];
#!/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
@ixqbar
ixqbar / gist:3b1d2713105d7567ac2e
Created October 14, 2015 02:34
color string to rgb
#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;
@ixqbar
ixqbar / gist:0250f08825fa4be225ce
Last active October 20, 2015 01:13
js get url paramters
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results==null){
return null;
} else{
return decodeURIComponent(results[1]) || 0;
}
}