Skip to content

Instantly share code, notes, and snippets.

@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;
@alan-mushi
alan-mushi / fields_magic.c
Created July 29, 2014 10:05
Simple ncurses form example with fields that actually behaves like fields
/*
* Simple ncurses form example with fields that actually behaves like fields.
*
* How to run:
* gcc -Wall -Werror -g -pedantic -o test fields_magic.c -lform -lncurses
*/
#include <ncurses/ncurses.h>
#include <ncurses/form.h>
#include <assert.h>
#include <string.h>
@alan-mushi
alan-mushi / scrolling_form.c
Created July 11, 2014 12:38
This is a simple example of "scrolling" form with ncurses. It use "page" to allow forms with more fields than your window can print.
/*
* This is a simple example of "scrolling" form with ncurses.
* It use "page" to allow forms with more fields than your window can print.
*
* It prints a "label" (inactive field) and a regular field and let you
* "scroll" pages of the form.
*
* How to compile:
* gcc -o test scrolling_form.c -lform -lncurses
*/
@alan-mushi
alan-mushi / ripe_test.ex
Last active July 15, 2020 22:55
Ripe inetnum elixir parsing (OOM-killer)
# Add flow as a mix dep
# Killed by the OOM-killer
defmodule RipeTest do
use ExUnit.Case
doctest Ripe
# From https://ftp.ripe.net/ripe/dbase/split/
@filename "./assets/ripe.db.inetnum.gz"
@outfile 'inetnum.dets'
@alan-mushi
alan-mushi / thunar-openssl-encrypt.sh
Created February 9, 2016 11:49
Simple Encryption/Decryption in Thunar's contextual menu
#!/bin/sh
usage() {
echo "$0 -f <filename>"
echo
echo " required:"
echo " -f input filename"
echo
}
@alan-mushi
alan-mushi / popup.c
Created July 24, 2014 10:22
Simple pop-up using ncurses form and menu library (not CDK) in C. This is a bit more oriented towards easy integration rather than a stand-alone example.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "popup.h"
static WINDOW *win_body;
static WINDOW *win_form;
static WINDOW *win_menu;
#include <click/config.h>
#include <click/args.hh>
#include "DummyAnswer.hh"
#include "DummyProto.hh"
CLICK_DECLS
DummyAnswer::DummyAnswer() { };
DummyAnswer::~DummyAnswer() { };
@alan-mushi
alan-mushi / ncurses-simple-pop-up.c
Last active October 26, 2017 06:47
Very simple pop-up using ncurses form and menu library (not CDK) in C
/*
* Very simple pop-up using ncurses form and menu library (not CDK).
*
* The buttons are made from items and the fields are made from... well fields.
*
* How to run:
* gcc -o test -lmenu -lform -lncurses ncurses-simple-pop-up.c -g && ./test
*/
// Depending on your OS you might need to remove 'ncurses/' from the include path.
@alan-mushi
alan-mushi / hello.click
Last active November 21, 2016 15:28
Click modular router: example of non element compilation file
InfiniteSource(LIMIT 1)
-> UserElem()
-> Discard;
@alan-mushi
alan-mushi / music
Last active July 17, 2016 14:47
Musique sympa
The Bewitched Hands - The laws of walls
The Bewitched Hands - Thank you, goodbye, it's over
Some Velvet Morning - How to start a revolution
Ellie Goulding - Your Song
Soma - Letters to unwrite
Angus and Julia Stone - Big Jet Plane
The Rolling Stones - Sympathy For The Devil
The Strokes - Machu Picchu
The Strokes - I'll Try Anything Once
Bloc Party - Banquet