Skip to content

Instantly share code, notes, and snippets.

🚑
🌍

Alexander Klimenko meteozond

🚑
🌍
View GitHub Profile
@matthewfeickert
matthewfeickert / config_example.py
Last active Jan 21, 2020
JSON config files with argparse from the CLI example
View config_example.py
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 Mar 6, 2020
Cisco AnyConnect VPN GUI client connection automation (with Keychain)
View anyconnect_gui.scpt
-- 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 Aug 4, 2020
Recursive dictionary merge in Python
View dict_merge.py
# Recursive dictionary merge
# Copyright (C) 2016 Paul Durivage <pauldurivage+github@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,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
View isomorphicish.js
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 Apr 23, 2020
Ansible callback plugin that posts events to your Datadog event stream as you deploy
View README.md

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 Apr 27, 2019
python in process memory cache based on ordered dictionary - with size limit and timeout support
View procache.py
# coding: utf-8
import time
from collections import OrderedDict
class Cache():
"""
In process memory cache. Not thread safe.
Usage:
View rsyslog_sentry.py
#!/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 Sep 24, 2012
Django, Django forms and Django rest framework: Payload validation
View Doc.rst

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
MySQL table lock with django
View dblock.py
#-*- coding: utf-8 -*-
import contextlib
from django.db import connection
@contextlib.contextmanager
def acquire_table_lock(read, write):
'''Acquire read & write locks on tables.
@alassek
alassek / extendEach.js
Created Sep 19, 2011
Easy multiple-inheritance in Backbone.js
View extendEach.js
(function () {
function extendEach () {
var args = Array.prototype.slice.call(arguments),
child = this;
_.each(args, function (proto) {
child = child.extend(proto);
});
You can’t perform that action at this time.