Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Frank Behrens fbehrens

🎯
Focusing
  • https://github.com/Bayer-Group
  • Cologne - Germany
  • @bluse1995
View GitHub Profile
View read musicmatch library.ps1
filter Decode { [System.Net.WebUtility]::UrlDecode($_) }
filter Get-Songs{
$xml = New-Object XML.XmlDocument
$xml.LoadXml((Get-Content $_))
$disk = $xml.BPP.disc
$outFile = $_.name -replace "\.bpp$",".mp3"
$(0..($disk.path.Length -1) | % {
"$($disk.path[$_].src | Decode)$($disk.file[$_].src | Decode)"
} )> $outFile
@fbehrens
fbehrens / HashFromCsv.ps1
Created Feb 26, 2020
PSReadline Handler
View HashFromCsv.ps1
Set-PSReadLineKeyHandler -Chord F2 -BriefDescription HashFromCsv -LongDescription "converts a comma separated String int a Hashtable" -ScriptBlock { param($key, $arg)
$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
$g = [Regex]::matches($line,"\S+") | ? { $_.index -le $cursor -and $_.index + $_.Length -ge $cursor }
if (!$g){ return }
$s = $g.value -replace ",",'="";'
$s = "@{$s=`"`"}"
$pos = $s.IndexOf('""')
[Microsoft.PowerShell.PSConsoleReadLine]::Replace($g.Index,$g.Length,$s)
@fbehrens
fbehrens / csv.fs
Created Nov 11, 2015
Hourly filtering
View csv.fs
module wba.csv
open FSharp.Data
open System
type Stocks = CsvProvider<"ES.csv", Schema = "Date(string),Time(string),Open,High,Low,Close,Volume">
let getTime (row:Stocks.Row) =
let iC = Globalization.CultureInfo.InvariantCulture
let s = row.Date + " " + row.Time
DateTime.ParseExact(s, "MM/dd/yyyy HHmm",iC)
View couch_gist
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y git help2man make gcc zlib1g-dev libssl-dev rake texinfo flex dctrl-tools libsctp-dev libxslt1-dev libcap2-bin ed
RUN cd opt && git clone git://github.com/iriscouch/build-couchdb
RUN cd opt/build-couchdb && git submodule init && git submodule update && rake
@fbehrens
fbehrens / gist:2056193
Created Mar 17, 2012
Using multiple databases in Active Record
View gist:2056193
equire 'oci8'
require 'activerecord-oracle_enhanced-adapter'
require 'active_record'
class Db1 < ActiveRecord::Base
self.abstract_class = true
establish_connection YAML.load_file('config/database.yml')['db1']
end
class Db2 < ActiveRecord::Base
@fbehrens
fbehrens / gist:2021798
Created Mar 12, 2012
build couchdb RHE5.5
View gist:2021798
configure:3959: checking for autoconf
configure:4008: checking for makedepend
configure:4056: checking for xargs
configure:4429: checking for gmake
configure:4492: checking for X
configure:5748: checking whether the compiler supports -Wno-invalid-offsetof
configure:5771: c++ -c -fno-strict-aliasing -Wno-invalid-offsetof conftest.C 1>&5
configure:5798: checking whether the compiler supports -Wno-variadic-macros
configure:5821: c++ -c -fno-strict-aliasing -Wno-variadic-macros conftest.C 1>&5
configure:5848: checking whether the compiler supports -Werror=return-type
View gem server gem_base
fb@by06oh:~$ ll gem_base/
total 48
drwxr-xr-x 4 fb fb 4096 2011-04-06 12:15 ./
drwxr-xr-x 55 fb fb 4096 2011-04-17 20:33 ../
drwxr-xr-x 2 fb fb 4096 2011-04-06 12:14 gems/
-rw-r--r-- 1 fb fb 62 2011-04-06 12:15 latest_specs.4.8
-rw-r--r-- 1 fb fb 80 2011-04-06 12:15 latest_specs.4.8.gz
-rw-r--r-- 1 fb fb 816 2011-04-06 12:15 Marshal.4.8
-rw-r--r-- 1 fb fb 508 2011-04-06 12:15 Marshal.4.8.Z
-rw-r--r-- 1 fb fb 4 2011-04-06 12:15 prerelease_specs.4.8
@fbehrens
fbehrens / monitor.rb
Created Feb 20, 2011
litte script which monitors my internetconnection
View monitor.rb
#!/usr/bin/ruby -w
# this is an example of uncommunicative code
# would be a good example for refactoring to make clear what it does
class Monitor
@@host = "heise.de"
@@tries = 4
@@results_per_line = 60
@@log = __FILE__.gsub(/rb$/,"log")
@fbehrens
fbehrens / remove_dublicates.rb
Created Jan 12, 2011
iterates over files and delete dublicates
View remove_dublicates.rb
require 'digest/md5'
require 'fileutils'
hash = {}
["/Users/frankbehrens/Desktop/niels\ backup/Pictures/iPhoto\ Library/Originals/**/*.*","**/*.*"].each do |dir|
Dir.glob(dir).each do |file|
print '.'
digest = Digest::MD5.hexdigest(File.read(file))
if hash[digest]
puts "#{file}is dublicate"
FileUtils.rm file
You can’t perform that action at this time.