Skip to content

Instantly share code, notes, and snippets.

@alksl
alksl / zfs_backup.sh
Created February 12, 2013 18:49
ZFS backup
#!/bin/sh
BACKUP_ROOT=/mnt/backup
now=$(date +%s)
readable=$(date -d $now +%F)
backup_name="${readable}-${now}"
mount /mnt/backup
%{
#include <stdio.h>
%}
%option noyywrap
IDENTIFIER [a-zA-ZS+=][a-zA-Z0-9+=]*
DIGIT [0-9]
LPAREN \(
RPAREN \)
@alksl
alksl / values_at.rb
Created November 20, 2013 22:50
Path for values_at to include block predicate
class Array
def values_at(*args)
arr = []
each_index do |i|
if args_include_index?(args, i) or (block_given? and yield(i))
arr << self[i]
end
end
arr
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char* argv[])
{
char c;
int fd;
FILE* file;
-
- setSubClasses
-
'Virtual Machine': 'FOI\Crate\CommonBundle\Entity\VirtualMachine'
'Honeypot Machine': 'FOI\Crate\CommonBundle\Entity\VirtualHoneypot'
'Physical Machine': 'FOI\Crate\CommonBundle\Entity\PhysicalMachine'
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <gtest/gtest.h>
#include <scanner.h>
extern FILE* yyin;
#ifndef KOMP_STRING_H
#define KOMP_STRING_H
#include <iostream.h>
//
// Note that the implementation of this class is rather inefficient.
// When operating on strings and character pointers, this
// implementation will create a lot of temporary objects. By
std::ostream& ShortSymbols(std::ostream& o)
{
SymbolInformation::outputFormat = SymbolInformation::kShortFormat;
return o;
}
std::ostream& LongSymbols(std::ostream& o)
{
SymbolInformation::outputFormat = SymbolInformation::kFullFormat;
return o;
#ifndef _SCHEMESE_SCANNER_H_
#define _SCHEMESE_SCANNER_H_
#include <iostream>
#include <vector>
#include <string>
namespace Schemese {
/*
@alksl
alksl / dolist.ss
Last active August 29, 2015 13:56
(define (eval-dolist exp env)
(let ((lst (eval (dolist-listexpr exp env))) ; evaluate the list
(startval (eval (dolist-resultvar exp env)))) ;evaluate the resultvar
(define (dolist-iteration lst result)
(if (null? lst)
result
(dolist-iteration
(rest lst)
(apply-%scheme
(eval-%scheme (make-lambda (list (dolist-variable exp) lst (dolist-resultvar exp))