Skip to content

Instantly share code, notes, and snippets.

View 0xeuclid's full-sized avatar

0xeuclid 0xeuclid

  • Taipei, Taiwan
View GitHub Profile
@0xeuclid
0xeuclid / init_list.c
Created April 23, 2013 12:08
This program demo how INIT_LIST works in EFI system. By using typedef (FUNC_POINTER)(fun_arg1,fun_arg2,...) We can write make as BootOptionDpMatchingFunctions = \ LocateDevicePathTest,\ PartitionDevicePathTest,\ UsbClassDevicePathTest,\ BbsDevicePathTest,\ AmiBbsDevicePathTest,\ AmiDeviceNameDevicePathTest,\ DeviceTypeDevicePathTest, And there'…
/*********************************************************
[Name]:
init_list.c
[Description]:
This is example to describe:
[Author]:
[email protected]
[Revision]: 2013/4/23 下午 07:41:52
@0xeuclid
0xeuclid / invoice_expected_value.rb
Created November 26, 2012 07:23
compute expected value of Taiwan invoice
=begin
#--- OUTPUT :
0.1
0.02
0.005999999999999999
0.012
0.030000000000000002
0.12000000000000001
0.3
1.0
@0xeuclid
0xeuclid / Simple function as argument.c
Created October 26, 2012 09:41
Simple function as argument.
//Simple function as argument.
// [email protected]
#include<stdio.h>
double f(double x);
double sum_square(double (*)(double x), int lower, int upper) ;
int main(){
printf("%lf\n",sum_square(f,1,10));
return 0;
//**********************************************************************
//** Easy Example for describing the usage of function pointer in C **
//**********************************************************************
#include<stdio.h>
//A simple funtion which return its parameter.
int p(int x){ return x ;}
typedef int (*functionPointer)(int x) ;
typedef struct _Interface {
@0xeuclid
0xeuclid / classic_algorithm.cpp
Created September 11, 2012 13:36
classic_algorithm.cpp
//常用算法经典代码(C++版)
//*快速排序
void qsort(int x,int y) //待排序的数据存放在a[1]..a[n]数组中
{//调用:qsort(1,n)即可实现数组a中元素有序。适用于n比较大的排序
int h=x,r=y;
int m=a[(x+y)>>1]; //取中间的那个位置的值
@0xeuclid
0xeuclid / prime_2_100.rb
Created August 29, 2012 16:05
Find prime numbers
=begin
If you want to find prime numbers less than N
then use each prime number form 2 to N**0.5 to test.
=end
print "2, 3, 5, 7, "
for i in (10..100)
if (i%2 != 0 and i%3 != 0 and i%5!=0 and i%7!=0)
print "#{i}, "
end
@0xeuclid
0xeuclid / base_8_16.c
Created August 28, 2012 16:26
interview test
#include<stdio.h>
int main(){
int i = 0 ;
printf("Plz enter a number:") ;
scanf("%d",&i) ;
printf("Base_10: %d\n",i) ;
printf("Base_8: %o\n",i) ;
printf("Base_16: %x\n",i) ;
return 0;
}