Skip to content

Instantly share code, notes, and snippets.

@greut
greut / bot.py
Last active February 12, 2020 13:47
Sample asyncio bot for Slack
"""Sample Slack ping bot using asyncio and websockets."""
import asyncio
import json
import signal
import aiohttp
from config import DEBUG, TOKEN
import websockets
@bmhatfield
bmhatfield / .profile
Last active August 9, 2025 20:28
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
/**
* Get a list of Events from a given Calendarurl
*
* @param {String} url
* @param {String} user
* @param {String} pass
* @param {String} date from which to start like 20140101T120000Z
* @param {String} date from which to stop like 20140102T120000Z, optional (can be undefined)
* @param {function} cb
*/
@alirobe
alirobe / reclaimWindows10.ps1
Last active October 22, 2025 05:28
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
### OR take a look at
### https://github.com/HotCakeX/Harden-Windows-Security
@daveweber
daveweber / graphs.py
Created March 17, 2016 18:46
Breadth First and Depth First Search in Python
def bfs(graph, start):
visited, queue = set(), [start]
while queue:
vertex = queue.pop(0)
if vertex not in visited:
visited.add(vertex)
queue.extend(graph[vertex] - visited)
return visited
@akrylysov
akrylysov / asyncio_producer_consumer.py
Last active June 30, 2024 09:20
Python 3 asyncio basic producer / consumer example
import asyncio
import random
q = asyncio.Queue()
async def producer(num):
while True:
await q.put(num + random.random())
await asyncio.sleep(random.random())
@Roland09
Roland09 / Algorithm.java
Created February 13, 2016 15:54
Line of Sight Demo
package application;
import java.util.ArrayList;
import java.util.List;
public class Algorithm {
/**
* Sweep around the given circle with the given distance and create the scan lines
* @param startX
@jbaldivieso
jbaldivieso / forms.py
Created February 12, 2016 23:12
Django code to make a multi-checkbox widget that works with Django's Postgres-based ArrayField
from django import forms
from django.forms import widgets
DELIMITER = ','
class MultiCheckboxChoiceInput(widgets.CheckboxChoiceInput):
def __init__(self, *args, **kwargs):
@Battleroid
Battleroid / tic-tac-toe.lisp
Created February 9, 2016 08:47 — forked from trhura/tic-tac-toe.lisp
tic-tac-toe AI using two-ply minmax in racket (scheme)
#lang scheme/gui
(define new-game #t)
(define game-finished #f)
(define user-move #\X)
(define computer-move #\O)
(define move-count 0)
(define start-move user-move)
@mahmoud
mahmoud / remerge.py
Last active November 29, 2023 09:08
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
"""
This is an extension of the technique first detailed here:
http://sedimental.org/remap.html#add_common_keys
In short, it calls remap on each container, back to front, using the accumulating
previous values as the default for the current iteration.
"""