Skip to content

Instantly share code, notes, and snippets.

View fpersson's full-sized avatar

Fredrik Persson fpersson

View GitHub Profile
#!/bin/bash
#Desc: Ett mindre fint bashscript för att skapa en mpeg-film av ett gäng bilder
# med morphad övergång mellan bilderna. Scriptet kräver ffmpeg och ImageMagick.
#Version: 1.1
#Coder: Fredrik Persson
#E-mail: fpersson.se@gmail.com
#Download/webpage:
#Licens: BSD
#TODO: Exif-rotation?
@rschildmeijer
rschildmeijer / DefaultHashMap.java
Created November 2, 2011 19:19
defaultdict in java
public class DefaultHashMap<K, V> extends HashMap<K, V> {
private final Class<V> cls;
public DefaultHashMap(Class factory) {
this.cls = factory;
}
@Override
public V get(Object key) {
@ionrock
ionrock / lockfile.py
Created June 29, 2012 04:14
A file locking example
"""
A file lock implementation that tries to avoid platform specific
issues. It is inspired by a whole bunch of different implementations
listed below.
- https://bitbucket.org/jaraco/yg.lockfile/src/6c448dcbf6e5/yg/lockfile/__init__.py
- http://svn.zope.org/zc.lockfile/trunk/src/zc/lockfile/__init__.py?rev=121133&view=markup
- http://stackoverflow.com/questions/489861/locking-a-file-in-python
- http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
- http://packages.python.org/lockfile/lockfile.html
@alan-mushi
alan-mushi / json_parser.c
Last active March 25, 2024 19:23
Examples for the json-c tutorial.
/*
* A simple example of json string parsing with json-c.
*
* clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c
*/
#include <json.h>
#include <stdio.h>
int main() {
struct json_object *jobj;
@ashwin
ashwin / getopt_long_example.cpp
Last active April 5, 2023 21:42
How to parse options in C++ using getopt_long
#include <getopt.h>
#include <iostream>
int num = -1;
bool is_beep = false;
float sigma = 2.034;
std::string write_file = "default_file.txt";
void PrintHelp()
{
@drmalex07
drmalex07 / README-python-service-on-systemd-activated-socket.md
Last active January 13, 2024 12:53
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at /opt/foo/serve.py.

@drmalex07
drmalex07 / README-setup-socket-activated-systemd-service.md
Last active December 26, 2023 05:13
An example inetd-like socket-activated service. #systemd #inetd #systemd.socket

README

This is an example of a socket-activated per-connection service (which is usually referred to as inetd-like service). A thorough explanation can be found at http://0pointer.de/blog/projects/inetd.html.

Define a socket unit

The key point here is to specify Accept=yes, which will make the socket accept connections (behaving like inetd) and pass only the resulting connection socket to the service handler.

@simonw
simonw / how-to.md
Last active June 13, 2024 09:35
How to create a tarball of a git repository using "git archive"
@Brainiarc7
Brainiarc7 / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Last active March 26, 2024 18:18
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@johncrossland
johncrossland / Sphinx_with_Markdown.rst
Created December 12, 2018 00:28
Sphinx with Markdown - How to use Markdown with Sphinx (including Markdown tables that Sphinx does not handle by default for PDF and HTML output)

Sphinx with Markdown walkthrough for HTML and PDF output

This walkthrough installs Sphinx and configures it to output HTML and PDF from .md. If you install it on a VM, allocate over 25GB storage and multiple processors. You'll need Ubuntu 16.04 LTS, an internet connection, and sudo rights.