Skip to content

Instantly share code, notes, and snippets.

View vejuhust's full-sized avatar
🎯
Focusing

Vej vejuhust

🎯
Focusing
  • Beijing, China
View GitHub Profile
@vejuhust
vejuhust / listdate.py
Created January 5, 2014 09:28
List past 20 days
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from datetime import datetime
from datetime import timedelta
now = datetime.now()
delta_day = timedelta(days = -1)
for i in range(21):
now += delta_day
@vejuhust
vejuhust / printallccode.sh
Last active December 15, 2015 09:19
print all c code in this folder
#!/bin/sh
TARGETFILE=allinone.c
if [ -e "$TARGETFILE" ]; then
rm -f "$TARGETFILE"
fi
if [ -n "$1" ]; then
printf "$1""\n" >> "$TARGETFILE"
@vejuhust
vejuhust / json_test.php
Last active December 14, 2015 07:09
a json testing controller in CodeIgniter.
<?php
class Json_test extends Controller {
public function setter() {
$fp = fopen("/tmp/json_test.txt","w");
$content = json_encode($_POST);
fwrite($fp, $content, strlen($content));
fclose($fp);
echo $content;
}
@vejuhust
vejuhust / rdtsc.c
Created October 5, 2012 06:03
Read Time Stamp Counter from Intel x86 CPU
#include <stdio.h>
int main (int argc, const char * argv[]) {
unsigned int hi;
unsigned int lo;
long double result;
/* Set *hi and *lo to the high and low order bits of the cycle counter.
Implementation requires assembly code to use the rdtsc instruction. */
asm("rdtsc; movl %%edx,%0; movl %%eax,%1" /* Read cycle counter */