Skip to content

Instantly share code, notes, and snippets.

View jeshan's full-sized avatar
🏠
Working from home

Jeshan Giovanni BABOOA jeshan

🏠
Working from home
  • Independent
  • Mauritius
View GitHub Profile
@jeshan
jeshan / extractgc.sh
Created July 17, 2021 23:18 — forked from xigh/extractgc.sh
Extracting LLVM bitcode from ELF files generated with -fembed-bitcode.
#!/bin/sh
if [ "*$1" == "*" ]; then
echo "usage: extract.sh src dst"
fi
if [ "*$2" == "*" ]; then
echo "usage: extract.sh src dst"
fi
@jeshan
jeshan / towctrans.lo.ll
Created May 27, 2021 21:14
towctrans from musl libc in LLVM IR assembly format
; ModuleID = 'towctrans.lo'
source_filename = "src/ctype/towctrans.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-alpine-linux-musl"
%struct.__locale_struct = type opaque
@casemap.mt = internal constant [3 x i32] [i32 2048, i32 342, i32 57], align 4, !dbg !0
@rules = internal constant [240 x i32] [i32 0, i32 8193, i32 -8192, i32 1949440, i32 190208, i32 30976, i32 9218, i32 257, i32 -256, i32 0, i32 513, i32 -512, i32 -50943, i32 -59392, i32 -30975, i32 -76800, i32 49920, i32 53761, i32 52737, i32 52481, i32 20225, i32 51713, i32 51969, i32 52993, i32 24832, i32 54017, i32 53505, i32 41728, i32 54529, i32 33280, i32 54785, i32 55809, i32 55553, i32 56065, i32 14336, i32 3, i32 -20224, i32 -24831, i32 -14335, i32 2369538, i32 0, i32 257, i32 -256, i32 -52480, i32 -55808, i32 -33279, i32 2763521, i32 -41727, i32 2762753, i32 2768640, i32 -49919, i32 17665, i32 18177, i32 2760448, i32 2759680, i32 2760192, i32 -53760, i32 -52736, i32 -517
; ModuleID = 'crt1.o'
source_filename = "crt/crt1.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-alpine-linux-musl"
module asm ".text "
module asm ".global _start "
module asm "_start: "
module asm "\09xor %rbp,%rbp "
module asm "\09mov %rsp,%rdi "
@jeshan
jeshan / state.pl
Created April 3, 2021 18:31
Pure way for tracking state of variables in Prolog
% get_value(Value, History)
% History tracks values set for variable
get_value(Val, List) :-
nonvar(List), % just so that fails when nothing added yet.
nextto(t(Val), Var, List),
var(Var),
!.
available_spot(X, History) :-
@jeshan
jeshan / hex.pl
Last active April 3, 2021 11:06
Bi-directional conversion between hex strings and numbers in Prolog
:- use_module(library(clpfd)).
hex_number(Hex, Num) :-
ground(Hex),
!,
string_concat("0x", Hex, HexStr),
number_string(Num, HexStr).
hex_number(Hex, Num) :-
var(Hex),
@jeshan
jeshan / ruby.dockerfile
Last active April 3, 2021 18:15
Demonstrates bug https://github.com/oracle/truffleruby/issues/2247 . v1 builds successfully but v2 throws exception in issue
FROM buildpack-deps:buster
# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc
@jeshan
jeshan / mri.dockerfile
Created February 2, 2021 20:43
Gist to reproduce Ruby MRI compilation issue with Sulong
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y make libedit* tree
WORKDIR /app
COPY graalvm-ce-java11-linux-amd64-21.0.0.tar.gz graalvm.tar.gz
COPY llvm-toolchain-installable-java11-linux-amd64-21.0.0.jar llvm-toolchain.jar
RUN tar zxvf graalvm.tar.gz
@jeshan
jeshan / interp.pl
Created January 11, 2021 21:30
Markus Triska's example interpreter and compiler: Source: https://www.metalevel.at/tist/interp.pl
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Interpreter and compiler for a simple imperative language.
Written May 2006 by Markus Triska (triska@metalevel.at)
Public domain code. Tested with Scryer Prolog.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
:- use_module(library(clpz)).
:- use_module(library(assoc)).
:- use_module(library(pio)).
@jeshan
jeshan / Dockerfile
Created January 8, 2021 20:42
OpenJDK build instructions for Linux/Docker
# This image builds OpenJDK 15 with Clang. Feel free to change the parameters as needed.
# Build instructions: https://openjdk.java.net/groups/build/doc/building.html
# Public domain code.
FROM ubuntu:20.04
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
git autoconf file make zip curl clang libcups2-dev libxrandr-dev libxtst-dev libxt-dev libfontconfig1-dev libasound2-dev
WORKDIR /app
@jeshan
jeshan / buildspec.yaml
Created October 30, 2020 12:58
How to pass environment variables to other processes in AWS Codebuild, e.g docker compose commands
{
"version": 0.2,
"phases": {
"build": {
"commands": [
"curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI > creds_json",
"export AWS_ACCESS_KEY_ID=$(cat creds_json | jq .AccessKeyId |tr -d '\"')",
"export AWS_SECRET_ACCESS_KEY=$(cat creds_json | jq .SecretAccessKey | tr -d '\"')",
"export AWS_SESSION_TOKEN=$(cat creds_json | jq .Token |tr -d '\"')",
"export CDK_DEFAULT_ACCOUNT=$CDK_DEFAULT_ACCOUNT",