Skip to content

Instantly share code, notes, and snippets.

View thinkhy's full-sized avatar
🐕
On vacation

thinkhy thinkhy

🐕
On vacation
View GitHub Profile
@thinkhy
thinkhy / check_prime.c
Created June 17, 2012 07:18
Check prime number using C
#include <stdio.h>
#include <math.h>
#include <time.h>
int main()
{
int prime_count = 0;
int ceiling = 1000000;
int i = 0;
@thinkhy
thinkhy / MsgWaitForMultipleObjects.cpp
Created June 1, 2011 05:30
Win32 Waitable Timer and MsgWaitForMultipleObjects
////////////////////////////////////////////////////////////////////////////////////
HANDLE hTimer;
LARGE_INTEGER li;
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
const int nTimerUnitsPerSecond = 10000000;
li.QuadPart = -(30 * nTimerUnitsPerSecond);
@thinkhy
thinkhy / cdecl vs. stdcall
Created February 10, 2011 12:50
汇编代码由cl.exe /FAs输出
TITLE test.c
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
@thinkhy
thinkhy / store_pcap.go
Last active April 12, 2022 02:14
Read pcap file generated by tcpdump and store ip packet info to InfluxDB
package main
/* file: readPcap.go
* brief: read pcap file with gopacket package
* date: 2017-02-20
* creator: thinkhy
* reference: http://www.devdungeon.com/content/packet-capture-injection-and-analysis-gopacket
* TODO:
* 2017-02-22 Extract URL from HTTP packet
*/
[2019-11-27T09:27:07.046872000Z TRACE mio::sys::unix::kqueue] registering; token=Token(18446744073709551615); interests=Readable
[2019-11-27T09:27:07.047121000Z TRACE mio::poll] registering with poller
[2019-11-27T09:27:07.047146000Z TRACE mio::sys::unix::kqueue] registering; token=Token(0); interests=Readable
[2019-11-27T09:27:07.075663000Z INFO http3_client] connecting to 127.0.0.1:4433 from 127.0.0.1:57689with scid 11f3609530bd0ba68ad74e4882855455005e13dd
[2019-11-27T09:27:07.075947000Z TRACE quiche::tls] 11f3609530bd0ba68ad74e4882855455005e13dd tls writemessage lvl=Initial len=512
[2019-11-27T09:27:07.076042000Z TRACE quiche] 11f3609530bd0ba68ad74e4882855455005e13dd tx pkt Initialversion=babababa dcid=688a56ec5134560e9813fb2f61e32c53 scid=11f3609530bd0ba68ad74e4882855455005e13dd len=1153 pn=0
[2019-11-27T09:27:07.076101000Z TRACE quiche] 11f3609530bd0ba68ad74e4882855455005e13dd tx frm CRYPTO off=0 len=512
[2019-11-27T09:27:07.076132000Z TRACE quiche] 11f3609530bd0ba68ad74e4882855455005e13dd tx frm PADDIN
@thinkhy
thinkhy / gist:774395
Created January 11, 2011 13:13
CopyFile_Perl
####################################################################################
# Description: Copy error files to another directory
# Usage:
# Creator: thinkhy
# Date: 2010.01.13
####################################################################################
use strict;
use warnings;
use Cwd;
@thinkhy
thinkhy / xhtml2ooxml.pl
Created July 10, 2011 08:07
Convert XHTML to OOXML
#!/usr/bin/perl -w
#################################################################
# filename: xhtml2ooxml.pl
# brief: Convert xhtml to ooxml format for Founder WordEditor
# creator: thinkhy
# date: 11/06/23
# changelog:
#
#################################################################
use Cwd;
@thinkhy
thinkhy / subjcl.pl
Created June 17, 2012 13:00
Submit JCL to JES from local file or mainframe.
#########################################################################################################
# File: subjcl.pl
# Brief: Submit JCL to JES from local file or mainframe.
#
# Usage: sub.pl [-d DSN|-f FILE] -s SERVER -u USER -p PWD
# -d DSN dataset name of JCL
# -f FILE local JCL file
# NOTICE: Must choose a dataset name or local file to specify the source of JCL.
#
# -s SERVER specify server logged into
@thinkhy
thinkhy / tedSubtitle.pl
Last active October 6, 2017 14:59
Get subtitle for TED video
#!/usr/local/bin/perl
################################################################################
# File: tedSubtitle.pl
# Desscription: Get ted talk's subtitle from TED.com
# and convert subtitle of TED video to SRT format(SubRip Subtitle File)
# Usage: ted.pl URL languageCode output.src
# Creator: Thinkhy
# Date: 2011.04.30
# ChangeLog: 1 Add language code. [thinkhy 2011.05.06]
# 2 Read advertisement time from the parameter of introDuration in html.