Skip to content

Instantly share code, notes, and snippets.

View YukiSakamoto's full-sized avatar

Yuki Sakamoto YukiSakamoto

  • Osaka, Japan
  • 02:57 (UTC +09:00)
View GitHub Profile
@YukiSakamoto
YukiSakamoto / clistup.c
Created September 12, 2012 11:21
pass numpy-object into C modules via cython
#include <stdio.h>
void listup(int *array, int size)
{
int i;
for(i = 0; i < size; i++) {
printf("%d\n", *(array + i));
}
}
@YukiSakamoto
YukiSakamoto / random.c
Created September 24, 2012 14:22
Disable ASLR on MacOSX
#include <stdio.h>
/*
This source is testing for address layout randomization.
If ASLR is enabled, output of this program will be variable.
*/
int main(void)
{
printf("%p\n", main);
@YukiSakamoto
YukiSakamoto / random.c
Created October 21, 2012 02:32
Disable ASLR secondver.
#include <stdio.h>
/*
This source is testing for address layout randomization.
If ASLR is enabled, output of this program will be variable.
*/
int main(void)
{
printf("%p\n", main);
@YukiSakamoto
YukiSakamoto / disasm.c
Created November 1, 2012 16:13
use libudis86
#include <stdio.h>
#include <udis86.h>
void fill_nop(unsigned char *array, size_t size)
{
int i;
if (array != NULL && 0 < size) {
for(i = 0; i < size; i++) {
*(array + i) = (unsigned int) 0x90;
}
@YukiSakamoto
YukiSakamoto / makefile
Created November 6, 2012 15:54
json parsing via pficommon::text::json
all:
g++ ./test_json.cpp -lpficommon_text -o test_json
go:
./test_json
@YukiSakamoto
YukiSakamoto / boost_test_sample.cpp
Created November 25, 2012 10:23
Boost.Test sample
#define BOOST_TEST_MODULE "Hogehoge"
#define BOOST_TEST_NO_LIB
#include <vector>
#include <boost/test/included/unit_test.hpp>
using namespace std;
// テストの名前
@YukiSakamoto
YukiSakamoto / rdtsc.c
Created December 6, 2012 16:08
Read Time Stamp Counter of IA-64
#include <stdio.h>
#include <stdint.h>
uint64_t rdtsc(void)
{
uint64_t ret;
__asm__ volatile("rdtsc" : "=A"(ret));
return ret;
}
@YukiSakamoto
YukiSakamoto / Result_on_my_MacBookAir.txt
Created December 8, 2012 07:26
Using CPUID instruction, and survey functions of my computer's cpu.
cpu_name: GenuineIntel
FPU yes
VME yes
DE yes
PSE yes
TSC yes
MSR yes
PAE yes
MCE yes
CX8 yes
@YukiSakamoto
YukiSakamoto / disasm.txt
Last active December 18, 2015 14:38
I could compile this code, but couldn't execute because of bus error.
./a.out: ファイル形式 mach-o-x86-64
セクション .text の逆アセンブル:
0000000100000eb0 <start>:
100000eb0: 6a 00 pushq $0x0
100000eb2: 48 89 e5 mov %rsp,%rbp
100000eb5: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
@YukiSakamoto
YukiSakamoto / mapk.gif
Last active December 18, 2015 21:49
mapk
digraph mapk {
graph [label = "mapk", labelloc = t];
"mapk(phos=pYpT^1)" -> "pp(bs^1)|(1, 2)";
"pp(bs^1)|(1, 2)" -> "mapk(phos=pYpT^1)";
}