Skip to content

Instantly share code, notes, and snippets.

View pascal08's full-sized avatar

Pascal Lubbers pascal08

  • The Hague, Netherlands
  • 17:26 (UTC -12:00)
View GitHub Profile
@pascal08
pascal08 / instructions.md
Created August 23, 2021 15:23
Install Oracle JDK Ubuntu
  1. Install oracle-jdk11-installer
  2. Pick version: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
  3. Download .tar.gz file: wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.12<<<truncated>>>.tar.gz
  4. Move .tar.gz to installer folder: sudo mv jdk-11.0.12_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
  5. Run installer (uwith sudo perm.): apt install oracle-jdk11-installer
@pascal08
pascal08 / add_bin.py
Created October 7, 2020 21:58
Add two binairy numbers
def bin_to_int(bin_val):
"""
We draaien het binaire getal (string) om, zodat we van het
grootste naar kleinste exponent kunnen werken. We kunnen daardoor
van de eerste index naar de laatste index itereren en bij elke "1"
de waarde optellen bij het subtotaal.
"""
bin_val = bin_val[::-1]
@pascal08
pascal08 / main.go
Created January 4, 2019 16:58
Execute shell command
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
binary, lookErr := exec.LookPath("bash")
@pascal08
pascal08 / main.go
Created January 4, 2019 16:56
Find/Replace in multiple files
package main
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
)
func visit(find string, replace string) filepath.WalkFunc {
@pascal08
pascal08 / example.php
Last active September 25, 2018 18:09
Loose comparison vs. strict comparison in PHP
<?php
class A {
public $val;
}
class B {
public $val;
}
@pascal08
pascal08 / commands
Last active September 8, 2018 23:39
Docker CLI commands
# Remove all non-running containers:
`docker rm $(sort <(docker ps -q) <(docker ps -aq) | uniq -u)`
@pascal08
pascal08 / replace_envs.sh
Created July 21, 2018 21:57
Parse environment placeholders (useful when using Docker for example)
#!/bin/bash
# Replace variables $ENV{<environment varname>}
# (optional: $ENV{<environment varname>??<default value>}
# ----
function ReplaceEnvironmentVariable() {
# - Parse environment variable placeholders.
# - The format should be $ENV{***} where *** should match
@pascal08
pascal08 / copy-all-repos-of-user.sh
Created June 18, 2018 10:40
Clone all repos of a user (using curl and bash only)
curl -s https://api.github.com/users/jobapis/repos?per_page=200 | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | xargs -n1 git clone
@pascal08
pascal08 / .bash_profile
Last active January 21, 2018 19:41
Turn PHP CLI XDebug on and off from command line
function php_exists() {
if ! [ -x "$(command -v php)" ]; then
echo 'b';
return 0;
fi
echo 'a';
return 1;
}