Skip to content

Instantly share code, notes, and snippets.

View mrdaemon's full-sized avatar

Alexandre Gauthier mrdaemon

View GitHub Profile
@mrdaemon
mrdaemon / copysfc.sh
Created December 15, 2010 22:46
Copy corrupt/missing files from windows sfc log from known good windows 7 install mounted at /media/wsystem. Thank you sfc for creating logs that are impossible to parse without sed grep and awk magic.
grep -i -e "could not" -e "cannot" sfclog.txt | \
awk -F ';' '{ print $1; }' | awk -F "??" '{ print $3; }' | \
sed -e 's/^\\//' -e 's/"\\\[.*\]"/\\/g' -e 's/"$//' | sort | uniq | \
tee -a ./win7sysfiles/FILELIST.TXT | \
sed -e '/^$/d' -e 's/\\/\//g' -e 's/^C:\(.*\)$/\/media\/wsystem\1/' \
-e 's/\([ ()]\)/\\\1/g' | \
while read i ; do if [ -f "$i" ] ; then STATUS="ERROR" ; \
cp "$i" ./win7sysfiles/ && STATUS="COPIED" ; else STATUS="MISSING" ; fi ; \
printf "%-30s%-30s\n" "`basename \"$i\"`" "[$STATUS]" ; done \
&& echo -n "Creating checkums..." ; for f in ./win7sysfiles/* ; do \
@mrdaemon
mrdaemon / hyperv-r2-configonly-import.ps1
Created December 29, 2010 19:36
Work in progress. cmdlet to import a config-only VM export on Hyper-V 2008 R2.
<#
.SYNOPSIS
Safely Imports Hyper-V Virtual Machines that were exported
as configuration only, without State Data (snapshots, VHDs, etc).
.DESCRIPTION
Hyper-V 2008 R2 removed the option to export a Virtual Machine without
its State Data (Snapshots, Virtual Disk Images (VHDs), Suspend State),
as configuration only through the GUI.
@mrdaemon
mrdaemon / .logo.rc.sh
Created December 30, 2010 05:52
This is the script exec'ed by my .bashrc that displays a crappy ascii 'picture' and text centered on screen as a banner. It was annoying to write, is completely useless and full of bashisms, but is interesting nonetheless.
#!/bin/bash
#
# rc.logo - Crappy welcome mat for unix shells
# 2010-2011 Alexandre Gauthier <alex@lab.underwares.org>
#
# Displays usless ascii logo, information and random niceties
# on login.
#
#####################################################################
public class HelloWorld : Object {
public string name { get ; set; default = "World"; }
public HelloWorld() {
/* Huh. With properties accessed like fields,
and able to have default values, turns out I don't
actually have to do this. At all. Sweet shorthand,
Vala. Your syntactic sugar is growing on me. */
//this.with_name("World");
}
/* hello.c generated by valac 0.11.1, the Vala compiler
* generated from hello.vala, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* -
* TP No. 1
* "Doing Melissa's programming homework out of boredom"
* (c) 2010-2011
* Alexandre Gauthier <alex@underwares.org>
*
* Specifications:
*
* Read 10 numbers from the user and store them in an array
* of 10 elements.
@mrdaemon
mrdaemon / cygwinapi_check.py
Created January 13, 2011 08:58
Work in progress. Functional programming is making me mad. Mad I say.
from contextlib import closing
#from collections import defaultdict
import re
import shelve
from urllib2 import Request, urlopen, URLError
from BeautifulSoup import BeautifulSoup
apiurls = { 'std-unix': 'http://cygwin.com/cygwin-api/compatibility.html',
@mrdaemon
mrdaemon / DesignModule.inc.php
Created January 23, 2011 09:54
The KnifaCode (tm)
<?php
/**
* Design Module.
*
* @package Module
* @subpackage Design
*/
/**
* Include System stuff.
@mrdaemon
mrdaemon / env_universaldate.cmd
Created January 30, 2011 18:31
Shit example to parse the output of date
@echo off
:: $Id: env_universaldate.cmd 1986 2006-12-06 20:36:59Z gauthiera $
:: Librarie pour generation de date Universelle
::
:: ATTENTION: La date et le nom des variables
:: sont differents selon la langue du systeme
:: d'exploitation:
:: Francais: %jj% %mm% %aa%
:: Anglais: %mm% %dd% %yy%
::
@mrdaemon
mrdaemon / Phones.muf
Created February 17, 2011 05:34
OH GOD MULTI USER FORTH WAS HORRIBLE I DON'T MISS IT ONE BIT
(** BuyPhone.muf [c] Nilesta, 2000 http://members.home.net/tiadasia/ **)
$def PPROG #277 (** DBREF of Phones.muf **)
(** The following are for costs. If you don't want costs, set them all **)
(** to 0. Per-month cost is added up and stored on the phone object **)
(** under '@phone/upkeep' **)
(** This /does not/ actually charge them the per-month costs. You'll **)
(** need to program something to do that if you want it done. **)