Skip to content

Instantly share code, notes, and snippets.

const cloudflareIpURLv4 = 'https://www.cloudflare.com/ips-v4'
const cloudflareIpURLv6 = 'https://www.cloudflare.com/ips-v6'
addEventListener('fetch', (event) => {
return event.respondWith(handleRequest())
})
/**
*
* @param url
@bitbybit
bitbybit / xorg.conf
Created March 25, 2018 00:08
NVIDIA GeForce FX 5200 and NEC LCD1701 (1280×1024)
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
Option "DDC" "False"
DisplaySize 338 271
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 76.0
Modeline "1280x1024_60" 108.88 1280 1360 1496 1712 1024 1025 1028 1060 -HSync +Vsync
EndSection
@bitbybit
bitbybit / flatten_array.php
Created July 15, 2015 13:50
Flatten multidimensional array (tree) to two-dimensional
<?php
function flatten($array,$child) {
$result = array();
foreach($array as $key => $value) {
if(!isset($value[$child]) || empty($value[$child]) || !is_array($value[$child])) {
$result[] = $value;
} else {
$child_array = flatten($value[$child],$child);
$value[$child] = array();
@bitbybit
bitbybit / recursive-sort.php
Last active August 29, 2015 14:22
Recursive multidimensional array sort
<?php
function recursive_sort($array,$child) {
usort($array,function($a,$b){
return $a['order'] - $b['order'];
});
foreach($array as $key => $value) {
if(isset($value[$child]) && !empty($value[$child]) && is_array($value[$child])) {
$array[$key][$child] = recursive_sort($value[$child],$child);
}
@bitbybit
bitbybit / openssl-archive-encrypt.sh
Created June 8, 2015 16:24
Encrypt file with openssl
#!/bin/sh
# create archive
tar -cPzf ./archive.tgz /path/to/unencrypted/directory/
# encrypt file with password
openssl enc -aes-256-cbc -salt -in ./archive.tgz -out ./archive.tgz.enc -pass file:/path/to/password
# remove unencrypted archive
rm ./archive.tgz
@bitbybit
bitbybit / wallabag-reload-articles.js
Created June 7, 2015 18:32
Reload contents of all Wallabag 1.9.0 articles imported from Pocket (default importing tool didn't load content)
// dotjs:
// https://github.com/defunkt/dotjs
// "EXPORT YOUR WALLABAG DATA" JSON here
var exported = [];
$(function(){
// http://stackoverflow.com/a/4762297
function goTo(url) {
var a = document.createElement("a");
@bitbybit
bitbybit / temp-email.txt
Last active January 23, 2024 10:53
List of temporary email services
0815.ru
0815.su
10minutemail.com
20mail.it
20minutemail.com
a45.in
anonbox.net
anonymbox.com
antispam.de
armyspy.com
@bitbybit
bitbybit / phone-autoformat.js
Created March 16, 2015 14:55
Phone number input autoformat
// EXAMPLE:
// https://jsfiddle.net/vvvvvv/xxo6x8wu/
var phone = {};
// http://country.io/phone.json
phone.codes = {"BD": "880", "BE": "32", "BF": "226", "BG": "359", "BA": "387", "WF": "681", "BL": "590", "BN": "673", "BO": "591", "BH": "973", "BI": "257", "BJ": "229", "BT": "975", "BV": "", "BW": "267", "WS": "685", "BQ": "599", "BR": "55", "BY": "375", "BZ": "501", "RU": "7", "RW": "250", "RS": "381", "TL": "670", "RE": "262", "TM": "993", "TJ": "992", "RO": "40", "TK": "690", "GW": "245", "GT": "502", "GS": "", "GR": "30", "GQ": "240", "GP": "590", "JP": "81", "GY": "592", "GF": "594", "GE": "995", "GB": "44", "GA": "241", "SV": "503", "GN": "224", "GM": "220", "GL": "299", "GI": "350", "GH": "233", "OM": "968", "TN": "216", "JO": "962", "HR": "385", "HT": "509", "HU": "36", "HK": "852", "HN": "504", "HM": " ", "VE": "58", "PS": "970", "PW": "680", "PT": "351", "SJ": "47", "PY": "595", "IQ": "964", "PA": "507", "PF": "689", "PG": "675", "PE": "51", "PK": "92", "PH": "63", "PN": "870", "PL": "48", "PM":
@bitbybit
bitbybit / csr_generator.php
Created July 28, 2014 08:19
Self-signed-certificate PKEY+CSR+X509 (SSL)
<?php
// ISO_3166-2
$countries = array(
array('AD', 'Andorra', 'Андорра'),
array('AE', 'United Arab Emirates', 'Объединённые Арабские Эмираты'),
array('AF', 'Afghanistan', 'Афганистан'),
array('AG', 'Antigua and Barbuda', 'Антигуа и Барбуда'),
array('AI', 'Anguilla', 'Ангилья'),
array('AL', 'Albania', 'Албания'),
@bitbybit
bitbybit / scrollspy.js
Last active December 29, 2015 08:09
Bootstrap ScrollSpy alternative with animation
// EXAMPLE:
// https://jsfiddle.net/vvvvvv/3hfcx3yx/
// https://raw.githubusercontent.com/jquery/jquery-mousewheel/4.0.x/jquery.mousewheel.min.js
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.12
*
* Requires: jQuery 1.2.2+