Skip to content

Instantly share code, notes, and snippets.

@Minoru
Minoru / task1.c
Created October 27, 2010 23:19
C implementation of simple shell script
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // sleep()
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int make_redirection(int stream, const char* file) {
@Minoru
Minoru / routines.h
Created October 29, 2010 22:57
VERY simple Haskell shell to C translator
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int exec_command(const char**);
@Minoru
Minoru / task2.hs
Created November 3, 2010 20:32
Shell to C translator (using new intermediate represantation)
import IR
type C = String
genC x = helper "" "" 0 x
where helper :: C -> C -> Int -> Statement -> C
helper defs code n (Sequence (x:[])) = helper (defs ++ genDefs n True x) (code ++ genCode n True x) (n + countDefs x) (Sequence [])
helper defs code n (Sequence (x:xs)) = helper (defs ++ genDefs n False x) (code ++ genCode n False x) (n + countDefs x) (Sequence xs)
helper defs code n (Sequence _ ) = "#include \"routines.h\"\nint main(){" ++ defs ++ code ++ "}"
@Minoru
Minoru / andOrList.c
Created September 11, 2011 17:27
Sample implementation of shell AND-OR list in C89
#include <stdlib.h>
#include <string.h>
#include "routines.h"
int main(int argc, const char *argv[]) {
int status,
status0,
status1;
char **argv0,
**argv1,
@Minoru
Minoru / gist:5185160
Created March 18, 2013 04:49
Bash (sorry!) script that implements idea from here: https://bnw.im/p/QBRE4F In short: it plays an audio file, pausing periodically to check if user is asleep already. If user doesn't respond (by making some noise), the script remembers current position in the file and quits. Next time script is run on the same file, playback is resumed from the…
#!/bin/bash
# I hereby place this script into public domain.
# database is CSV file containing position (in seconds) and filename, separated by a comma
db="$HOME/.mama.db"
# timeout is number of seconds to wait between checks if user is asleep
# default is 10 minutes
timeout="600"
I had a dream. Like there is ahead
An endless, empty and the wildest plane,
And I stand there, held by iron chain,
Under the tall rock made from finest stone,
And next to me are thousands just like me.
The face of each is marked by life and sorrow,
Love's favour burn in each and every eye,
And hands of everyone are chained with snakes of iron,
And every shoulder's bent low to the ground,
@Minoru
Minoru / palmrest_ergonomics.markdown
Created December 10, 2013 06:28
Results of my little Internet research conducted to answer the following question: can I rest my wrists/palms on the wrist/palm rest while typing/using a mouse?

The question: Can I rest my wrists/palms on the wrist/palm rest while typing/using a mouse?

Key

Marks before the source URL indicates the main tone of the source in regard of wrist/palm rests:

[xy]
 ^^
@Minoru
Minoru / command
Created January 26, 2014 19:12
Solution to Mayoi Hachikuji's problem of matching something like "wtf (.+) going (.+) (.+)" in a way so that \1 ≠ \2 ≠ \3
echo 'wtf is going is is\nwtf is going is on\nwtf is going is guys\nwtf is going on is\nwtf is going on on\nwtf is going on guys\nwtf is going guys is\nwtf is going guys on\nwtf is going guys guys\nwtf on going is is\nwtf on going is on\nwtf on going is guys\nwtf on going on is\nwtf on going on on\nwtf on going on guys\nwtf on going guys is\nwtf on going guys on\nwtf on going guys guys\nwtf guys going is is\nwtf guys going is on\nwtf guys going is guys\nwtf guys going on is\nwtf guys going on on\nwtf guys going on guys\nwtf guys going guys is\nwtf guys going guys on\nwtf guys going guys guys' | \
perl -ne '$i++; if ( $_ =~ /^wtf (\w+) going (?!.*\1.*)(\w+) (?!.*\2.*)(\w+)$/ ) { print $i, ": ", $1, "--", $2, "--", $3, "\n"; }'
@Minoru
Minoru / start.txt
Last active August 29, 2015 14:04
Предлагаемые правки для главной nethack-rutext
{{ :nh4tx.gif?nolink&300 |}}
<WRAP center round info 60%>
* [[wpru>Jabber]]-конференция: **nethack@conference.jabber.ru**
* Группа ВКонтакте: [[http://vk.com/club10804897]]
* Старая версия сайта находится по адресу: [[http://nethack.ucoz.com/|nethack.ucoz.com]]
</WRAP>
**[[http://ru.wikipedia.org/wiki/NetHack|NetHack]]** — компьютерная ролевая игра. Она представляет собой очень сложный, динамический и непредсказуемый мир подземелий, в котором игрок сражается с различными существами, торгует, развивается и продвигается всё ниже по уровням ради того, чтобы завладеть [[nw>Amulet_of_Yendor|Амулетом Йендора]].
@Minoru
Minoru / test.html
Created April 10, 2016 18:50
Trying to shrink an image to container's height
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<link rel="stylesheet" href="http://loglist.net/stylesheets/reset.css">
<style type="text/css" media="screen">
.plate {
background: #aaaaaa;
}