Skip to content

Instantly share code, notes, and snippets.

@uraimo
uraimo / oracle_long_to_varchar2.md
Last active March 28, 2022 15:05
Oracle string in LONG field to VARCHAR2 without temporary tables or anything else, pure PL/SQL

LONG fields were used in Oracle DB during the Dark Ages to store long text, but they are not selectable and cannot be used in where clauses with LIKE. A multitude of broken solutions exist (to_lob,substr,weird macros, converting the value into new tables, etc...) online to be able to search into this field with a normal query with LIKE, but they are mostly broken. This sample declares a temporary function for the conversion (size up to 4k, it's an oracle limit, some sei you can go up to 32k in PL/SQL but this does not seem the case) and then uses it in a query, ugly but simple.

Errors you could see while handling LONG fields:

ORA-00997: illegal use of LONG datatype
ORA-06502: PL/SQL: numeric or value error
@uraimo
uraimo / The-Long-Strange-Trip-to-Java.md
Last active March 28, 2022 15:02
The Long Strange Trip to Java - Patrick Naughton, March 18, 1996

Saved in case it gets lost, from: http://www.blinkenlights.com/classiccmp/javaorigin.html

The Long Strange Trip to Java

Note: This is an unabridged, unedited version of the Epilogue of my book, The Java Handbook. My editors fought with three problems, libel, slander and page count. We were out of space, and they were also worried a few of my associates from the last 12 years might want to sue them for things I've recalled about them. Well, I kinda see their point... but then everything I say in here is merely my opinion, and this web publication in no way should reflect the views of Osborne/McGraw-Hill, nor any of their personnel. And if I've insulted anyone in this page to the point that they feel like calling a lawyer, I'll snip them out of it as soon as they contact me. (I should also say that the contents of this page have nothing to do with Starwave Corporation while I'm here). 'nuff said. I've debated with myself for several years about whether or not to write this down. After so much time has passe

@uraimo
uraimo / raspberrypi_wifi_headless_config.md
Last active December 2, 2021 08:14
Config/recover an headless pi wireless

To configure the wireless connection of a newly installed Pi or an old one with an obsolete wireless config, just create a file wpa_supplicant.conf file on the /boot/ fat32 partition with this content:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
country=GB
update_config=1

network={
 ssid="<Name of your wireless LAN>"
 psk=""

How to squash an image with multiple layers in a single new one (losing history).

Enable experimental features in Docker

Using --squash requires a Docker with and API version greater than 1.13 (can be checked with docker version).

Edit /etc/docker/daemon.json adding:

  {

"experimental": true

@uraimo
uraimo / disable_ocsp.md
Created November 27, 2020 09:53
Disable oscp

This is usefull when you are experiencing network issues and the apps refuse to open (icon jumping, no window shown) because macOS can't complete its oscp signature verification on binaries. Or just if you want to disable it for other reasons.

Open /etc/hosts and add:

0.0.0.0 ocsp.apple.com

Everything should open normally now.

@uraimo
uraimo / swift_compiler_generate_swift.xcodeproj.md
Created April 29, 2020 08:50
How to generate Swift.xcodeproj for the apple/swift compiler without building everything

Clone the Swift compiler and all the related subprojects and then just create the build directories without compiling:

mkdir swiftlang
cd swiftlang
git clone https://github.com/apple/swift.git
./swift/utils/update-checkout --clone
cd swift
utils/build-script --release-debuginfo --xcode --skip-build
@uraimo
uraimo / multiple_github_accounts_guide.md
Last active April 12, 2020 13:26
Configuring multiple github accounts for work and private

In this short guide two sample user will be used: leisure and work.

  1. Create two ssh keys, one of each user, and register them with their github account on the site. Let's suppose you have created id_rsa_work and id_rsa_leisure.

  2. Configure ssh using two virtual hosts, one for work and one for leisure, each one linked to one of the keys:

     # Personal GitHub account
     Host leisure-github.com
    

HostName github.com

  • Link gcc and g++ to clang and clang++ respectively if necessary

  • Move /bin/uname to /bin/uname.orig and override it with a /bin/uname script that calls /bin/uname.orig "$@" | sed 's/armv7l/armv6l/g'

  • Force armv6l for build-impl-script instead of using python's platform.machine() that calls the uname syscall (setarch cannot be used since armv6 cannot be set...):

    diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.
    py
    index 2859677fac..b7d65c4f9a 100644
    

--- a/utils/swift_build_support/swift_build_support/targets.py

@uraimo
uraimo / swift_globals_checks.md
Created July 2, 2019 08:50
Check if a function is defined in the global namespace in Swift
guard dlsym(nil,"iDontExistOnThisPlatformSorry") != nil else {print("Doesn't exist!");exit(0)}

Just some useful one liners.

  • A better way to get the ARCH for a binary:

readelf -a -W | grep CPU