Skip to content

Instantly share code, notes, and snippets.

View tallakt's full-sized avatar

Tallak Tveide tallakt

View GitHub Profile
require 'win32ole'
opc_automation = WIN32OLE::new 'OPC.Automation'
# get list of servers
opc_automation.GetOPCServers
# Connect to specific server
opc_automation.connect 'Matrikon.OPC.Simulation.1'
#old style
a={}
a[:test] = {}
a[:test][:second_test] = 'Hello hash!'
# new style
# emulates working with directories
b = {}
b/:test = {}
b/:test/:second_test = 'Hello hash!'
@tallakt
tallakt / .vimrc
Last active December 1, 2017 23:29
VIM setup
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'altercation/vim-colors-solarized'
Plug 'elixir-lang/vim-elixir'
@tallakt
tallakt / .gitconfig
Last active September 30, 2015 16:18
cygwin config files
[user]
name = Tallak Tveide
email = tallak.tveide@nov.com
[core]
editor = /usr/bin/vim
excludesfile = /cygdrive/c/Users/tveidet/.gitignore_global
autocrlf = false
[diff "excel"]
textconv = strings
[diff "word"]
@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 / 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 / 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 / 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
#
$excel.Range('A4').Value = 'Remote Set'
@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|