Skip to content

Instantly share code, notes, and snippets.

View astarasikov's full-sized avatar
🐈
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈

Alexander Tarasikov astarasikov

🐈
🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈🐈
View GitHub Profile
#!/bin/bash
cat > Makefile <<EOF
APPNAME=test_struct_different_decl
CFLAGS=-g2 -O0 -Wall -Wextra -Wpedantic
CC=clang
all:
\$(CC) \$(CFLAGS) -c -o mod1.o mod1.c
\$(CC) \$(CFLAGS) -c -o mod2.o mod2.c
@astarasikov
astarasikov / clear_stack_i386.S
Created September 16, 2015 17:07
assembly stub to clear caller's stack frame on i386 linux/gcc
.globl mcount
mcount:
push %eax
push %ebx
push %ecx
mov %esp,%eax
add $0x10,%eax //retval + rax + rbx + rcx
mov %ebp,%ebx
avg [] curr n = curr
avg (x:xs) curr n =
let c' = (x + (curr * n)) / (n + 1)
in avg xs c' (n + 1)
avg' lst = avg lst 0 0
main =
print $ avg' ([1, 2, 3, 4, 5] :: [Double])
@astarasikov
astarasikov / process_bookmarks.sh
Created June 22, 2015 03:06
A script to sort my Chrome bookmarks
#!/bin/bash
set -e
set -u
BOOKMARKS_TXT="bookmarks.txt"
if [[ -z "$1" ]]; then
echo "Usage: $0 $BOOKMARKS_TXT"
exit -1
@astarasikov
astarasikov / elf_dependency_graph.rb
Last active August 29, 2015 14:21
Visualize ELF dependency graph in Graphviz dot
#!/usr/bin/env ruby2.1
#@bin_dir="/home/me/bin/foo"
@bin_dir = ""
# context = {
# :exports => {
# "foo" => [
# "file2.ois",
# "file3.ois",
#!/bin/bash
set -e
set -u
export SRC_LLVM="https://github.com/llvm-mirror/llvm.git"
export SRC_COMPILER_RT="https://github.com/llvm-mirror/compiler-rt.git"
export SRC_CLANG="https://github.com/llvm-mirror/clang.git"
export SRC_CLANG_EXTRA="https://github.com/llvm-mirror/clang-tools-extra.git"
export SRC_LIBCXX="https://github.com/llvm-mirror/libcxx.git"
#!/usr/bin/env ruby
require 'Digest'
require 'set'
if 0 == ARGV.length then
puts "Usage: $0 dir"
exit -1
end
#!/usr/bin/env ruby
require 'Digest'
if 2 != ARGV.length then
puts "Usage: $0 dir [good_dir]"
exit -1
end
def probe_file(path, good_path)
@astarasikov
astarasikov / parse_math
Created February 19, 2015 23:20
some stupid expression parser, just a backup
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
enum token_type {
let rec revZipWithDefault accum dval lsta lstb =
match lsta with
| ha :: ta ->
(match lstb with
| hb :: tb -> zipWithDefault ((ha, hb) :: accum) dval ta tb
| _ -> zipWithDefault ((ha, dval) :: accum) dval ta [])
| _ ->
(match lstb with
| hd :: tl -> zipWithDefault ((dval, hd) :: accum) dval [] tl
| _ -> accum);;