Skip to content

Instantly share code, notes, and snippets.

@peerapongsam
peerapongsam / Gson Dynamic Key Deserializer.java
Last active August 1, 2020 13:01
Gson Dynamic Key Deserializer
package me.peerapong.android_dynamicjsonkey;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
@tachyondecay
tachyondecay / models.py
Last active July 7, 2024 09:00
Tags in Flask via SQLalchemy and association proxies
from app import db
from sqlalchemy import desc, event, func, orm
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy_utils import ArrowType, auto_delete_orphans
from slugify import slugify_unicode
tags = db.Table('tag_associations',
db.Column('tag_id', db.Integer, db.ForeignKey('tags.id')),
db.Column('article_id', db.Integer, db.ForeignKey('articles.id')))
@mustafaturan
mustafaturan / network-tweak.md
Last active June 17, 2025 21:44
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@mdonkers
mdonkers / server.py
Last active June 14, 2025 20:50
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@ygurin
ygurin / synapticshotkey.ahk
Last active March 30, 2022 14:05
Simple AutoHotkey script disables and enables touchpad on Windows 10. Synaptics touchpad driver must be installed. This is targeted at older machines where the driver is installed, but Function key for disabling the touchpad doesn’t work.
;Disable and Enable Synaptics touchpad using Keyboard Shortcut on Windows 10
;CTRL+F9 to enable the Synaptics Touchpad
^F9::
Run C:\Windows\System32\control.exe main.cpl ;Open Mouse Properties
Sleep 1000 ;Wait one second
if WinExist("Mouse Properties") {
WinActivate ;Make Mouse Properties the active Window
Send, ^+{TAB} ;Go to last tab
Send, !E ;Alt+E to enable touchpad
@vvoody
vvoody / com.foobar.ifconfiglo.plist
Created April 26, 2017 07:00
ifconfig alias loopback on macOS startup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.foobar.ifconfiglo</string>
<key>ProgramArguments</key>
<array>
<string>/sbin/ifconfig</string>
@huyinghuan
huyinghuan / encrypt_file_pkcs5_pkcs7.go
Created May 31, 2017 07:44
golang encrypt with pkcs5 and pkcs7
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
"io"
"io/ioutil"
@harshavardhana
harshavardhana / nginx-minio-static.md
Last active May 6, 2025 07:55 — forked from koolhead17/gist:4b8dd8d95ec86368634693cf9ad9391c
How to configure static website using Nginx with MinIO ?

How to configure static website using Nginx with MinIO ?

1. Install nginx

2. Install minio

3. Install mc client

4. Create a bucket:

$ mc mb myminio/static
Bucket created successfully ‘myminio/static’.
@mcxiaoke
mcxiaoke / crossover.md
Created July 21, 2017 05:52 — forked from Nathaniel100/crossover.md
crossover在mac系统字体模糊解决方法

先从windows系统复制文件simsun.ttf到你的虚拟机下(c:\windows\fonts\),在CrossOver下打开regedit(命令行方式) 找到HKEY_CURRENT_USER\Software\Wine\Fonts\Replacements,删除下面的项目simsun 宋体 新宋体

@fearblackcat
fearblackcat / proxy_for_terminal.md
Last active July 9, 2025 00:20
Set proxy for terminal on mac

Shadowsocks Proxy

apt-get install python-pip
pip install shadowsocks

sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start