Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
%w{foo Chihiro bar z0rk}.each do |word|
case word
when *[/[A-Z]/, /[0-9]/]
puts w
end
end
| Dry run | Update | Size
--------+---------+---------+--------
DB | 1.263s | on srvr | on srvr
YAML | 0.685s | 12.984s | 2580k
Marshal | 0.183s | 1.314s | 1944k
Class/Module Index
Ldb
Ldb::Context
Ldb::Context::Schema
Ldb::Dn
Ldb::Flags
Ldb::Flags::ChangeType
Ldb::Flags::Connect
Ldb::Flags::DebugLevel
Ldb::Flags::Mod
@pcarrier
pcarrier / number_to_bytes.rb
Created July 14, 2011 14:01
Turn a number to bytes in Ruby
class Numeric
def to_bytes
f = self
1.upto((Math.log2(self)/8).ceil).collect do
f, c = f.divmod 256; c
end.reverse
end
end
if __FILE__ == $PROGRAM_NAME and ARGV.length > 0
file { "/etc/foo.d":
source => [
"puppet:///modules/foo/conf/${debian_version}",
"puppet:///modules/foo/conf/common",
],
recurse => true,
}
(ns moob.sslbs
(:import (java.io InputStreamReader Reader)
(java.net URL
URLConnection)
(javax.net.ssl HostnameVerifier HttpsURLConnection
SSLContext SSLSession TrustManager
X509TrustManager)
(java.security cert.X509Certificate SecureRandom)))
(defn disable
LINK_MATCHER = re.compile(r"""
^
(?P<num> [0-9] +?) :
\ (?P<name> [^:] +?) :
\ <(?P<flags> [^>] +?)> # uppercase, comma-separated list of flags
\ (?P<extra> . *?) # space-separated pairs of "key value"
\ *\\\ *
\ *link/(?P<link> [^ ] +?)
\ (?P<addr> [0-9a-f:] +?)
\ brd\ (?P<brd> [0-9a-f:] +?)
require 'nokogiri'
doc = Nokogiri::XML open 'oval-definitions-2010.xml'
doc.css('definition[class="vulnerability"]').collect do |v|
references = v.css('reference').collect {|v| v['ref_id']}.grep /^CVE/
final_criteria = v.css('criterion[test_ref]').collect {|c| c['test_ref']}
next Hash[
final_criteria.collect{|c| doc.css "*[id='#{c}']"}.collect do |t|
obj_ref_nodes = t.css('*[object_ref]')
#ifndef g_info
#define g_info(...) g_log (G_LOG_DOMAIN,G_LOG_LEVEL_INFO, __VA_ARGS__)
#endif
typedef struct sp_session sp_session;
typedef struct sp_track sp_track;
typedef struct sp_album sp_album;
typedef struct sp_artist sp_artist;
typedef struct sp_artistbrowse sp_artistbrowse;
typedef struct sp_albumbrowse sp_albumbrowse;
typedef struct sp_toplistbrowse sp_toplistbrowse;
typedef struct sp_search sp_search;
typedef struct sp_link sp_link;
typedef struct sp_image sp_image;