Skip to content

Instantly share code, notes, and snippets.

View ThomazPom's full-sized avatar

ThomazPom ThomazPom

View GitHub Profile
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playNote(frequency, duration,cancontinue) {
// create Oscillator node
var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = frequency; // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();
function discoverAllShadowRoots(){
let shadowroots = []
function discover(elem){
let elemshadowroots = [...elem.querySelectorAll("*")]
elemshadowroots.push(elem)
elemshadowroots=elemshadowroots.map(z=>z.shadowRoot).filter(z=>z)
elemshadowroots.forEach(discover)
shadowroots.push(...elemshadowroots)
}
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int emit(int value=1008,int protocol=6,int wordlen=12)
{
String must_send = intToBinaryWord(value,wordlen);
@ThomazPom
ThomazPom / gimp_smart_remove_bg.py
Last active September 1, 2022 20:07
Execute this in gimp python fu console to remove black backgrounds from png images while keeping accurate colors
import glob, os
def smart_remove_bg(folder,rem_color="#000000"):
for filename in glob.glob(folder.replace('"','').strip()):
out_fname = os.path.join(os.path.dirname(filename),"out-"+os.path.basename(filename))
out_fname_xcf = os.path.join(os.path.dirname(filename),"xcf-"+os.path.basename(filename)+".xcf")
image = pdb.file_png_load(filename, filename)
drawable = pdb.gimp_image_get_active_drawable(image)
pdb.plug_in_colortoalpha(image, drawable, rem_color)
<?php
foreach ([1] as $i) if ($condition) { // Breakable if
//some code
$a = "b";
// Le break
break;
// code below will not be executed
}
for ($i=0; $i < 1 ; $i++) if ($condition) {
//some code
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<style>
body{
background-color:#000048;
color:white;
@ThomazPom
ThomazPom / auto_answer.js
Created May 8, 2021 10:36
Auto answer on facebook page inbox
// ==UserScript==
// @name FAQ AutoAnswer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @grant none
// ==/UserScript==
var nlist = [];
widthheight=$(wm size | sed "s/.* //")
width=$(($(echo $widthheight | sed "s/x.*//g" )+0))
height=$(($(echo $widthheight | sed "s/.*x//g" )+0))
GetColorAtPixel () {
x=$1;y=$2;
rm ./screen.dump 2> /dev/null
screencap screen.dump
screenshot_size=$(($(wc -c < ./screen.dump)+0));
buffer_size=$(($screenshot_size/($width*height)))
let offset=$width*$y+$x+3
<!DOCTYPE html>
<html>
<body>
<style>iframe,embed{width:90vw;height:90vh;}pre{background:lightgray;padding:10px}
</style>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<h1>Test page for Moz-Ext-Ignore-X-Frame-Options</h1>
<h2>If content is <u>blocked</u>, you may want to
# Multiply elems in a list
def m(l,i=0,v=1):
return m(l,i+1,v*l[i]) if i+1<len(l) else v*l[i]
# >>> m([1,2,3,4,5])
# 120