Skip to content

Instantly share code, notes, and snippets.

View SalemHarrache's full-sized avatar
💭
🤤

Salem Harrache SalemHarrache

💭
🤤
View GitHub Profile
@atomaths
atomaths / nginx.conf
Last active April 17, 2024 16:11
This is a FastCGI example server in Go.
## FastCGI
server {
location ~ /app.* {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
## Reverse Proxy (이 방식으로 하면 http.ListenAndServe로 해야함)
server {
@jcrist
jcrist / parametric_modules.py
Created August 30, 2015 20:47
Parametric Modules and functors in Python
from types import ModuleType
import sys
import inspect
from contextlib import contextmanager
class LocalImportFinder(object):
def find_module(self, fullname, path=None):
if path:
return None
@oakfang
oakfang / js.py
Last active April 7, 2023 04:45
How to import js modules into python
import sys
import jiphy # pip install
from os import path
from types import ModuleType
class JsFinder(object):
def find_module(self, name, m_path):
name += '.js'
if m_path is not None:
@vermotr
vermotr / upgrade.sh
Created April 28, 2016 11:24
Bash script to upgrade docker container after its image changed
#!/usr/bin/env bash
if [ $# -lt 1 ];then
echo Usage: `basename $0` image 1>&2
exit 1
fi
set -e
IMAGE=$1
CID=$(docker ps | grep $IMAGE | awk '{print $1}')
@kyle-eshares
kyle-eshares / models.py
Created October 15, 2016 18:01
Strict ForeignKeys
from __future__ import unicode_literals
from django.db import models
from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor # noqa
class RelationNotLoaded(Exception):
pass
@krisnod
krisnod / gist:56ff894f400cce7c742fb11fb2fde9cf
Last active April 6, 2022 18:46
RancherOS on Hetzner using software RAID (RAID 1)
Install:
----------
* Activate Hetzner Rescue System (Debian)
* Connect to Hetzner Rescue System using SSH and live boot RancherOS
(thanks goes to William Fleurant for showing how this can be done: https://github.com/wfleurant/boot-rancheros-hetzner/)
* apt-get update
* apt-get install kexec-tools aria2
@davidfraser
davidfraser / Google Drive Sync Wine Scripting.md
Last active July 9, 2023 01:00
Google Drive Sync Wine Scripting

Google Drive Sync Wine Scripting

This is a set of scripts that help running Google Drive Backup and Sync under Wine, with multiple Google accounts.

Each account is given its own Wine prefix (a separate wine configuration).

To install, run install-gdrive-sync google_account

List the accounts set up in ~/.config/gdrive-accounts

@hapylestat
hapylestat / __manual_openvpn_with_external_dhcpd.md
Last active October 25, 2022 15:12
Configure OpenVPN to work using external DHCP server

Configuration steps:

  • create bridge vpn-bridge and tap device connected to this bridge vpn-server:
nmcli con add ifname vpn-bridge type bridge con-name vpn-bridge-server
nmcli con modify vpn-bridge-server bridge.stp no
nmcli con add type tun ifname vpn-server con-name vpn-server-slave mode tap master vpn-bridge
@baleyko
baleyko / socat_server.sh
Created March 8, 2018 10:44 — forked from CMCDragonkai/socat_server.sh
Socat: Simple HTTP Server
socat \
-v -d -d \
TCP-LISTEN:1234,crlf,reuseaddr,fork \
SYSTEM:"
echo HTTP/1.1 200 OK;
echo Content-Type\: text/plain;
echo;
echo \"Server: \$SOCAT_SOCKADDR:\$SOCAT_SOCKPORT\";
echo \"Client: \$SOCAT_PEERADDR:\$SOCAT_PEERPORT\";
"
@jackton1
jackton1 / drf_optimize.py
Last active October 6, 2023 22:37
Optimize Django Rest Framework model views queries.
from django.db import ProgrammingError, models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query import normalize_prefetch_lookups
from rest_framework import serializers
from rest_framework.utils import model_meta
class OptimizeModelViewSetMetaclass(type):
"""
This metaclass optimizes the REST API view queryset using `prefetch_related` and `select_related`
if the `serializer_class` is an instance of `serializers.ModelSerializer`.