Skip to content

Instantly share code, notes, and snippets.

View svagionitis's full-sized avatar

stavros vagionitis svagionitis

View GitHub Profile
@svagionitis
svagionitis / Makefile
Last active November 21, 2023 07:45
This small utility shows how to use the `getifaddrs` and get information for network interfaces.
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
@svagionitis
svagionitis / stash-get-clone-repos.sh
Created October 27, 2016 16:09
Clone repositories for projects in Stash
#!/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"
@svagionitis
svagionitis / bitbucket-clone-user-repos.sh
Last active July 10, 2017 06:46
Clone a user repos from bitbucket using it's REST API
#!/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`"
@svagionitis
svagionitis / fix_pem.c
Last active September 27, 2020 11:54
Fix certificates in PEM format which don't have newlines
#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-----"
@svagionitis
svagionitis / ssha.c
Last active September 27, 2020 11:54
SSHA encoding and decoding (bruteforce)
#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
/* ========================================================================
$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.
@svagionitis
svagionitis / curl_multi_test.c
Created May 4, 2016 23:46 — forked from clemensg/curl_multi_test.c
libcurl multi interface example
/* 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.
@svagionitis
svagionitis / .git-commit-template.txt
Created March 12, 2016 18:48 — forked from adeekshith/.git-commit-template.txt
A Git commit template to make it easy to enforce a good and uniform commit message style across teams.
# <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
@svagionitis
svagionitis / curltest.c
Last active September 27, 2020 11:57 — forked from aaronhurt/curltest.c
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* Requirements:
*
* json-c - https://github.com/json-c/json-c
* libcurl - http://curl.haxx.se/libcurl/c
*
@svagionitis
svagionitis / Makefile
Created February 4, 2016 14:50
Generate a random string which will be used as a UUID.
all: rand_uuid
rand_uuid: rand_uuid.c
gcc -o rand_uuid -O2 -Wall -W -ansi -pedantic -std=gnu99 rand_uuid.c
clean:
rm -rf rand_uuid