Skip to content

Instantly share code, notes, and snippets.

View tallakt's full-sized avatar

Tallak Tveide tallakt

View GitHub Profile
@tallakt
tallakt / conways_game_of_life.exs
Last active August 29, 2015 14:08
Conways Game of Life in Elixir
#!/usr/bin/env elixir
# https://elixirquiz.github.io/2014-11-01-game-of-life.html
defmodule Conway do
defstruct lookup: HashDict.new, rows: 0, cols: 0
def run_file(filename) do
case load_file(filename) do
{:ok, initial_state} ->
#!/bin/sh
/bin/curl -k -F apikey=xxxxxxx -F application=Transmission -F event="Download Complete" -F description="$TR_TORRENT_NAME completed on $TR_TIME_LOCALTIME" https://api.prowlapp.com/publicapi/add
#!/usr/bin/env ruby
require 'win32ole'
e=WIN32OLE::connect "Excel.Application"
e.Sheets.Count.times do |n|
sheet = e.Sheets(n + 1)
v = sheet.UsedRange.Value2
puts "=== Sheet: #{sheet.Name}"
v.each do |row|
puts row.map {|x| x || ""}.join "\t"
end
@tallakt
tallakt / hash_from_block.rb
Last active December 26, 2015 04:49
Ruby Hash from block
class Hash
class << self
def from_block()
Hash[Enumerator.new {|yielder| yield yielder }.to_a]
end
end
end
Hash::from_block do |yielder|
$excel.Range('A4').Value = 'Remote Set'
@tallakt
tallakt / s7unprotect.pl
Created October 16, 2012 13:29
Step 7 unprotect blocks
#!/usr/bin/env perl -w
# To run on linux, install the following packages:
# sudo apt-get install libdbd-xbase-perl
# sudo apt-get install libdbi-perl
#
# To run without downloading and creating the perl file, type:
# cd /path/to/step7/project
# curl -s -L https://raw.github.com/gist/3899286/s7unprotect.pl | perl
#
@tallakt
tallakt / nodave.rb
Created September 14, 2012 11:56
Nodave FFI integration test
require 'ffi'
require 'socket'
require_relative 'nodave_constants'
module Nodave
include NodaveConstants
extend FFI::Library
ffi_lib 'libnodave'
@tallakt
tallakt / table_hash.rb
Created September 14, 2012 09:45
Concept for Hash from table generator
class TableHash
# creates a Hash from a table structure
#
# TableHash[
# 4,
# :key, :a, :b, :c,
# 'first', 10, 11, 12,
# 'second', 20, 30, 40
# ]
#
@tallakt
tallakt / gist:3052461
Created July 5, 2012 08:58
Cygwin install
# http://code.google.com/p/apt-cyg/
apt-cyg show
The following packages are installed:
_autorebase
_update-info-dir
alternatives
autoconf
autoconf2.1
autoconf2.5
@tallakt
tallakt / .gitconfig
Last active September 30, 2015 16:18
cygwin config files
[user]
name = Tallak Tveide
email = [email protected]
[core]
editor = /usr/bin/vim
excludesfile = /cygdrive/c/Users/tveidet/.gitignore_global
autocrlf = false
[diff "excel"]
textconv = strings
[diff "word"]