Skip to content

Instantly share code, notes, and snippets.

@jsfaint
jsfaint / Question.txt
Created August 1, 2013 07:21
An bash script resolve the topic described in "Question.txt"
Description
Assume there is a directory contains student records regarding to different courses. These files have “.rec” extension. Each file belongs to a course and has the following format:
COURSE NAME: <the name of the course>
CREDITS: <credits>
Student# <a list of numbers belong to different activities have been done in the course>
For example a course record file can be like this:
COURSE NAME: Operating Systems
@jsfaint
jsfaint / gif2bin.c
Created May 27, 2014 03:10
Convert gif to binary file.
/*
v0.3 implement getFileName(), optimize output file.
v0.2 add multi file support
v0.1 first demo
*/
#include <string.h>
#include <stdio.h>
void getFileName(const char *szFullName, char *szFileName);
@jsfaint
jsfaint / bcd2dec.c
Created May 27, 2014 03:18
BCD code to decimal
#include <stdio.h>
unsigned char bcd2dec(unsigned char c);
unsigned char bcd2dec(unsigned char c)
{
unsigned char dec;
dec = (c>>4) & 0x07;
dec = (dec<<3) + (dec<<1) + (c & 0x0F);
#include <cstdio>
const int max = 65000;
const int lineLength = 12;
void fibonacci( int max )
{
if ( max < 2 )
return;
#include <stdio.h>
#define NO_OF_PORTS 8
#define TRUE 1
#define FALSE 0
static long pow(int x, int y)
{
int ii;
long result = 1;
@jsfaint
jsfaint / parse_ip.c
Created May 27, 2014 03:30
Parse IP address
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char u_char;
typedef unsigned char uchar;
typedef unsigned long u_long;
typedef unsigned long ip_addr;
typedef unsigned short ushort;
@jsfaint
jsfaint / gif2c.c
Created May 27, 2014 03:31
Convert gif to C file
/*
* gif2c.c
* convert gif file to c file.
* support multi file one time.
*
* author: jason([email protected])
* date: 2009.03.30
*
*/
#include <windows.h>
#include <stdio.h>
BOOL DisplaySystemVersion()
{
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
//
@jsfaint
jsfaint / yaDeskView.c
Created June 20, 2014 09:32
Yet Another DeskView
//deskview.exe cosplay
//[2008-09-11 jason [email protected]]
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pszCmdLine, int cmdShow)
{
HWND hwnd = FindWindowEx(FindWindowEx(FindWindow("Progman", NULL), 0, "SHELLDLL_DefView", NULL), 0, "SysListView32", NULL);
int iStyle = GetWindowLong(hwnd, GWL_STYLE);
/*++
Module Name:
write_ver.c
Abstract:
Add version string in wrp file header for VSC7398.
A part of auto provision function implement.
Author:
jason ([email protected]) Dec-01-2009