Skip to content

Instantly share code, notes, and snippets.

aleiphoenix

Block or report user

Report or block aleiphoenix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aleiphoenix
aleiphoenix / mongo.demo.php
Created Apr 9, 2012
mongodb connection demo for php
View mongo.demo.php
<?php
error_reporting(E_ALL);
$m = new Mongo("mongodb://127.0.0.1:27017");
$db = $m->selectDB("test");
$coll = $db->selectCollection("foo");
@aleiphoenix
aleiphoenix / gd.cropimage.php
Created Jun 4, 2012
crop_image in gd equivalent to cropImage in imagick
View gd.cropimage.php
<?php
function cropImage ($image, $width, $height, $x, $y) {
list($w, $h) = getimagesize($image);
$nw = (($width + $x) >= $w) ? $w - $x : $width;
$nh = (($height + $y) >= $h) ? $h - $y : $height;
// var_dump($nw);
// var_dump($nh);
@aleiphoenix
aleiphoenix / poll.js
Created Jul 3, 2012
loop for calling a function
View poll.js
var a = function (i) {
console.log(i)
setTimeout(a(++i), 1000); // wrong, the 1st parameters should be a function but passed a function calling by mistaken.
}
@aleiphoenix
aleiphoenix / poll.js
Created Jul 3, 2012
loop for calling a function
View poll.js
var a = function (i) {
console.log(i)
setTimeout(function () {
a(++i);
}, 1000); // now correct
}
View truble.shooting.of.scribe.markdown

truble shooting of scribe

依赖

  • 整体
    • 这些依赖是必须的,以RHEL/CentOS举例
yum install automake libtool flex bison pkgconfig gcc-c++ libevent-devel
@aleiphoenix
aleiphoenix / socket.crossdomain.py
Created Jul 19, 2012
simple socket server for serving flash crossdomain policy
View socket.crossdomain.py
import errno
import functools
import socket
from tornado import ioloop, iostream
def connection_ready(sock, fd, events):
while True:
try:
connection, address = sock.accept()
except socket.error, e:
@aleiphoenix
aleiphoenix / lpfc_scsi.c.patch
Created Aug 31, 2012
patching drivers/scsi/lpfc/lpfc_scsi.c for kernel 3.4.9 gentoo workaround with -Werror while compile WITH CONFIG_LPFC_SCSI
View lpfc_scsi.c.patch
--- /usr/src/linux/drivers/scsi/lpfc/lpfc_scsi.c 2012-05-21 06:29:13.000000000 +0800
+++ lpfc_scsi.c 2012-08-31 21:12:33.619966584 +0800
@@ -1897,7 +1897,6 @@
dma_addr_t physaddr;
int i = 0, num_bde = 0, status;
int datadir = sc->sc_data_direction;
- uint32_t rc;
uint32_t checking = 1;
uint32_t reftag;
unsigned blksize;
@aleiphoenix
aleiphoenix / screenshot
Last active Apr 24, 2019
a script using ImageMagick to take screenshots
View screenshot
#!/bin/bash
DIR="${HOME}/images/screenshots"
DATE="$(date +%Y%m%d-%H%M%S)"
NAME="${DIR}/screenshot-${DATE}.png"
LOG="${DIR}/screenshots.log"
# Check if the dir to store the screenshots exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir -p "${DIR}"; fi
@aleiphoenix
aleiphoenix / create.exif.php
Created Oct 30, 2012
php using PEL manipulate the exif data
View create.exif.php
<?php
error_reporting(E_ALL);
$root_path = dirname(__FILE__);
$lib_path = $root_path . "/lib/";
include_once($lib_path . 'PelJpeg.php');
include_once($lib_path . 'PelTag.php');
include_once($lib_path . 'PelIfd.php');
@aleiphoenix
aleiphoenix / post.py
Last active Dec 3, 2019
urlopen with proxy support
View post.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import urllib2
data = urllib2.urlencode({'foo': 'bar'})
r = urllib2.Request('https://www.google.com', # url
data, # post data
You can’t perform that action at this time.