Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jasmarc on github.
  • I am jmarcell (https://keybase.io/jmarcell) on keybase.
  • I have a public key ASCgnjrWJQ9JMOa89ZBcmLLlCdeGWpj_fJgR4AQQVToiLwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am jasmarc on github.
  • I am jmarcell (https://keybase.io/jmarcell) on keybase.
  • I have a public key ASCgnjrWJQ9JMOa89ZBcmLLlCdeGWpj_fJgR4AQQVToiLwo

To claim this, I am signing this object:

@jasmarc
jasmarc / create_webpages.command
Created June 13, 2012 20:09
Creates a photo gallery from a folder full of images, somewhat per this request: http://www.idiotking.org/archives/2012/05/exercise-in-futility/
#! /usr/bin/env ruby
# 1. Save this file as "make_webpages.command"
# 2. chmod a+x+r make_webpages.command
# 3. Place make_webpages.command in folder full of pictures
# 4. Double-click make_webpages.command
extensions = "png,PNG,jpg,JPG,gif"
working_dir = File.dirname($0)
pictures = Dir.glob("#{working_dir}/*.{#{extensions}}")
@jasmarc
jasmarc / ruby-LDA.rb
Created April 19, 2011 03:37
running LDA on some stuff
entries = Entry.all :limit => 20, :abstractText.not => nil
corpus = Lda::Corpus.new
entries.each do |entry|
doc = Lda::TextDocument.new(corpus, entry.abstractText)
corpus.add_document(doc)
end
lda = Lda::Lda.new(corpus) # create an Lda object for training
lda.em("random") # run EM algorithm using random starting points
require 'rubygems'
require 'datamapper'
require 'pp'
class Author
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :entries, :through => Resource
has n, :friendships, :child_key => [ :source_id ]
using Put.Usings.Here;
namespace Your.Namespace.Here
{
public class CommonPolicyDeclarationWrapper : BaseWrapper
{
private CommonPolicyDeclaration _commonPolicyDeclaration;
internal CommonPolicyDeclarationWrapper(CommonPolicyDeclaration commonPolicyDeclaration)
{
_commonPolicyDeclaration = commonPolicyDeclaration;
using Put.Usings.Here;
namespace Your.Namespace.Here
{
public class CommonPolicyDeclaration
{
public string Description { get; set; }
public int StatusCode { get; set; }
}
}
require 'yaml'
class String
def to_camel
parts = self.scan(/[A-Z]*[a-z]*/)
parts.first.downcase!
parts.join
end
end
require 'yaml'
def top(clazz)
<<EOF
using Put.Usings.Here;
namespace Your.Namespace.Here
{
public class #{clazz}
{
CommonPolicyDeclaration:
Description: string
StatusCode: int
# PolicyForm
PolicyForm:
PolicyFormId: int
Document: RuleBasedDoc
FieldValues: IList<FieldValue>