This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X { | |
int x[3]; | |
public: | |
X() : x{0, 1, 3} {} | |
}; | |
int main() { | |
X x; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |