Skip to content

Instantly share code, notes, and snippets.

View daniel-illi's full-sized avatar
💭
☕ 💎 🔋

Daniel Illi-Zuberbühler daniel-illi

💭
☕ 💎 🔋
View GitHub Profile
@daniel-illi
daniel-illi / sdcard_fix.md
Created August 6, 2024 20:31 — forked from mvidaldp/sdcard_fix.md
SD card formating fix via ADB shell when Android GUI fails (internal, portable/external or mixed). Works on Retroid Pocket 2+

I wrote this short tutorial because extending my internal storage using my new micro SD card on my Retroid Pocket 2+ failed all the time. Only setting it up as portable/external worked. However, this instructions should work in any Android 5.0+ device.

So, in case you have problems setting up your SD card on your Android device via graphical interface (setting up storage as extended internal memory or portable), and you get a corrupted SD card or any other error, follow these steps to fix it via adb shell:

  1. Make sure you have adb access to your Android device: Settings > System > About, touch/click on Build number until Developer options are enabled:
  2. Go to Settings > System > Developer options and enable USB debugging.
  3. Assuming you have adb installed on your remote terminal run the following:

adb shell

@daniel-illi
daniel-illi / traefik-auth.conf
Created September 16, 2019 12:19 — forked from DiscoYeti/traefik-auth.conf
Traefik fail2ban
# /etc/fail2ban/filter.d/traefik-auth.conf
[Definition]
failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) .+\" 401 .+$
@daniel-illi
daniel-illi / README.md
Created October 6, 2017 11:01 — forked from tristanm/README.md
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@daniel-illi
daniel-illi / gitignore2svnignore.sh
Created April 6, 2017 09:39 — forked from iegik/gitignore2svnignore.sh
Oneliner to convert svn:ignore into .gitignore
#!/bin/bash
cat .gitignore | sed 's/^/\.\//g;s/\(.*\)\/\([0-9a-zA-Z\*\?\.]*\)$/svn propedit svn:ignore "\2" \1 /mg' | bash

Caching

Problemstellung

  • API neu designed, Ziel Reaktionszeit der App immer <1s → alle benötigten Daten in 1 request/response
  • Peaks (von 50 auf 5000 Clients)
  • Multiprozess Architektur (Versandmodul, cron jobs, shared db)
  • Langsame Antwortzeiten aufgrund von DB Queries

Demo v5 API

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
module Colors
def colorize(text, color_code)
"\033[#{color_code}m#{text}\033[0m"
end
{
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
# Gemfile
gem 'kramdown'
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<title>The API Documentation</title>
<script type="text/javascript" src="http://yandex.st/highlightjs/6.1/highlight.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/default.min.css"/>
<script type="text/javascript">
var hilight_hljs = function(){
$('pre code').each(function(i, e){hljs.highlightBlock(e, ' ');});
-- SPLIT_STR MySQL Function
-- from http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/
CREATE FUNCTION SPLIT_STR(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),