Skip to content

Instantly share code, notes, and snippets.

@falsovsky
falsovsky / doom.py
Last active March 7, 2021 23:52
Zandronum Master Server query
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import socket
import struct
import sys
import time
import concurrent.futures
@smurugap
smurugap / heat-stack-delete-db
Created April 9, 2018 22:16
DB Changes to delete a heat stack manually.
mysql -hlocalhost -uroot -p$(cat /etc/contrail/mysql.token) -e "
use heat;
delete from resource_data where resource_id in (select id from resource where stack_id in (select id from stack where name = \"$project\"));
delete from resource where stack_id in (select id from stack where name = \"$project\");
delete from event where stack_id in (select id from stack where name = \"$project\");
delete from stack where name = \"$project\";
@dchest
dchest / gist:c1985fd5bef3b19bf73f3165fe2e59b6
Created October 13, 2016 07:10
Secure coding guidelines for C
Don't write in C.
@jessfraz
jessfraz / go-release-stats.md
Last active March 9, 2019 02:32
stats on the go 1.7 release for fun

Setup:

# set CONTRIBUTORS file to mailmap to remove duplicate emails for the same name
# see: https://git-scm.com/docs/git-shortlog#_mapping_authors
$ git config mailmap.file CONTRIBUTORS

Top 10 contributors (all):

import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@ipedrazas
ipedrazas / knife cheat
Last active December 13, 2021 11:50
Hello!
# knife cheat
## Search Examples
knife search "name:ip*"
knife search "platform:ubuntu*"
knife search "platform:*" -a macaddress
knife search "platform:ubuntu*" -a uptime
knife search "platform:ubuntu*" -a virtualization.system
knife search "platform:ubuntu*" -a network.default_gateway
@shimarin
shimarin / block_device_sector_size.py
Last active January 11, 2024 13:24
Determining block device's sector size in Linux+Python
#!/usr/bin/python
import fcntl
import os
import struct
import array
import sys
BLKGETSIZE=0x1260
BLKGETSIZE64=0x80081272
BLKSSZGET=0x1268
@miguelmota
miguelmota / README.md
Last active March 16, 2024 12:52
Multiple accounts with Mutt E-Mail Client (gmail example)

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/