This file contains 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
tokens = [/^:61/, /^:62F:/] | |
mt940 = <<MT940 | |
:20:951110 | |
:25:45050050/76198810 | |
:28:27/01 | |
:60F:C951016DEM84349,74 | |
:61:951017D6800,NCHK16703074 | |
:86:999PN5477SCHECK-NR. 0000016703074 | |
:61:951017D620,3NSTON |
This file contains 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/env ruby | |
# encoding: utf-8 | |
require 'yaml' | |
require 'active_support/hash_with_indifferent_access' | |
class Hash | |
def self.new_from_hash_copying_default(hash) | |
hash = hash.to_hash | |
new(hash).tap do |new_hash| |
This file contains 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
#define file extensions that should be regarded | |
EXT=(css ejs erb gemspec gitignore html js json md mustache rake rb rdoc rspec ru scss sh sql txt ui xml xsd yardopts yml) | |
EXT=$(printf "\|%s" "${EXT[@]}") | |
EXT=${EXT:2} | |
# git: | |
git ls-files "*.*" | grep "\.\($EXT\)$" | sed "s/^/\'/; s/$/\'/;" | xargs sed -i -e '$a\' | |
This file contains 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
# plain | |
find . -name '*.*' | sed 's/.*\.//' | sort -u | tr "\n" " " | |
# git | |
git ls-files "*.*" | sed 's/.*\.//' | sort -u | tr "\n" " " | |
# Explained | |
# find . -name '*.*' # List all files containing a '.' | |
# git ls-files "*.*" # List all tracked files containing a '.' |
This file contains 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
module Foo | |
include ActiveSupport::Configurable | |
class << self | |
def configure | |
yield config | |
end | |
end | |
end | |
Foo.configure do |config| |
This file contains 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
# cat, print file.bin's binary content | |
cat file.bin | |
# => | |
# DUMP - convert binary content to hex string | |
xxd -p file.bin | tr -d '\n' | |
# => 48656c6c6f20576f726c640a | |
# RESTORE - convert hex string to binary content | |
echo 48656c6c6f20576f726c640a | xxd -r -p |
This file contains 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
# DUMP | |
mkdir -p ~/backup | |
dpkg --get-selections > ~/backup/Package.list | |
sudo cp -R /etc/apt/sources.list* ~/backup/ | |
sudo apt-key exportall > ~/backup/Repo.keys | |
# RESTORE | |
sudo apt-key add ~/backup/Repo.keys | |
sudo cp -R ~/backup/sources.list* /etc/apt/ | |
sudo apt-get update |
This file contains 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
params = Hash[[*'a'..'j'].zip([*1..10])] # => {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5, "f"=>6, "g"=>7, "h"=>8, "i"=>9, "j"=>10} | |
slice_keys = ['a','f','g'] | |
filter = -> (key, _) { slice_keys.include?(key) } | |
slice = params.select &filter | |
params.delete_if &filter | |
slice # => {"a"=>1, "f"=>6, "g"=>7} | |
params # => {"b"=>2, "c"=>3, "d"=>4, "e"=>5, "h"=>8, "i"=>9, "j"=>10} |
This file contains 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
require 'digest' | |
result = Hash.new() { |hash, key| hash[key] = [] } | |
Dir['**/*'].each do |file| | |
if File.file?(file) | |
result[Digest::MD5.new.file(file).to_s] << file | |
end | |
end | |
result |
This file contains 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
ls **/en.yml **/de.yml | grep -v spec| tar -czf archive.tgz -T - |
OlderNewer