Skip to content

Instantly share code, notes, and snippets.

@je-so
je-so / deepcopy.js
Last active October 10, 2018 07:14
deep copy of javascript object (version ES6)
//
// Precondition: 1. "obj is not allowed to contain references pointing to itself"
// (function calls itself recursively, so this precondition
// must be matched by all contained objects)
//
function deepCopy(obj)
{
if (typeof obj !== 'object' || obj === null)
return obj
@je-so
je-so / build.sh
Created December 7, 2013 07:08
Simulate package visibility of functions of different modules contained in a single directory.
#!/bin/bash
# BUILD library which contains all modules of the package
echo "Build package.o from module1.c and module2.c"
gcc -c -o module1.o module1.c
gcc -c -o module2.o module2.c
ld -o package.o -r module1.o module2.o
symbols=(`nm package.o`)
for((i=0;i<${#symbols[*]};i=i+1)) do
if [ "${symbols[$i]}" != "T" ]; then continue; fi
@je-so
je-so / Makefile
Last active March 14, 2020 21:31
Generic Makefile For C Projects. Supports different building modes (Debug and Release preconfigured). Supports building mode specific configurations. C source code dependencies are computed automatically by the compiler and included into the makefile. All object files are put under directory $(TargetDir)/$(buildmode)/$(Project)/. Makefile suppor…
# Generic Makefile (c) 2013 Jörg Seebohn
# Version 1.0
# Use it at your own risk !
# This Makefile depends on GNU make.
# The clean command uses "@echo rm -rf $(TargetDir)"
# remove the echo if you know that $(TargetDir) is set to a valid value.
# The target test builds the project in Release mode and starts it.
# Adapt project specific part to your own project.
# Adapt compiler specific part to your own compiler.
@je-so
je-so / testprogram.c
Last active October 21, 2024 22:39
Xlib transparent window with OpenGL support
/*
____ _____
/\__ \ /\ ___\
\/__/\ \ \ \ \__/_
\ \ \ \ \____ \
_\_\ \ \/__/_\ \
/\ _____\ /\ _____\
\/______/ \/______/
Copyright (C) 2011 Joerg Seebohn
@je-so
je-so / glxwindow.c
Created April 4, 2011 11:58
Xlib set transparency of top level window
/* Sets the transparency of the toplevel window.
* An alpha value of 1 draws the window opaque a value of 0 makes
* it totally translucent.
* If alpha is set to a value outside of [0..1] EINVAL is returned. */
static int settransparency_helper(Display * display, Window win, double alpha)
{
int err ;
if ( alpha < 0
|| alpha > 1) {