Skip to content

Instantly share code, notes, and snippets.

@mathieu-aubin
mathieu-aubin / grabua.sh
Last active April 23, 2021 14:56
Grab User-Agents from access logs with typical structure
#!/bin/bash
zcat /var/log/*/*access*.gz | grep -Ev '(robots|humans).txt|favicon' | awk -F\" '($2 ~ "^GET /"){print $6}' | \
grep -Eiv "^-$|^$|Wordpress|^WOW$|wget|^curl.+|WhatsApp|Twitter|TOBBOT|GoogleBot|AdsBot|Baidu|Crawl|TurnitinBot|random|knowledge|smurl|thither|urlcheck|Traackr|Spider|^Z$|Zoom|chr\(|test|scrapy|ruby|SafeDNS|Research|Whatweb|semrush|seobility|slack|scan|yahoo|requests|reqwest|queue|serende|yakuza|zmeu|zoxh|xenu|semantic|siri|tagvisit|wapp|p40|PHP|cfnetwork|Pattern|python|seeker|scamadviser|\\x|pinterest|Pocket|thumbor|photon|null|okhttp|panscient|pa11y|OnalyticaBot|fetch|my_linux|powered|node\.js|newspaper|zgrab|gnowit|gzip|lighthouse|Datanyze|7777|MAUI|J2ME|seznam|proxy|detection|libwww|survey|hakai|nmap|go-http-client|PROBT|Nimbostratus|^Mozilla\/[[:digit:]].[[:digit:]][[:digit:]]?$|5.01682558|Mozilla\/5.0 Mozilla\/5.0|Zend|user-agent|symfony|poster|Writter|Rome|project25499|SMTB|^Mozilla [[:digit:]].[[:digit:]]|^Mozilla\/[[:digit:]].[[:digit:]]$|^Mozilla$|WebDav|Ahrefs|aiHitBot|Cloud
@nuriel77
nuriel77 / watch_events.py
Last active March 5, 2018 22:50
Watch for events from kubernetes
from kubernetes import client, config, watch
from pprint import pprint, pformat
import argparse
import logging
import urllib3
import threading
import signal
import time
import json
import sys
@marceljanerfont
marceljanerfont / worker.py
Created September 21, 2017 10:24
Stoppable worker thread
# -*- coding: utf-8 -*-
import threading
import time
class Worker(object):
def __init__(self):
self._stop_event = threading.Event()
self._thread = threading.Thread(target=self.run, args=())
# important otherwise never stops when run() gets stuck!!
@rldotai
rldotai / interruptible_threads.py
Created May 7, 2016 23:58
Python threads that can be safely terminated via KeyboardInterrupt (e.g., ctrl-c)
#!/python3
"""
Python threads with a `threading.Event` flag to allow for safe termination with
a `KeyboardInterrupt`.
While it is possible to have all threads abruptly terminate by setting
`daemon == True` on the thread object, sometimes you need to perform cleanup,
so we essentially set a flag for the threads to check, assuming they all work
via an ongoing loop.
Note that this flag could be any object that evaluates to `True` or `False`,
@josefmonje
josefmonje / The Technical Interview Cheat Sheet.md
Created February 14, 2016 14:54 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@thisismitch
thisismitch / le-renew-webroot
Last active April 26, 2024 04:13
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file="/usr/local/etc/le-renew-webroot.ini"
le_path='/opt/letsencrypt'
exp_limit=30;
if [ ! -f $config_file ]; then
echo "[ERROR] config file does not exist: $config_file"
@damienalexandre
damienalexandre / ProfilerController.php
Created July 5, 2015 15:10
Adding a checkbox on the translation panel + custom save controller
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ProfilerController extends Controller
@peterjmag
peterjmag / react-native-talk.md
Last active June 21, 2021 10:13
Let's build a React Native app in 20 minutes - React Berlin #1 (April 2015)
<?php
namespace ProgrammingAreHard\ResourceBundle\Security;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
use Symfony\Component\Security\Acl\Exception\NoAceFoundException;
use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface;
use Symfony\Component\Security\Acl\Permission\BasicPermissionMap;
from time import sleep
from threading import Event, Thread
def main():
# set
to_run = Event()
to_run.set()
# start thread
worker = Worker(to_run, 1)