Skip to content

Instantly share code, notes, and snippets.

<?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,
);
<?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,
@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('/', '_');
@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 <bojic@devshack.biz>
* @copyright Copyright (c) 2011, Boris Bojic (DevShack)
* @version Fri, 23 Dec 2011 13:47:11 +0100
* @updated -
@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');
#touch body #navbar {
height: 2.5rem;
}
#touch body #printer #state .progress {
top: 3.125rem;
}
#touch body #printer #state {
padding-top: calc(3.125rem + 30px);
@CodeBrauer
CodeBrauer / ajax.js
Last active September 4, 2020 07:16 — forked from jasonhinkle/ajax.js
jQuery AJAX Snippet
$.ajax({
url: 'api/url',
method: 'POST',
data: {var:'val'},
contentType: "application/json; charset=utf-8",
dataType: 'json'
}).done(function(data, textStatus, jqXHR) {
console.log('done');
}).fail(function(jqXHR, textStatus, errorThrown) {
if (jqXHR.responseJSON) {
@CodeBrauer
CodeBrauer / README.md
Last active January 18, 2022 11:58
quick and dirty script to toggle audio device (switch between speaker and headphones) using switchaudio-osx and BetterTouchTool (for a keyboard shortcut)

README

  1. brew install switchaudio-osx
  2. Check your audio devices with switchaudiosource -a
  3. Replace Mac mini Lautsprecher and Externe Kopfhörer with your ouput channels
  4. Place the script somewhere your user can execute it (do a chmod +x audiotoggle.sh)
  5. Copy the json and paste it to BTT. Edit the script path and you're done.
@CodeBrauer
CodeBrauer / reset_apple_mail.sh
Last active February 8, 2021 08:10
This will reset Apple Mail to factory settings.
killall Mail &> /dev/null
# optional, if you want to backup any not-synced data
mv ~/Library/Containers/com.apple.mail ~/Desktop/com.apple.mail.backup
# Attention, these commands will delete everything about Apple Mail except the app itself (factory reset)
rm -rf ~/Library/Caches/com.apple.mail
rm -rf ~/Library/Saved\ Application\ State/com.apple.mail.savedState
rm -rf ~/Library/Application\ Support/AddressBook/MailRecents-v4.abcdmr
rm -rf ~/Library/Preferences/com.apple.mail.plist