Skip to content

Instantly share code, notes, and snippets.

View dpino's full-sized avatar
🏠
Working from home

Diego Pino dpino

🏠
Working from home
View GitHub Profile
@dpino
dpino / ns-inet.sh
Last active April 19, 2024 18:12
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@dpino
dpino / gist:e7892470bd5dda746fa612ff007cd496
Created March 21, 2024 20:14
current_branch_equals_remote.sh
#!/usr/bin/env bash
REPO=git@github.com:microsoft/playwright.git
BRANCH=release-1.41
current_branch_equals_remote() {
git branch -vv
local current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $(git log -1 --pretty="%h" ${current_branch}) == $(git log -1 --pretty="%h" origin/${current_branch}) ]]; then
echo "Current branch equals remote branch"
@dpino
dpino / b4-to-aftr-over-inet.sh
Created February 8, 2018 17:32
Communication of a lwB4 network fuction with a remote lwAFTR over Internet
#/usr/bin/env bash
set -x
# This script implements a lwB4 network function insolated into its own network namespace. Once running any IPv4 network command
# will get forwarded to a remote lwAFTR over the Internet. Communication with the lwAFTR is meant to happen via an IPv6 tunnel
# broker (such as Hurricane Electric) which should be already up and running.
# Author: Diego Pino Garca <dpino@igalia.com>
# Based on https://marcelwiget.wordpress.com/2015/11/30/lightweight-4over6-b4-client-in-linux-namespace/
@dpino
dpino / ns-ipv6-no-nat.sh
Created April 29, 2016 22:19
Create Network Namespace with IPv6 connectivity via Hurricane Electric tunnel (no NAT66 needed)
#!/usr/bin/env bash
set -x
if [[ $EUID -ne 0 ]]; then
echo "You must run this script as root."
exit 1
fi
# Fill up IPv6 addresses for the veth pair. Addresses must belong to the
@dpino
dpino / last-successful-build-to-git-commit.sh
Last active November 16, 2022 12:40
Fetch commit of last successful WebKit build (default: GTK-Linux-64-bit-Release-Ubuntu-LTS-Build)
#!/usr/bin/env bash
# set -x
# Return commit of last successful WebKit build (default: GTK-Linux-64-bit-Release-Ubuntu-LTS-Build).
# Changes:
# 2022-11-16: Reworked script using changes suggested by asutherland to fetch commit number of last successful build directly from build.webkit.org.
BUILDER_NAME=${1:-GTK-Linux-64-bit-Release-Ubuntu-LTS-Build}
@dpino
dpino / main.cc
Last active November 15, 2022 11:14
Pass CPP object to JavaScript function
/**
* Pass CPP object to JavaScript function
*
* sample.js:
* function fileInfo(obj)
* {
* return "fileInfo: " + obj.i;
* }
*
* To compile: g++ main.cc -o main `pkg-config --cflags --libs javascriptcoregtk-4.0`
@dpino
dpino / perf-iterators.lua
Last active October 24, 2022 19:32
Measures performance of loops iterating with pairs, ipairs and indexing
#!/usr/bin/env luajit
--[[
Environment: Lenovo ThinkPad X200 / 16GB RAM / iCore7 2620M (2.70GHz, 4MB Cache)
| pairs | ipairs | indexing |
| 1.000000 | 5.244480 | 9.388388 |
| 0.190677 | 1.000000 | 1.790146 |
| 0.106515 | 0.558614 | 1.000000 |
@dpino
dpino / patch.diff
Created November 24, 2021 14:41
Patch build fixes
From 0f93b285725b0ac8a77a75de0a9d7d0ded94074b Mon Sep 17 00:00:00 2001
From: Diego Pino Garcia <dpino@igalia.com>
Date: Wed, 24 Nov 2021 14:38:36 +0000
Subject: [PATCH] Patch build fixes
---
.../loader/archive/mhtml/MHTMLParser.cpp | 2 +-
.../platform/SharedBufferChunkReader.h | 2 ++
Source/WebCore/platform/gtk/SelectionData.h | 6 ++--
.../ServiceWorkerSoftUpdateLoader.cpp | 2 +-
$ WEBKIT_JHBUILD=1 WEBKIT_JHBUILD_MODULESET=minimal Tools/Scripts/build-webkit --gtk --touch-events --no-bubblewrap-sandbox --cmakeargs=-DUSE_SOUP2=ON --cmakeargs=-DUSE_JPEGXL=OFF --cmakeargs=-DUSE_AVIF=OFF --no-webxr MiniBrowser | tee log
+ /home/dpino/playwright/browser_patches/webkit/checkout/Tools/jhbuild/jhbuild-wrapper --gtk run cmake --build /home/dpino/playwright/browser_patches/webkit/checkout/WebKitBuild/Release --config Release --
[0/548] Generate bindings (WebCoreBindings)
Preprocess IDL
[4/548] cd /home/dpino/playwright/browser_patches/webkit/checkout/WebKitBuild/Release/Source/WebKit && /usr/bin/perl /home/dpino/playwright/browser_patches/webkit/checkout/Source/WebKit/Scripts/generate-forwarding-headers.pl --include-path /home/dpino/playwright/browser_patches/webkit/checkout/Source/WebKit --output /home/dpino/playwright/browser_patches/webkit/checkout/WebKitBuild/Release/DerivedSources/ForwardingHeaders --platform gtk --platform soup
[5/124] Generate bindings (TestRunnerSharedBindings)
[6/124]
@dpino
dpino / layout-tests-split
Created March 14, 2019 17:51
Split LayoutTests in several jobs
#!/usr/bin/env bash
function usage {
echo "Usage: layout-tests-split [jobs] [webkit-dir]"
}
JOBS="${1:-1}"
WEBKIT_DIR="${2:-.}"
LAYOUT_TESTS_DIR="$WEBKIT_DIR/LayoutTests/"