Skip to content

Instantly share code, notes, and snippets.


Simon Schick SimonSimCity

View GitHub Profile
SimonSimCity / bitshift.js
Created March 29, 2017 07:56
Takes an 8-bit string and encodes it to a 7-bit string (base64 compatible). Doesn't work with characters upover the 8th bit ...
View bitshift.js
const id =;
const bitEncode = (s) => {
let binString = '';
for (let i = 0; i < s.length; i++) {
const bin = (s.charCodeAt(i) - 20).toString(2);
const binSubString = (`0000000000${bin}`).slice(-7);
binString += binSubString;
SimonSimCity / mongodb-replace-UUID-BinData3-by-BinData4
Created October 13, 2016 07:56
Rewrite all your UUIDs, that accidentially have been saved as BinData(3, "") as BinData(4, ""). But be careful! This script only takes one implementation of the three (Python, Java, C#) and treats all BinData(3, "") datasets like that. This can damage your data if you don't know what you're doing.
View mongodb-replace-UUID-BinData3-by-BinData4
// Load this script:
// Start your mongo-shell with this script: mongo --shell uuidhelpers.js
// Find out what type of UUID it was. In my case it was PYUUID(). But it could (in your case) also be CSUUID() or JUUID().
db.tests.find(function() { return this.orderId.subtype() == 3 }).snapshot().forEach(function(elem) {
_id: elem._id
SimonSimCity / mongodb-fix-uuid-0
Created October 13, 2016 07:51
Replaces a UUID that has been saved as BinData(0, "") as a UUID.
View mongodb-fix-uuid-0
function decode_base64(s) {
var e={},i,k,v=[],r='',w=String.fromCharCode;
var n=[[65,91],[97,123],[48,58],[43,44],[47,48]];
for(z in n){for(i=n[z][0];i<n[z][1];i++){v.push(w(i));}}
var b=0,c,x,l=0,o=s.substring(i,i+72);
SimonSimCity /
Last active October 17, 2022 17:15 — forked from stephennancekivell/
Extended the script, written by @streeter to exclude the pinned formulae in the list of formulas to update.
# Notify of Homebrew updates via Notification Center on Mac OS X
# Author: Chris Streeter
# Requires: terminal-notifier. Install with:
# brew install terminal-notifier
SimonSimCity / guessTimeZone.php
Last active June 13, 2016 07:00
A script to guess the timezone based on data provided in a VTIMEZONE object in an iCal file. The name is a non-olson-name. Those with olson-names are easy. Originally written for
View guessTimeZone.php
$timezones = DateTimeZone::listIdentifiers();
$VTIMEZONE = array(
"TZID" => "Mitteleuropäische Zeit",
"DAYLIGHT" => array(
"RULE" => array(
"BYDAY" => "-1SU",
View phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<!-- -->
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
SimonSimCity / php5-fpm
Created April 5, 2013 09:39
Logrotate for php5-fpm ... first definition is for the log of the master-process, the second one is for every pool.
View php5-fpm
/var/log/php5-fpm.log {
rotate 21
kill -USR1 `cat /opt/php/logs/`
SimonSimCity / localhost
Last active December 15, 2015 19:18
You can use php_inkl_pathinfo for websites that want to support pathinfo - otherwise you can use php and just drop the pathinfo stuff ;) The php-configuration is
View localhost
server {
server_name localhost linos;
root /srv/http/$host/www;
index index.php index.html index.htm;
access_log /srv/http/$host/log/nginx.access.log;
error_log /srv/http/localhost/log/nginx.error.log;
location / {
SimonSimCity / pagination.html.twig
Last active April 4, 2023 19:41
A gist for pagination in Twig, based on the total number of pages, the current page and some URL-settings.
View pagination.html.twig
Updated by: Simon Schick <>
* currentFilters (array) : associative array that contains the current route-arguments
* currentPage (int) : the current page you are in
* paginationPath (string) : the route name to use for links
* showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled)
* lastPage (int) : represents the total number of existing pages