Skip to content

Instantly share code, notes, and snippets.

View mniip's full-sized avatar
😼

mniip mniip

😼
View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <sys/auxv.h>
char const *default_path = "/bin/sh";
char const *const default_argv[] = {"/bin/sh", "-", NULL};
char const *const default_envp[] = {NULL};
@mniip
mniip / logger.c
Last active December 15, 2015 19:03
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <string.h>
char *channel_path;
char *channel_name;
int raw;
int hosts;
#!/var/www/core/lci
local page = env.REQUEST_URI
if page then
page = page:gsub("^/pages", ""):gsub("^/", "")
else
page = ""
end
page = page:gsub("[^a-zA-Z0-9_/-]", "")
local title
local content = tag"div"()
IN=in.c
LINKER=in.T
OUT=out
all:
gcc -Os -fPIC -o $(OUT) $(IN) -ggdb -nostdlib -T $(LINKER) -fno-asynchronous-unwind-tables -Wl,-z,max-page-size=4096
strip $(OUT)
strip -R .comment $(OUT)
@mniip
mniip / 2048.sh
Created March 25, 2015 02:33
A 2048 clone for those who can't afford a desktop environment. Runs in sh!
#!/bin/sh
print_cell()
{
if [ "$1" = 0 ]; then
echo -en " "
else
if [ "$1" -ge 128 ]; then
echo -en '\x1B[33m'
elif [ "$1" -ge 16 ]; then
echo -en '\x1B[31m'
data Combinator = Id | Join | Const | Flip | Lift Combinator | Compose [Combinator] deriving (Eq,Show)
reorder src dst = reCompose $ optimize $ deCompose $ trans src dst
where
trans src [] = nullify src
trans src dst = Compose [trans src $ init dst, findAndMove src $ last dst]
nullify [] = Id
nullify (_:xs) = Compose [Const, nullify xs]
findAndMove [] c = error "Not found"
findAndMove (x:xs) c
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define error(...) (printf(__VA_ARGS__), exit(EXIT_FAILURE))
struct node_s
{
int type;
@mniip
mniip / Lambda.hs
Last active August 29, 2015 14:13
Alpha-less lambda calculus in Haskell.
module Lambda (
Lambda(..),
($$),
lambda,
lambdaEnv,
annotate,
fromInt,
toInt,
fromBool,
toBool,
@mniip
mniip / isbanned.pl
Last active August 29, 2015 14:13
A freenode-specific irssi script that checks whether someone is banned on some channel. For hexchat version see https://gist.github.com/mniip/441aacc9f7f571b8ea25
use Irssi;
use strict;
use bignum;
use Socket;
use vars qw($VERSION %IRSSI);
%IRSSI =
(
name => "isbanned",
description => "freenode-specific module that checks whether someone is banned on some channel",
@mniip
mniip / files-ng.lua
Last active August 29, 2015 14:12
TPT file-to-particle converter
local MEDIUM_TYPE = elem.DEFAULT_PT_BRAY
local BLOCK_LENGTH = 19
local SECTOR_LENGTH = 604
local SECTOR_OFFSET = 5
local BLOCK_OFFSET = 4
local SIGNATURE_X = 4
local SIGNATURE_Y = 4
local SIGNATURE_MAGIC = 0xBEEFD1ED