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
=begin | |
* ruby implementation of find that follows symbolic directory links | |
* tested on ruby 1.9.3, ruby 2.0 and jruby on Fedora 20 linux | |
* you can use Find.prune | |
* detect symlinks to dirs by path "/" suffix; does nothing with files so `symlink?` method is working fine | |
* depth first order | |
* detects cycles and raises an error | |
* raises on broken links | |
* uses recursion in the `do_find` proc when directory links are met (takes a lot of nested links until SystemStackError, that's practically never) |
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
=begin | |
based on find_follow.rb : https://gist.github.com/akostadinov/05c2a976dc16ffee9cac | |
* use like: cp_r_dereference 'src', 'dst' | |
Note: if directory `src` content is copied instead of the full dir. i.e. you end up | |
with `dst/*` instead of `dst/basename(src)/*` | |
Copyright (c) 2014 Red Hat inc | |
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
# execute this code to fall into a pry session upoon step failure | |
# works only with cucumber 1.3 | |
# so far for 2.0 best similar approach is to us the After hook | |
# fall into pry/buybug if scenario.failed? is true | |
# After hook works for 1.3 as well | |
Cucumber::Ast::StepInvocation.class_eval do | |
## first make sure we don't lose original accept method | |
unless self.instance_methods.include?(:orig_accept) | |
alias_method :orig_accept, :accept |
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
<?php | |
/* | |
original code by cogitom: https://gist.github.com/997980/ | |
phibo23: https://gist.github.com/2808256/ | |
This script reads future events (plus several days into the past) from Facebook pages | |
and creates a subscribable iCalendar | |
Improvements upon the original version: | |
- avoid setting DTEND field if facebook event lacks an end time |
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 'fileutils' | |
# this is ugly quickly hacked script, not very nice and reliable at the moment | |
# it finds what files from one archive need to be backed-up (i.e. are not present in some other archive dir) | |
# $ find new_dir -type f > arch.txt | |
# $ find old_dir -type f > arch_old.txt | |
# `find -name ".?*" -prune -o -type f` to avoid hidden files | |
# cat to_arch.txt | xargs -d "\n" stat -c "%s" | awk '{size+=$1} END {print size}' # to see size of files to copy | |
# sudo rsync -avx --files-from=to_arch.txt ./ /path/to/store/backup | |
# TODO: get files fast hash (md5?) and compare based on it; avoid external tools like find |
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
=begin | |
Copyright (c) 2015 Red Hat inc | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. |
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 | |
# see https://github.com/sparklemotion/nokogiri/issues/1200 | |
require 'nokogiri' | |
src =<<EOD | |
<wrapper xmlns="ns"> | |
<record xml:id="r1" xmlns:extra="extra"> | |
<field>aaa</field> |
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 | |
# see https://github.com/sparklemotion/nokogiri/issues/1200 | |
require 'nokogiri' | |
src =<<EOD | |
<wrapper xmlns="ns"> | |
<record xml:id="r1" xmlns:extra="extra"> | |
<field>aaa</field> |
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 'io/console' | |
require 'wsse' | |
header = WSSE::header('username', STDIN.noecho(&:gets).chomp) | |
def wsse_xml(user, password) | |
raw = WSSE::header(user, password) | |
# username = raw.gsub(/^.* Username="(.*)", PasswordDigest=".*(?!PasswordDigest)$/, '\\1') | |
digest = raw.gsub(/^.*, PasswordDigest="(.*)", Nonce=".*$/, '\\1') | |
nonce = raw.gsub(/^.*, Nonce="(.*)", Created=".*$/, '\\1') |
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
# LICENSE: MIT, wtfpl or whatever OSS license you like | |
function get_stack () { | |
STACK="" | |
local i message="${1:-""}" | |
local stack_size=${#FUNCNAME[@]} | |
# to avoid noise we start with 1 to skip the get_stack function | |
for (( i=1; i<$stack_size; i++ )); do | |
local func="${FUNCNAME[$i]}" | |
[ x$func = x ] && func=MAIN | |
local linen="${BASH_LINENO[$(( i - 1 ))]}" |
OlderNewer