Skip to content

Instantly share code, notes, and snippets.

@rocketgeek
rocketgeek / extract_html_atts.php
Created August 4, 2021 14:10
Extract "data-" attributes from WooCommerce HTML tags
<?php
// Extraction utility for getting attributes from HTML tag.
function extract_html_atts( $string, $prefix = "data-" ) {
$start = 0;
$end = 0;
while( strpos( $string, $prefix, $end ) ) {
$start = strpos( $string, $prefix, $start )+strlen( $prefix );
$end = strpos( $string, '"', $start )-1;
@nima-rahbar
nima-rahbar / linkvertise-bypass.js
Created January 30, 2021 13:08
Linkvertise Bypass
// ==UserScript==
// @name Linkvertise Bypass
// @namespace https://github.com/nima-rahbar/
// @version 1.0
// @description Bypass links that cannot be bypassed by Universal Bypass
// @author Nima Rahbar
// @match *://*.linkvertise.com/*
// @match *://*.linkvertise.net/*
// @match *://*.link-to.net/*
// @icon https://nimarahbar.com/wp-content/uploads/2017/07/favicon.png
@xeoncross
xeoncross / YouTubeURLFormats.txt
Created January 16, 2021 03:55 — forked from rodrigoborgesdeoliveira/ActiveYouTubeURLFormats.txt
Example of the various YouTube url formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://youtu.be/-wtIMTCHWuI
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare
@marcus-at-localhost
marcus-at-localhost / split.php
Created April 13, 2020 18:27
[Split by Comma but not if in Parenthesis] #regex #split #array
<?php
$filters = "1,2,4,(5,6,7),8;9";
var_dump(preg_split("~[,|;](?![^(]*\\))~", $filters));
/*
array (size=6)
0 => string '1' (length=1)
1 => string '2' (length=1)
2 => string '4' (length=1)
@n-kb
n-kb / scrape.py
Created February 13, 2020 20:31
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import csv, time
import os.path
browser = webdriver.Chrome()
for year in range(2013, 2020):
for month in range(1,13):
@rocketgeek
rocketgeek / html_to_obj.php
Created July 10, 2019 12:43
Convert HTML DOM to JSON
<?php
// https://stackoverflow.com/questions/23062537/how-to-convert-html-to-json-using-php
function html_to_obj( $html ) {
$dom = new DOMDocument();
$dom->loadHTML( $html );
return element_to_obj( $dom->documentElement );
}
function element_to_obj( $element ) {
@sundowndev
sundowndev / GoogleDorking.md
Last active May 3, 2024 19:34
Google dork cheatsheet

Google dork cheatsheet

Search filters

Filter Description Example
allintext Searches for occurrences of all the keywords given. allintext:"keyword"
intext Searches for the occurrences of keywords all at once or one at a time. intext:"keyword"
inurl Searches for a URL matching one of the keywords. inurl:"keyword"
allinurl Searches for a URL matching all the keywords in the query. allinurl:"keyword"
intitle Searches for occurrences of keywords in title all or one. intitle:"keyword"
This file has been truncated, but you can view the full file.
{
"log": {
"comment": "",
"creator": {
"comment": "",
"name": "BrowserMob Proxy",
"version": "2.1.4"
},
"entries": [
{
@lyquix-owner
lyquix-owner / cleanhtml.php
Last active August 14, 2023 12:30
PHP script to automatically clean dirty HTML. Removes unnecessary attributes (e.g. style, id, dir), replaces deprecated tags with valid ones (e.g. <b> to <strong>), and strips undesirable tags (e.g <font>). We have used this script to safely clean hundreds of blog posts that were littered with inline styling.
<?php
// List of tags to be replaced and their replacement
$replace_tags = [
'i' => 'em',
'b' => 'strong'
];
// List of tags to be stripped. Text and children tags will be preserved.
$remove_tags = [
@nicklasos
nicklasos / download.php
Last active January 31, 2024 09:13
Curl PHP multiple files downloading
<?php
function multiple_download(array $urls, $save_path = '/tmp')
{
$multi_handle = curl_multi_init();
$file_pointers = [];
$curl_handles = [];
// Add curl multi handles, one per file we don't already have
foreach ($urls as $key => $url) {