Skip to content

Instantly share code, notes, and snippets.

View xrash's full-sized avatar

Felipe xrash

View GitHub Profile
// Intercepting calls to open() and setRequestHeader().
(function (open, setRequestHeader) {
XMLHttpRequest.prototype.open = function (method, url) {
console.log('open', method, url);
this.addEventListener('readystatechange', function () {
console.log('state', this.readyState);
}, false);
open.apply(this, arguments);
};
@xrash
xrash / docker-compose-coreos.sh
Last active January 23, 2017 05:46 — forked from sourcec0de/docker-compose-coreos.sh
Install docker compose on coreos
sudo su -
mkdir -p /opt/bin
curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
docker run -ti --rm -v /opt/bin:/out ubuntu:17.10 /bin/bash -c "apt-get update && apt-get -y install build-essential && cp /usr/bin/make /out/make"
@xrash
xrash / gist:3353b0cc34c1174111becf5432bbbfe6
Created October 30, 2020 18:02 — forked from jamesgmarks/gist:56502e46e29a9576b0f5afea3a0f595c
MySQL/MariaDB BIN_TO_UUID and UUID_TO_BIN Polyfill
DELIMITER //
CREATE FUNCTION BIN_TO_UUID(b BINARY(16))
RETURNS CHAR(36)
BEGIN
DECLARE hexStr CHAR(32);
SET hexStr = HEX(b);
RETURN LOWER(CONCAT(
SUBSTR(hexStr, 1, 8), '-',
SUBSTR(hexStr, 9, 4), '-',
@xrash
xrash / POSITIONING.md
Last active March 11, 2021 13:47
Differences in positioning functions/properties between react-native and react-native-web
Web Native
nativeEvent.pageX/pageY coordinates from page size coordinates from screen size
nativeEvent.locationX/locationY always undefined (apparently) coordinates from inside the innermost component touched
ref.measure() x/y coordinates from parent always 0
ref.measure() pageX/pageY coordinates from screen size coordinates from screen size
ref.measure() width/height expected width/height expecte
@xrash
xrash / FindNodeHandleMeasureLayout.ts
Created March 3, 2021 19:38
Using `findNodeHandle` and `measureLayout` in React Native
const nodeHandle = findNodeHandle(wrapperRef.current)
if (nodeHandle === null) {
return
}
const onSuccess = (x: number, y: number, width: number, height: number) => {
console.log('measureLayout', x, y, width, height)
}