Skip to content

Instantly share code, notes, and snippets.

@viktorklang
viktorklang / dockless.sh
Created May 27, 2014 12:15
"Permanently" hide the Dock
#!/bin/bash
#########################################################################################################################
# MIT License
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@mcimadamore
mcimadamore / CustomMappedSegment.java
Last active March 31, 2022 18:31
An example of how to implement a mapped memory segment on top of the Panama ABI support
import jdk.incubator.foreign.Addressable;
import jdk.incubator.foreign.CLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.ResourceScope;
import jdk.incubator.foreign.SegmentAllocator;
import jdk.incubator.foreign.SequenceLayout;
import jdk.incubator.foreign.ValueLayout;
@mcimadamore
mcimadamore / DlOpen.java
Created May 22, 2021 21:51
DlOpen implementation using the Foreign Linker API
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@Glavo
Glavo / PanamaJIT.java
Last active November 23, 2021 10:43
PanamaJIT Demo
import jdk.incubator.foreign.*;
import java.lang.invoke.*;
// Original code (C++): https://stackoverflow.com/a/40937610/7659948
public class PanamaJIT {
public static final int MEM_COMMIT = 0x00001000;
public static final int PAGE_READWRITE = 0x04;
public static final int PAGE_EXECUTE_READ = 0x20;