Skip to content

Instantly share code, notes, and snippets.

View meteozond's full-sized avatar
🚑
🌍

Alexander Klimenko meteozond

🚑
🌍
View GitHub Profile
from threading import Condition
import traceback
import time
from minecraft.networking.connection import Connection
from minecraft.networking.packets import clientbound, serverbound
from minecraft.networking.types import (
Position, PositionAndLook, RelativeHand, BlockFace,
)
@matthewfeickert
matthewfeickert / config_example.py
Last active October 23, 2023 09:32
JSON config files with argparse from the CLI example
import json
import argparse
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['text.usetex'] = True
# Inspiration came from https://stackoverflow.com/q/3609852/8931942
@e11s
e11s / anyconnect_gui.scpt
Last active March 6, 2020 10:12
Cisco AnyConnect VPN GUI client connection automation (with Keychain)
-- 1. Create a new generic password entry in Keychain Access called "WHATEVER_AnyConnect_VPN" (the name in Keychain access must match that in line 39 below) with your password for the Cisco AnyConnect VPN server.
-- 2. Modify values of vpnUrl and keychainKey variables
-- 3. Open this script in Script Editor (both this and the above are in the Applications->Utilities folder) and "Save as.." an Application (.app) with desired name.
-- 4. Open Security & Privacy System Preferences, go to Privacy, Accessibility.
-- 5. Enable the above .app so it can access Accessibility
-- 6. Copy and paste a nice icon on the generic Applescript icon (I used a copy of the default AnyConnect one)
-- 7. Add the new .app to /Users/[yourshortname]/Applications with a shortcut to your Dock
-- 8. Enjoy the fast connection with no need to enter password and increased security of not having a sensitive password stored as plain text
-- 9. Run script again to close connection
@angstwad
angstwad / dict_merge.py
Last active March 1, 2024 23:53
Recursive dictionary merge in Python
# Copyright 2016-2022 Paul Durivage
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
var _ = require('underscore');
var Backbone = require('backbone');
var cheerio = require('cheerio');
var request = require('request');
Backbone.ajax = function(options) {
options.json = true;
return request(options, function(error, result) {
if (error) {
@alekstorm
alekstorm / README.md
Last active April 23, 2020 19:00
Ansible callback plugin that posts events to your Datadog event stream as you deploy

Installation

To install, place datadog.py in your callback plugins directory. If you don't yet have one, run:

mkdir -p plugins/callback

Then place the following in your ansible.cfg file:

[defaults]

callback_plugins = ./plugins/callback

@FZambia
FZambia / procache.py
Last active April 27, 2019 16:06
python in process memory cache based on ordered dictionary - with size limit and timeout support
# coding: utf-8
import time
from collections import OrderedDict
class Cache():
"""
In process memory cache. Not thread safe.
Usage:
#!/usr/bin/env python
#
# Copyright 2012 Patrick Hetu <patrick.hetu@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@copitux
copitux / Doc.rst
Created September 24, 2012 22:20
Django, Django forms and Django rest framework: Payload validation

Django request flow

-------------------------------                         ------------------ Django --------------------
| Browser: GET /udo/contact/2 |    === wsgi/fcgi ===>   | 1. Asks OS for DJANGO_SETTINGS_MODULE      |
-------------------------------                         | 2. Build Request (from wsgi/fcgi callback) |
                                                        | 3. Get settings.ROOT_URLCONF module        |
                                                        | 4. Resolve URL/view from request.path      | # url(r'^udo/contact/(?P<id>\w+)', view, name='url-identifier')
                                                        | 5. Apply request middlewares               | # settings.MIDDLEWARE_CLASSES
@atabary
atabary / dblock.py
Created May 26, 2012 08:45
MySQL table lock with django
#-*- coding: utf-8 -*-
import contextlib
from django.db import connection
@contextlib.contextmanager
def acquire_table_lock(read, write):
'''Acquire read & write locks on tables.