Skip to content

Instantly share code, notes, and snippets.

@dolang
dolang / kivy_asyncio_example.py
Created May 28, 2018 15:46
Kivy with an asyncio EventLoop example
"""
Kivy asyncio example app.
Kivy needs to run on the main thread and its graphical instructions have to be
called from there. But it's still possible to run an asyncio EventLoop, it
just has to happen on its own, separate thread.
Requires Python 3.5+.
"""
@danielpops
danielpops / pyyaml-custom-loader.py
Created March 8, 2018 10:32
pyyaml custom loader with yaml.safe_load
import yaml
from yaml.constructor import ConstructorError
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
def no_duplicates_constructor(loader, node, deep=False):
@SuneKjaergaard
SuneKjaergaard / check_uwsgi.sh
Last active January 12, 2024 04:01
Small shell script to restart the uWSGI application when https://github.com/unbit/uwsgi/issues/1369 happens. Based on uWSGI server run by upstart
#!/bin/bash
line=$(tail -1 /var/log/myapp/myapp.uwsgi.log)
substr='uWSGI listen queue of socket'
if test "${line#*$substr}" != "$line"
then
#We're using upstart, could be easily adapted to fx systemd
# Adding a log statement to keep track of when this happens. Remember to create the monitor dir
/sbin/initctl restart myapp > /var/log/myapp/monitor/uwsgi-monitor.log 2>&1
echo "$(date) restarted myapp due to listen queue error" >> /var/log/myapp/monitor/uwsgi-monitor.log
#!/usr/bin/perl -w
use IO::Socket ;
use IO::Handle ;
my $host = $ARGV[0] || "localhost";
my $port = $ARGV[1] || 8000;
STDERR->autoflush(1);
STDOUT->autoflush(1);
my $data = "";
@tayvano
tayvano / gist:6e2d456a9897f55025e25035478a3a50
Created February 19, 2017 05:29
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
@brandomr
brandomr / merkle_tree.py
Created December 6, 2016 02:01
implement merkle tree in python
from hashlib import sha256 as sha
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
def m_tree(transactions):
"""Takes an array of transactions and computes a Merkle root"""
sub_t = []
@mikefromit
mikefromit / jinja2_markdown_filter.md
Last active August 29, 2021 11:21
Markdown filter for jinja2

markdown.py

@environmentfilter
def markdown(env, value):
    """
    Markdown filter with support for extensions.
    """
    try:
        import markdown as md
@delascuevas
delascuevas / gist:45f46c8c33646d860a3314a88aaea70a
Created September 23, 2016 15:52
Rot13 english word pairs
a n
ab no
aba non
abb noo
abba noon
abib novo
abjurer nowhere
abl noy
abn noa
abo nob
@m4dEngi
m4dEngi / IClientUser.h
Last active September 23, 2017 22:13
//========================== Open Steamworks ================================
//
// This file is part of the Open Steamworks project. All individuals associated
// with this project do not claim ownership of the contents
//
// The code, comments, and all related files, projects, resources,
// redistributables included with this project are Copyright Valve Corporation.
// Additionally, Valve, the Valve logo, Half-Life, the Half-Life logo, the
// Lambda logo, Steam, the Steam logo, Team Fortress, the Team Fortress logo,
// Opposing Force, Day of Defeat, the Day of Defeat logo, Counter-Strike, the
@bsara
bsara / git-ssh-auth-win-setup.md
Last active April 24, 2025 05:04
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
  • .ssh/config