Instantly share code, notes, and snippets.

View stringify_newline.c
/** @brief Stringify the newline character of a string.
*
* In detail, the newline character, '\n' is not supported on
* json string, so it needs to split in two characters "\n".
*
* @param [in] src The string to stringify
* @return the stringified string on success<br>
* NULL otherwise
*
*/
View tpm-tools_build.sh
#!/bin/sh -ex
mkdir -p sysroot
PREFIX_DIR=$(readlink -e sysroot)
mkdir -p $PREFIX_DIR/include
INCLUDE_DIR=$(readlink -e $PREFIX_DIR/include/)
mkdir -p $PREFIX_DIR/lib
LIB_DIR=$(readlink -e $PREFIX_DIR/lib/)
mkdir -p $LIB_DIR/pkgconfig
PKG_CONFIG_PATH=$(readlink -e $LIB_DIR/pkgconfig/)
View Makefile
all: get-network-interfaces get-gateway-ip
get-network-interfaces: get-network-interfaces.c
gcc -o get-network-interfaces -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-network-interfaces.c
get-gateway-ip: get-gateway-ip.c
gcc -o get-gateway-ip -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-gateway-ip.c
clean:
rm -rf get-network-interfaces
View stash-get-clone-repos.sh
#!/bin/sh
JQ="`which jq` -r"
CURL="`which curl` -s"
BASENAME="`which basename`"
GIT="`which git`"
STASH_SERVER=""
STASH_PROJECTS="${STASH_SERVER}/rest/api/1.0/projects"
View bitbucket-clone-user-repos.sh
#!/bin/bash -ex
BITBUCKET_SERVER_API="https://api.bitbucket.org"
USER_REPOSITORIES="${BITBUCKET_SERVER_API}/1.0/user/repositories"
# Utilites to be used
CURL="`which curl` -s"
JQ="`which jq`"
GIT="`which git`"
View fix_pem.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define PEM_CERTIFICATE_HEADER "-----BEGIN CERTIFICATE-----"
View ssha.c
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
#define NUM_SALT_BYTES 8
#define SHA1_LENGTH 20
View gist:489472062a3718899f80a921fcc74c17
/* ========================================================================
$File: tools/ctime/ctime.c $
$Date: 2016/05/08 04:16:55PM $
$Revision: 7 $
$Creator: Casey Muratori $
$Notice:
The author of this software MAKES NO WARRANTY as to the RELIABILITY,
SUITABILITY, or USABILITY of this software. USE IT AT YOUR OWN RISK.
View curl_multi_test.c
/* curl_multi_test.c
Clemens Gruber, 2013
<clemens.gruber@pqgruber.com>
Code description:
Requests 4 Web pages via the CURL multi interface
and checks if the HTTP status code is 200.
Update: Fixed! The check for !numfds was the problem.
View .git-commit-template.txt
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23