Skip to content

Instantly share code, notes, and snippets.

View weirdpercent's full-sized avatar

Drew Prentice weirdpercent

View GitHub Profile
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'zaml'
require 'json'
yaml_str = <<-eos
yaml goes here
eos
@weirdpercent
weirdpercent / html2doku
Last active October 8, 2018 13:18
Perl script to convert HTML to Dokuwiki markup using the HTML::WikiConverter module
#!/usr/bin/perl -w
# Perl script to convert HTML files to DokuWiki Markup.
# Requires HTML::WikiConverter Perl module
use HTML::WikiConverter;
print "HTML to DokuWiki markup converter\n";
my $argcnt = $#ARGV + 1;
if ($argcnt == 2) {
print "Converting...";
(import '(javax.sound.sampled AudioSystem DataLine$Info SourceDataLine
AudioFormat AudioFormat$Encoding))
(def popular-format
(AudioFormat. AudioFormat$Encoding/PCM_SIGNED
48000 ; sample rate
16 ; bits per sample
2 ; channels
4 ; frame size 2*16bits [bytes]
48000 ; frame rate
@weirdpercent
weirdpercent / addjson.rake
Last active December 24, 2015 17:19
This rake task is part of the kvr-tools project. It parses product entries in JSON format into Active Record.
desc "Add product entries to database"
task :addjson => :environment do
require 'multi_json'
print 'Adding products to database'
fa=[]
Dir.glob('json/*.json').select {|f| fa.push f}
pa={}
x=0
y=fa.length
y-=1
# Runs with Picky 3.3.1.
#
# Note: You need some example html files in
# the same directory.
#
# Index data and start:
# 1. rake index
# 2. ruby app.rb
#
# Then, search on it using:

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

Project

Description: What does this project do and who does it serve?

Project Setup

How do I, as a developer, start working on the project?

  1. What dependencies does it have (where are they expressed) and how do I install them?
  2. How can I see the project working before I change anything?
@weirdpercent
weirdpercent / rdoc2md.rb
Created March 11, 2014 16:45
Convert rdoc to markdown
require 'rdoc'
h = RDoc::Markup::ToMarkdown.new
puts h.convert(input_string)
["YARVInstructionSequence/SimpleDataFormat",
2,
1,
1,
{:arg_size=>0, :local_size=>3, :stack_max=>2},
"<main>",
"./example.rb",
"/home/someone/example.rb",
1,
:top,