Skip to content

Instantly share code, notes, and snippets.

View divadsn's full-sized avatar
🎯
Focusing

David Sn divadsn

🎯
Focusing
View GitHub Profile

Welcome to the Lawnchair FAQ

How do I enable blur?

Open Lawnchair's settings, go to UI and under the "Theme" category, toggle the "Enable blur" option.

I enabled blur but it isn't working!

Open the settings, go to "Debug" and tap "Restart Lawnchair".

I can't see my statusbar icons!

Open the settings, go to "Behaviour" and toggle the "Light statusbar" option accordingly.

@divadsn
divadsn / nginx.conf
Created October 7, 2017 23:05
Boosted default nginx.conf, based on https://github.com/denji/nginx-tuning
# default nginx runtime settings
user www-data;
pid /run/nginx.pid;
# you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that
worker_processes auto; #some last versions calculate it automatically
# number of file descriptors used for nginx
# the limit for the maximum FDs on the server is usually set by the OS.
# if you don't set FD's then OS settings will be used which is by default 2000
@divadsn
divadsn / 808b.cpp
Created October 12, 2017 09:45
Codeforces solution for 808B
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int sum = 0, m;

Keybase proof

I hereby claim:

  • I am divadsn on github.
  • I am divadsn (https://keybase.io/divadsn) on keybase.
  • I have a public key whose fingerprint is 4C78 EF51 59DC 6223 D55E FE14 58E7 0CB5 5FAC 5ACA

To claim this, I am signing this object:

#!/bin/bash
ACCESS_LOG=/var/log/nginx/access.log
URL=webstats.razex.de
PORT=7890
OUTPUT=/var/www/webstats/index.html
SSL_CERT=/etc/letsencrypt/live/webstats.razex.de/fullchain.pem
SSL_KEY=/etc/letsencrypt/live/webstats.razex.de/privkey.pem
# Shitty workaround, see https://github.com/allinurl/goaccess/issues/600
@divadsn
divadsn / soundcloud-grabber.py
Last active November 10, 2017 00:13
Some hacky SoundCloud grabber for my radio station
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import eyed3
import soundcloud
import sqlite3
import sys
import re
import socket
# http://www.nateware.com/linux-network-tuning-for-2013.html
# Increase Linux autotuning TCP buffer limits
# Set max to 16MB for 1GE and 32M (33554432) or 54M (56623104) for 10GE
# Don't set tcp_mem itself! Let the kernel scale it based on RAM.
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.optmem_max = 40960
@divadsn
divadsn / local_storage.js
Created September 5, 2018 18:40
Proof of Concept, WIP.
Storage.prototype.setItem = function(key, value) {
AndroidLocalStorage.setItem(key, value);
}
Storage.prototype.getItem = function(key) {
AndroidLocalStorage.getItem(key);
}
@divadsn
divadsn / docker-android.md
Last active December 9, 2018 10:23
Building Android using a pre-built Docker image on Linux or macOS (or even Windows).

Introduction

In this guide, I will show you how to deploy and run a pre-built build environment using Docker.
This guide is tested to run on Linux and macOS, but it should also work on Windows.

You are a pr0 thug dev and you only need the docker instruction? Click here.

Prerequisites

Your build machine should at least follow the minimum specs for building Android:

  • CPU: 4 cores with 2 GHz
  • Memory: 8 GB (recommended 12 GB if running with graphical environment)
@divadsn
divadsn / secure_filename.py
Created March 2, 2019 02:39
Normalize and remove illegal characters in filenames in Python.
import string
import unicodedata
INVALID_FILE_CHARS = '/\\?%*:|"<>' # https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
def secure_filename(filename):
# keep only valid ascii chars
output = list(unicodedata.normalize("NFKD", filename))
# special case characters that don't get stripped by the above technique