Skip to content

Instantly share code, notes, and snippets.

@vivkin
vivkin / 16-color-table.sh
Created May 26, 2017 07:11
Terminal color test scripts
#!/bin/bash
#
# This file echoes a bunch of color codes to the terminal to demonstrate
# what's available. Each line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a test use of that color
# on all nine background colors (default + 8 escapes).
#
T='gYw' # The test text
echo -e "\n 40m 41m 42m 43m 44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m';
logic.script "API_LoadNavigationData('Resources/missions/LV_Karhad_PvE_Caravanserai_Navigation.json')"
logic.script "for i = 0, 30 do API_SpawnBot({x=1,y=1,z=1},0,'TaurusRPG',-1) end"
// generated by quake, do not modify
unbindall
bind TAB "+scores"
bind ENTER "+button2"
bind ESCAPE "togglemenu"
bind SPACE "+moveup"
bind + "sizeup"
bind - "sizedown"
bind / "weapnext"
bind 0 "weapon 10"
@vivkin
vivkin / colors.h
Created September 4, 2017 09:57
Color schemes and palette for use in C
#pragma once
// https://yeun.github.io/open-color/
enum oc_names {
oc_gray,
oc_red,
oc_pink,
oc_grape,
oc_violet,
@vivkin
vivkin / Makefile
Last active June 4, 2017 15:31
Small LZ77 compressor. Uses variable length integers from xz for coding length\offset
CC ?= cc
CFLAGS ?= -Wall -Wextra -std=c11 -O3
BINDIR = bin
OUTNAME = lz
SOURCES = lz.c
OBJECTS = $(SOURCES:%.c=$(BINDIR)/%.o)
export V := false
export CMD_PREFIX := @
@vivkin
vivkin / showaddrinfo.c
Created May 23, 2017 23:38
show getaddrinfo(3) results
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char **argv) {
@vivkin
vivkin / myfire.py
Created March 11, 2017 18:05
google/python-fire in 30 seconds
from __future__ import print_function
import sys
class Calculator(object):
"""A simple calculator class."""
def double(self, number):
return 2 * number
if __name__ == '__main__':
int d = 42;
int o = 052;
int foo = 2321312;
int x = 0xdead'beef;
int X = 0Xc0'0f'fe;
int y = 0XBAD'cab1e;
int Y = 0Xc0'0f'fe;
int b = 0b101010; // C++14
unsigned long long l1 = 18446744073709550592ull; // C++11
unsigned long long l2 = 18'446'744'073'709'550'592llu; // C++14
@vivkin
vivkin / unsplashy
Created July 7, 2016 08:51
unsplashy. download daily featured pictures from unsplash.com
#!/bin/sh
CATEGORIES="buildings food nature people technology objects"
DESTDIR=~/Pictures/unsplash
RESOLUTION=$(system_profiler SPDisplaysDataType | grep Resolution | sed 's/[^x0-9]//g')
for CATEGORY in ${CATEGORIES}; do
URL=https://source.unsplash.com/category/${CATEGORY}/${RESOLUTION}/daily
IMAGE=$(curl --silent --fail --location --write-out "%{url_effective}" --output /dev/null --url ${URL})
NAME=${IMAGE##*/}
@vivkin
vivkin / mouse-click.c
Created January 27, 2014 21:56
auto OS X mouse click with delay
// clang mouse-click.c -o mouse-click -framework ApplicationServices
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc != 3)
{
fprintf(stderr, "usage: %s [seconds to wait] [number of clicks]\n", argv[0]);