Skip to content

Instantly share code, notes, and snippets.

View Mr-Slippery's full-sized avatar

Cornel Izbașa Mr-Slippery

View GitHub Profile
@Mr-Slippery
Mr-Slippery / .bashrc
Last active August 8, 2019 20:34
"If you could ... that would be greeaat" prompt
# Shamelessly based on:
# https://stackoverflow.com/questions/39305476/bash-prompt-with-background-color-extending-to-end-of-line
FIRST_YOU_COULD=1
PROMPT_COMMAND=__prompt_command
__prompt_command()
{
local None='\[\e[0m\]'
local Green='\[\033[1;38;5;10m\]'
local LightPurple='\[\033[1;35m\]'
@Mr-Slippery
Mr-Slippery / klee_cpp.sh
Last active August 16, 2019 06:02
Running klee on a C++ program using its Docker image
#!/usr/bin/env bash
set -euo pipefail
FILE=${1-main.cc}
if [ ! -f "${FILE}" ]
then
cat << EOF > "${FILE}"
#include <klee/klee.h>
#include <assert.h>
@Mr-Slippery
Mr-Slippery / klee_template.c
Created October 20, 2019 12:46
Template C file for verifying an array operation using KLEE
#ifdef KLEE
#include <klee/klee.h>
#include <assert.h>
#endif
#include <stdbool.h>
#ifndef KLEE
#include <stdio.h>
#endif
@Mr-Slippery
Mr-Slippery / col3.py
Created November 6, 2019 21:01
Find counter examples to the conjecture: The orbit of all strictly positive natural numbers through col3 ends up in one of the two finite cycles.
#!/usr/bin/env python3
"""
Find counter examples to the conjecture:
The orbit of all strictly positive natural numbers
through col3 ends up in either C[0] and C[1].
"""
# Ignores PEP8 and pylint for brevity and math-friendly notation.
import sys
@Mr-Slippery
Mr-Slippery / data_member_detection.cpp
Created March 5, 2020 17:41
Basic data member detection in C++17
#include <type_traits>
#define HAS_MEMBER(member) \
template <typename T, typename = void> \
struct has_##member : std::false_type {}; \
template <typename T> \
struct has_##member<T, std::void_t<decltype(std::declval<T>().member)>> : std::true_type {};
struct WithBla {
int bla;
@Mr-Slippery
Mr-Slippery / mandel.rs
Last active April 5, 2020 16:27
ASCII rendering of Mandelbrot in Rust
extern crate num;
use num::complex::Complex;
struct IFS
{
max_iter: u64
}
trait DDS<State> {
@Mr-Slippery
Mr-Slippery / klee_c.sh
Created November 18, 2020 20:49
Example invocation of KLEE on a sample source or user-supplied file
#!/usr/bin/env bash
set -euo pipefail
FILE=${1-main.cc}
if [ ! -f "${FILE}" ]
then
cat << EOF > "${FILE}"
#include <klee/klee.h>
#include <assert.h>
@Mr-Slippery
Mr-Slippery / hamilton.c
Last active November 19, 2020 15:09
Hamiltonian cycle finder with KLEE
#include <klee/klee.h>
#include <assert.h>
typedef unsigned char byte;
#define N 5
byte a[N * N]=
{
/* A B C D E*/
@Mr-Slippery
Mr-Slippery / queens.c
Created November 19, 2020 17:15
Solving 8-queens with KLEE
#include <klee/klee.h>
#include <assert.h>
#define N 8
unsigned char queens[N];
int abs(int x)
{
return x >= 0 ? x: -x;
}
@Mr-Slippery
Mr-Slippery / einstein.c
Last active November 19, 2020 17:35
Solving Einstein's enigma with KLEE
#include <klee/klee.h>
#include <assert.h>
typedef enum {
NAT = 0,
COL = 1,
PET = 2,
DRI = 3,
SMO = 4
} cols_type;