Skip to content

Instantly share code, notes, and snippets.

View Aarbel's full-sized avatar
✍️
.

Clement Fradet Normand Aarbel

✍️
.
View GitHub Profile
@Aarbel
Aarbel / .ts
Created September 5, 2022 09:07
Compress image in the browser
import loadImage from "blueimp-load-image";
import { readAndCompressImage } from "browser-image-resizer";
import { captureException } from "../sentry";
const ONE_MB_IN_BYTE = 1048576;
interface Options {
/** @default Number.POSITIVE_INFINITY */
maxSizeMB?: number;
/** @default undefined */
document.addEventListener('click', (e) => {
const el = e.target;
if (el.tagName == 'A' && el.href && el.getAttribute("target") === "_blank") {
window.todesktop.contents.openUrlInBrowser(el.href);
}
}, false);
@Aarbel
Aarbel / edit-xml-attribute.sh
Created September 20, 2019 19:30
Edit XML Tag attribute with sh bash or shell script.
sed -i '' "s/\(<tag_to_target [^>]*attribute_to_target=\"\)[^\"]*\"/\1$variable_to_set\"/" file.xml
@Aarbel
Aarbel / embedded-file-viewer.md
Last active September 30, 2024 13:50 — forked from tzmartin/embedded-file-viewer.md
Free desktop and mobile files viewers and editors: Google Drive, OneDrive, Zoho public viewers and editors.

Desktop / Web

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

Format :

    http://view.officeapps.live.com/op/view.aspx?src=[ONLY_OFFICE_FILE_URL_ENCODED]
    
 
@Aarbel
Aarbel / dabblet.css
Last active November 24, 2018 18:10
Untitled
html {
height: 100%;
font-family: 'Source Sans Pro', sans-serif;
}
body {
background: linear-gradient(90deg, #6bafd2 0%, #a4c8dc 38%, #d6cbca 58%, #eabc96 79%, #db8876 100%);
min-height: 100%;
height: 100%;
position: relative;
@Aarbel
Aarbel / dabblet.css
Last active November 24, 2018 17:53
Untitled
html {
height: 100%;
}
body {
background: linear-gradient(90deg, #6bafd2 0%, #a4c8dc 38%, #d6cbca 58%, #eabc96 79%, #db8876 100%);
min-height: 100%;
height: 100%;
position: relative;
display: flex;
@Aarbel
Aarbel / mouse-drag-click-control.js
Created August 17, 2018 23:48
Way to know if the mouse moved during a click, and prevent event on click if needed. Usefull for THREE.js camera rotation
let mouseMoved = false;
document.addEventListener('mousedown', () => {
mouseMoved = false;
}, false);
document.addEventListener('mousemove', () => {
mouseMoved = true;
}, false);