Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
# Written by Claudio Ramirez <[email protected]>
# A small wrapper around Solaris ifconfig to get rid of the awful
# hexadecimal netmask (ffffff00 => 255.255.255.0)
#
# Modified to address change in filesystem
use strict;
use warnings;
import Cocoa
extension String {
func scan(regex: String) -> [String] {
let regex = NSRegularExpression(pattern: regex,
options: nil, error: nil)!
let nsString = self as NSString
let results = regex.matchesInString(self, options: NSMatchingOptions(0), range: NSMakeRange(0, (self as NSString).length))
as! [NSTextCheckingResult]
return map(results) { nsString.substringWithRange($0.range)}
tell application "Safari"
activate
open location "http://www.google.com"
delay 3
set theScript to "document.getElementById('lst-ib').value = 'hello world'"
do JavaScript theScript in current tab of first window
end tell
@s3itz
s3itz / base.html
Last active August 29, 2015 14:15 — forked from rtuita23/traceback
Error with macros
{% from "macros.html" import nav_link with context %}
<!DOCTYPE html>
<html>
<head>
<title>Flask Template Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
div#main {
max-width: 500px;
padding: 20px;
import sys
n = None
try:
n = int(sys.argv[1])
except (ValueError, IndexError) as e:
pass # Ignore error here
if (len(sys.argv) == 1) or (n is None):
rm -rf ~/Library/Preferences/com.apple.appstore.plist
rm -rf ~/Library/Preferences/com.apple.storeagent.plist
rm -rf ~/Library/Preferences/ByHost/*
App = Application.currentApplication();
App.includeStandardAdditions = true
App.say("Hello from Dan's JavaScript automation!!!");
extension NSFileManager {
func fileExists(path: String) -> (Bool, isDirectory: Bool) {
var dir: ObjCBool = true
let status = self.fileExistsAtPath(path, isDirectory: &dir)
return (status, dir.boolValue)
}
}
NSFileManager.defaultManager().fileExists("/Applications").isDirectory
type file;
app (file o) simulate_app ()
{
simulate stdout=filename(o);
}
foreach i in [1:10] {
string fname=strcat("output/sim_", i, ".out");
file f <single_file_mapper; file=fname>;
(define (square x)
(* x x))