Skip to content

Instantly share code, notes, and snippets.

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
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)}
#!/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;
class X {
int x[3];
public:
X() : x{0, 1, 3} {}
};
int main() {
X x;
}
# Site settings
title: seitz - a blog or something
email: [email protected]
description: > # this means to ignore newlines until "baseurl:"
This site exists as a resource for me to dump all the little thoughts
that come to me concerning programming. I am interested in Rust and
functional programming languages.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://seitz.space" # the base hostname & protocol for your site
twitter_username: ds3itz
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
gem 'rake'
gem 'rouge'
gem 'html-proofer'
defmodule Swapper do
def swap([]), do: []
def swap([a,b | tail]), do: [b, a | swap(tail)]
def swap([_]), do: raise "Can't swap a list with an odd number of elements"
end
defmodule Countdown do
def sleep(seconds) do
receive do
after seconds*1000 -> nil
end
end
def say(text) do
spawn fn -> :os.cmd('say #{text}') end
end
defmodule Eval do
def calculate(str), do: _calculate(str)
defp _calculate(str) do
{op, i} = find(str)
list1 = Enum.slice(str, 0..i-1)
list2 = Enum.slice(str, i+2..length(str))
_calculate(op, list1, list2)
end
defp _calculate(?+, list1, list2), do: number(list1) + number(list2)
defmodule Parse do
def calculate(expression) do
{ left, rest } = Enum.split_while(expression, &(!(&1 in '+-*/')))
[ op | right ] = rest
{ result, _ } = Code.eval_quoted { :erlang.list_to_atom([op]), [],
[value(left), value(right)] }
result
end
defp value(digits) do