Skip to content

Instantly share code, notes, and snippets.

7rans trans

Block or report user

Report or block trans

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@trans
trans / email-parser.rb
Created Dec 10, 2017
Parse Email Crude
View email-parser.rb
class Email
attr :headers
attr :body
def initialize
@headers = Multimap.new
@body = ""
end
def parse(io)
View clik2.cr
$argv = [] of String
def cli(argv=ARGV)
# Convert single dash flags into multiple flags.
a = [] of String
argv.each do |v|
if v[0,1] == "-" && v[1,1] != "-"
a.concat(v[1..-1].chars.map{|c| "-#{c}"})
else
a << v
@trans
trans / clik.cr
Created Aug 10, 2015
Crystal port of Clik
View clik.cr
def cli(opts : Hash(String,Proc))
cli(ARGV.dup, opts)
end
def cli(argv : Array(String), opts : Hash(String,Proc))
args = [] of String
# Split option aliases.
h = {} of String => ->
opts.each do |k,v|
View tk-8.5.10.1.sh
# This is a build script made for ruby-install, though it may be out of date by now.
# Still the same basic approach applies.
# @see http://www.tkdocs.com/tutorial/install.html
# TODO: Add support for MacOS.
if [ -z $installdir ]; then
installdir="/opt/ActiveTcl-8.5"
fi
@trans
trans / trans1-jl.md
Last active Aug 29, 2015
Two proposals for a better Julia Module System
View trans1-jl.md

This is one of two proposals for a better module system for Julia. The goal is to promote good modular design. This proposal, as opposed to my other proposal, supports multiple modules per file.

The main concept is that files are loaded into a program always at the toplevel. Once loaded any module within those files are available for use, either through their absolute paths or by way of importing.

I will use the function load in the examples, but obviously another term can be used. When a file is loaded, it's modules are made available as are it's exported functions via absolute paths. e.g.

# Bar.jl
module Bar
  function f()
    ... 
@trans
trans / indexfilter.jl
Created Aug 14, 2014
Index filter for Pandoc
View indexfilter.jl
#!/usr/bin/env runhaskell
import Text.Pandoc
import Text.Pandoc.Shared
import Text.Pandoc.JSON
import Text.Parsec
import Text.Regex
import Control.Applicative
import Data.Monoid
import Data.List
@trans
trans / AltGtk.jl
Last active Aug 29, 2015
Another Look at Julia's Import/Module Syatem
View AltGtk.jl
# Notes: Notice there is no `module Gtk` at the top. b/c not the file _is_ the module.
#
# The term `use` was chosen just to differentiate from the others. It would
# probably be called `import` in the end.
#
# The complex imports for GLib are gone. Why does there need to be a separate
# and specific import just b/c a function is going to be extended. The same is
# true for Base.
#
# The arguments are just file names and could also be written, e.g. `("GLib/Glib")`.
View igny2.yaml
--- !!yaml
- !!version "2.0"
- !!tags
"!!": "tag:example.com,2000:app/"
---
!!int 1 - 3 # Interval, not integer
@trans
trans / superini.md
Last active Aug 29, 2015
Indention or Double Brackets for Super INI
View superini.md
[section]

  [subsection1]
  key1=value1
  key2=value2

  [subsection2]
  key1=value1
  key2=value2
@trans
trans / postponed-arguments
Created Jun 2, 2014
Postponed Evaluation of Arguments
View postponed-arguments
# Postponed Evaluation of Arguments
Today in Ruby, there are a few special `methods' in that they do not seem to evaluate their arguments. An example is alias, which contrary to Module#alias_method does not take symbols as arguments, but instead takes the method names directly. This cannot be done by pure Ruby code as the method name would be evaluated by calling the method and taking the return value as the actual value of the parameter. The idea would be to give a method control over this. There are lots of unanswered questions though:
Languages like Lisp can do this in their macros because code is data and can easily be manipulated. In Ruby, code is not data (yet). It would be nice if it could be data. This requires the representation of a parse tree (although that may change with the advent of YARV) that can be inspected or even manipulated. This would be a powerful tool by itself, but at least inspection is required to make full use of the idea of postponed evaluation of arguments.
How is it indicated
You can’t perform that action at this time.