Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
CodeBrauer / get-wix-images-full-res.js
Last active February 13, 2020 10:38
just paste to console. enjoy.
window.WixxURLS = "";
document.querySelectorAll('[data-src]').forEach(function(el,index) {
window.WixxURLS += el.getAttribute('data-src').replace(/\/v1\/.+/, '') + "\n"
})
document.body.innerHTML = "<textarea rows='100' cols='100'>" + window.WixxURLS + "</textarea>";
document.querySelector("textarea").select();
document.execCommand('copy');
@CodeBrauer
CodeBrauer / fix_umlaute.php
Last active April 20, 2025 17:04 — forked from pepebe/gist:4554926
SQL: Repair German "Umlaute" inside a MySQL Database. (mysqli version / PHP7 supported)
<?php
/**
* Alle kaputten Umlaute reparieren bei Umstellung von ISO->UTF8
* Source: http://xhtmlforum.de/66480-kleines-skript-alle-umlaute-der-datenbank.html
*
* @project -
* @author Boris Bojic <[email protected]>
* @copyright Copyright (c) 2011, Boris Bojic (DevShack)
* @version Fri, 23 Dec 2011 13:47:11 +0100
* @updated -
@CodeBrauer
CodeBrauer / backup-all-repos-gitlab.py
Created April 16, 2019 06:48
Python3 script to backup all repos from gitlab. Just pipe the command output to a textfile (to run it later/somewhere else) or directly in your shell.
from urllib.request import urlopen
import json
import subprocess, shlex
import sys
allProjects = urlopen("http://gitlab.example.org/api/v3/projects/all?private_token=[PERSONAL_TOKEN]&per_page=100")
allProjectsDict = json.loads(allProjects.read().decode())
for index,thisProject in enumerate(allProjectsDict):
try:
thisProjectURL = thisProject['ssh_url_to_repo'] + ' ' + thisProject['path_with_namespace'].replace('/', '_');
<?php
function curl_get_contents($url) {
if (!function_exists('curl_init')) { return file_get_contents($url); } // fallback
$ch = curl_init();
$options = array(
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HEADER => false,
CURLOPT_URL => $url,
<?php
function curl_get_contents($url, $json = false, $show_error = false) {
if (!function_exists('curl_init')) { return file_get_contents($url); } // fallback
$ch = curl_init();
$options = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
);
@CodeBrauer
CodeBrauer / twf.german.js
Last active November 24, 2020 14:31
com.twf
this.windAll = [
//Highest
["Ein verdammter Tornado.", "Kinder werden weggeblasen.", "Binde dein Haus fest.", "Ein verfickter Hurrikan.", "Stürmisch wie Scheiße.", "Tornadoig.", "Irgendeine Scheiße auf Monsun-Niveau."],
//High
["Ziemlich scheißwindig.", "Scheißböig.", "Geh heute nicht zum Frisör.", "Du wist einen bad-hair-day haben.", "Trag bloß keinen Rock", "Ein verdammter Sturm.", "Gründlich beschissen.", "Der Wind hat es heute verdammt eilig."],
//Medium
["Ziemlich windig.", "Ziemlich böig, verdammt.", "Genug Wind, um Scheiße zu sein.", "Vielleicht mit dem Segeln anfangen.", "Ziemlich verfickt zugig.", "Beschissen windig.", "Rather windy.", "Fairly fucking windy.", "Good time to buy a kite."],
//LOW
["Not a lot.", "Some.", "Some shitty breeze.", "Like someone breathing in your face.", "A bit of a draft.", "A bit drafty.", "Dull little breeze.", "Rather breezy.", "The air is in a bit of a hurry."],
//Lowest
@CodeBrauer
CodeBrauer / mask_ip.php
Last active January 18, 2022 12:00
PHP function that anonymizes IP addresses like Google Analytics does (https://support.google.com/analytics/answer/2763052)
<?php
function mask_ip($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$parts = explode('.', $ip);
$parts[count($parts)-1] = '0';
return implode('.', $parts);
} else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$parts = explode(':', $ip);
$parts[count($parts)-1] = '0';
<?php
// or just use json_last_error_msg...
public function get_json_human_error($err_code)
{
$constants = get_defined_constants(true);
$json_error_constants = array_filter(array_keys($constants['json']), function($row) {
return strpos($row, 'JSON_ERROR_') !== false;
});
foreach ($json_error_constants as $index => $error_name) {
$json_error_constants[constant($error_name)] = $error_name;
@CodeBrauer
CodeBrauer / composer-stats.sh
Last active February 17, 2022 13:51
prints how ofter you required which package (tested on mac with zsh)
history | grep "composer require" | cut -d " " -f 7- | grep -v "grep" | sort | uniq -c | sort -r