Skip to content

Instantly share code, notes, and snippets.

Yuanhao Luo ictlyh

Block or report user

Report or block ictlyh

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
@ictlyh
ictlyh / OutlookSubjectAndAttachmentChecking
Created Jul 29, 2017
Check whether email has a subject and attachment for Outlook
View OutlookSubjectAndAttachmentChecking
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim lngres As Long
'检查邮件是否添加附件
If InStr(1, Item.Body, "附件") <> 0 Then
If Item.Attachments.Count = 0 Then
Application.Explorers(1).Activate
lngres = MsgBox("邮件内容中包含“附件”,但没有上传附件!" & Chr(10) & "仍然发送?", _
vbYesNo + vbDefaultButton2 + vbQuestion, "提示")
If lngres = vbNo Then
@ictlyh
ictlyh / list_server_variable.php
Created Apr 5, 2017
PHP to list server variables of predefined variable $_SERVER
View list_server_variable.php
<?php
/* Try http://mutouxiaogui.cn/blog/list_server_variable.php?v1=1&v2=2 in your browser */
$indicesServer = array('PHP_SELF',
'argv',
'argc',
'GATEWAY_INTERFACE',
'SERVER_ADDR',
'SERVER_NAME',
'SERVER_SOFTWARE',
'SERVER_PROTOCOL',
@ictlyh
ictlyh / list_server_variable.php
Created Apr 5, 2017
PHP to list server variables of predefined variable $_SERVER
View list_server_variable.php
<?php
/* Try http://mutouxiaogui.cn/blog/list_server_variable.php?v1=1&v2=2 in your browser */
$indicesServer = array('PHP_SELF',
'argv',
'argc',
'GATEWAY_INTERFACE',
'SERVER_ADDR',
'SERVER_NAME',
'SERVER_SOFTWARE',
'SERVER_PROTOCOL',
@ictlyh
ictlyh / redirect.php
Last active Apr 5, 2017
PHP page redirect with parameters
View redirect.php
<?php
/* redirect mutouxiaogui.cn/blog to stay-stupid.com, the parameters remain unchanged */
/* notify search engines that a page has been permanently moved to another location */
header('Status: 301 Moved Permanently', false, 301);
/* redirect to another page */
$redirect_url = 'http://stay-stupid.com/'.basename($_SERVER['REQUEST_URI']);
header('Location: '.$redirect_url);
@ictlyh
ictlyh / libpq-epoll.cpp
Created Dec 30, 2016
postgresql epoll demo
View libpq-epoll.cpp
/*
* Demo of libpq epoll.
* Build: g++ libpq-epoll.cpp -o libpq-epoll -lpq
* Run: ./libpq-epoll
*/
#include <arpa/inet.h>
#include <cstdlib>
#include <cstring>
#include <errno.h>
View test-gflag.cc
/*
* Demo of gflags
* Build: g++ test-gflags.cc -o test-gfalgs -lgflags
* // ERROR: illegal value '-1' specified for uint64 flag 'u64'
* ./test-gflags.out --b=false --i32=-1 --i64=1 --u64=-1 --d=10.01 -s="string value"
* // ERROR: failed validation of new value '11' for flag 'i32'
* ./test-gflags.out --b=false --i32=11 --i64=1 --u64=1 --d=10.01 -s="string value"
* ./test-gflags.out --b=false --i32=1 --i64=1 --u64=1 --d=10.01 extraa extrab extrac
*
* Refer to gflags.h for more detail help message of structs and function.
@ictlyh
ictlyh / test-glog.cc
Created Nov 30, 2016
glog(google log system for cpp) demo
View test-glog.cc
/*
* Demo of glog.
* Build: g++ test-glog.cc -o test-glog.out -lglog
* Run: export GLOG_log_dir=/path/to/logdir && ./test-glog
*/
#include <glog/logging.h>
int main(int argc, char* argv[]) {
google::InitGoogleLogging(argv[0]);
@ictlyh
ictlyh / producer-consumer
Created Nov 30, 2016
Producer and consumer demo in concurrent queue. c++ multi-threading.
View producer-consumer
// concurrent-queue.h
#ifndef CONCURRENT_QUEUE_H_
#define CONCURRENT_QUEUE_H_
#include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
template <typename T>
View whiptail-demo.sh
#!/bin/bash
# Demo of check list using whiptail
whiptail --title "Check list example" --checklist \
"Choose user's permissions" 20 78 4 \
"NET_OUTBOUND" "Allow connections to other hosts" ON \
"NET_INBOUND" "Allow connections from other hosts" OFF \
"LOCAL_MOUNT" "Allow mounting of local devices" OFF \
"REMOTE_MOUNT" "Allow mounting of remote devices" OFF
@ictlyh
ictlyh / test-handlezombie.c
Last active Nov 30, 2016
Demo of handling zombie process.
View test-handlezombie.c
/*
* Demo of handling zombie process.
* Build: gcc test-handlezombie.c -o test-handlezombie
* Run: ./test-handlezombie
*/
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
You can’t perform that action at this time.