Skip to content

Instantly share code, notes, and snippets.

@markembling
markembling / hosts.ps1
Created August 24, 2009 13:38
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
@Ciantic
Ciantic / keyboardlistener.cs
Created July 11, 2010 17:33
C# Keyboard listener
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
{
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@mkitt
mkitt / notes.md
Created February 13, 2011 03:24
AppleScript for use with Automator which allows opening files within Terminal Vim

What It Does

This AppleScript used in conjunction with Automator will allow you to set preferences for opening files via mouse click in the Terminal version of Vim. It will also allow you to fire up the Terminal version of Vim through Spotlight within the home directory.

Installation Notes

  • Fire up Automator
  • Choose "Application" from the workflow templates
  • Under the "Actions" panel select "Utilities"
  • To the right of "Utilities" drag an instance of "Run AppleScript" to the editor window
@hashmal
hashmal / gist:874792
Created March 17, 2011 17:54
[Lua] Print table contents recursively
-- Print contents of `tbl`, with indentation.
-- `indent` sets the initial level of indentation.
function tprint (tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
else
@emiliano-poggi
emiliano-poggi / foreach.ps1
Created April 4, 2011 20:58
POSH: For each constructs
# foreach statement
foreach ($ps1 in ls -filter $home\*.ps1) {$ps1.length/1024}
# foreach inside the pipeline
ls -filter $home\*.ps1 | ForEach-Object -process {$_.length/1024}
# foreach inside the pipeline omitting -process
ls -filter $home\*.ps1 | ForEach-Object {$_.length/1024}
# foreach inside the pipeline using foreach alias
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@eligrey
eligrey / html-domparser.js
Last active April 11, 2024 10:34
DOMParser HTML extension - Now a polyfill since HTML parsing was added to the DOMParser specification
/*
* DOMParser HTML extension
* 2019-11-13
*
* By Eli Grey, http://eligrey.com
* Public domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
/*! @source https://gist.github.com/1129031 */
@paulredmond
paulredmond / Custom.css
Created August 17, 2011 17:11
Espresso syntax theme for Google Chrome Inspector
/**********************************************/
/*
/* Espresso-inspired theme for Google Chrome Inspector
/*
/* By: Paul Redmond http://github.com/paulredmond
/*
/* Inspired by Darcy Clarke's post - http://darcyclarke.me/design/skin-your-chrome-inspector/
/* Darcy Clarke's "Darker Skin" theme - http://darcyclarke.me/dev/inspectorskin/Custom.css
/*
/**********************************************/
@Grayson
Grayson / isOptionKeyPressed.scpt
Created August 18, 2011 14:03
Applescript snippet to test if Option key is held down.
on isOptionKeyPressed()
return (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlternateKeyMask > 1'") is "True"
end isOptionKeyPressed