Skip to content

Instantly share code, notes, and snippets.

View izabera's full-sized avatar

Isabella Bosia izabera

  • General System
  • Flitwick, UK
View GitHub Profile
@deepcube
deepcube / bsolve
Last active August 29, 2015 14:20
#!/usr/bin/env bash
# solve Rubik's cube using the Tperm blindfold method. input: http://tomas.rokicki.com/cubecontest/
# idea from Stefan Pochmann's second entry: http://tomas.rokicki.com/cubecontest/winners.html
n=0 tperm="R2 U' R2 D B2 L2 U L2 D' B2 U "
cube=("$@") solved=(UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR)
declare -A inverse=([\']=\ [2]=2 [\ ]=\') setups=(
[UF]="R2 U R2 " [UR]="" [UB]="R2 U' R2 " [UL]=""
[DF]="D' L2 " [DR]="D2 L2 " [DB]="D L2 " [DL]="L2 "
[FR]="U2 R U2 " [FL]="L' " [BR]="U2 R' U2 " [BL]="L "
[FU]="R F' L' R' " [RU]="" [BU]="R' B L R " [LU]="L F' D' F L2 "
#!/bin/bash
save=$(bind -p; bind -X)
function clean-up {
bind -r '\C-i'
bind -f /dev/stdin <<< "$save"
}
trap 'clean-up' RETURN
function write-options {
@vivithemage
vivithemage / libmagic_example.c
Last active October 18, 2022 21:24
libmagic.h example
#include <stdio.h>
#include <magic.h>
int main(void)
{
char *actual_file = "/file/you/want.yay";
const char *magic_full;
magic_t magic_cookie;
/* MAGIC_MIME tells magic to return a mime of the file,
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active March 22, 2023 03:06
Discussion of korn.c, 1987 IOCCC entry, mentioned in http://stackoverflow.com/a/19214007/827263

korn.c is the "Best One Liner" winner of the 1987 International Obfuscated C Code Contest, by David Korn (yes, the author of the Korn Shell).

korn.hint, as the name implies, offers some hints.

A commenter on Stack Overflow asked for some clarification. I didn't want to post spoilers on the site, so I'm posting them here instead. If you haven't already (and if you're familiar with the rules of C) I encourage you to study the program for a while first.

=====

Here's the code: