Skip to content

Instantly share code, notes, and snippets.

@ghedo
ghedo / sound_playback.c
Last active March 2, 2024 08:47
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
@HungHuynh
HungHuynh / ReasPKCS7
Created October 1, 2012 11:04
how to Read the certificates file from the PKCS7.p7b certificate file usind openssl
#include <stdio.h>
#include <openssl/pkcs7.h>
#include <openssl/x509.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
int main(int argc, char **argv)
{
PKCS7 *p7 = NULL;
BIO *in = BIO_new(BIO_s_file());
@skyscribe
skyscribe / .gdbinit
Created October 30, 2012 03:04
GDB init file to print STL containers and data members
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@cat-in-136
cat-in-136 / libtar-list.c
Last active August 18, 2022 11:47
Study for reading/writing a tar file using libtar
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <libtar.h>
int main(int argc, char *argv[]) {
TAR *tar = NULL;
int ret = 0;
int exitcode = 0;
@will-hart
will-hart / plugin.py
Created July 1, 2013 09:36
A simple python plugin system using a custom metaclass
# a simple Python plugin loading system
# see http://stackoverflow.com/questions/14510286/plugin-architecture-plugin-manager-vs-inspecting-from-plugins-import
class PluginMount(type):
"""
A plugin mount point derived from:
http://martyalchin.com/2008/jan/10/simple-plugin-framework/
Acts as a metaclass which creates anything inheriting from Plugin
"""
@roxlu
roxlu / YUV420PGrabber.cpp
Created July 2, 2013 08:36
OpenGL RGB > YUV420P shader/class (doesn't do much more. implementation/usage is up to you)
#include <assert.h>
#include <roxlu/core/Utils.h>
#include <roxlu/core/Log.h>
#include "YUV420PGrabber.h"
YUV420PGrabber::YUV420PGrabber()
:y_prog(0)
,y_vert(0)
,y_frag(0)
,uv_prog(0)
@flashlib
flashlib / RSA非对称数据加密算法使用示例
Created August 19, 2013 03:08
RSA非对称数据加密算法使用示例
#include <stdio.h>
#include <string.h>
#include <openssl/rsa.h>
#include <openssl/applink.c>
void print_buf_hex( unsigned char *buf, int len )
{
int i;
for( i = 0; i < len; i++ )
@barrysteyn
barrysteyn / Base64.md
Last active April 9, 2024 08:29
OpenSSL Base64 En/Decode: Portable and binary safe.

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn

@billyshambrook
billyshambrook / ffmpeg_build.sh
Last active September 23, 2022 07:15
Build FFMPEG, x264 and FDK-AAC
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \
libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libspeex-dev \
libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
cd
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '