Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jeshan Giovanni BABOOA jeshan

🏠
Working from home
  • Independent
  • Mauritius
View GitHub Profile
@jeshan
jeshan / extractgc.sh
Created Jul 17, 2021 — forked from xigh/extractgc.sh
Extracting LLVM bitcode from ELF files generated with -fembed-bitcode.
View extractgc.sh
#!/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
towctrans from musl libc in LLVM IR assembly format
View towctrans.lo.ll
; 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
View musl-crt1.o.ll
; 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 Apr 3, 2021
Pure way for tracking state of variables in Prolog
View state.pl
% 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 Apr 3, 2021
Bi-directional conversion between hex strings and numbers in Prolog
View hex.pl
:- 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 Apr 3, 2021
Demonstrates bug https://github.com/oracle/truffleruby/issues/2247 . v1 builds successfully but v2 throws exception in issue
View ruby.dockerfile
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 Feb 2, 2021
Gist to reproduce Ruby MRI compilation issue with Sulong
View mri.dockerfile
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 Jan 11, 2021
Markus Triska's example interpreter and compiler: Source: https://www.metalevel.at/tist/interp.pl
View 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 Jan 8, 2021
OpenJDK build instructions for Linux/Docker
View Dockerfile
# 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 Oct 30, 2020
How to pass environment variables to other processes in AWS Codebuild, e.g docker compose commands
View buildspec.yaml
{
"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",