Skip to content

Instantly share code, notes, and snippets.

View JimPanic's full-sized avatar

Alexander Pánek JimPanic

  • Austria, Vienna
View GitHub Profile
@JimPanic
JimPanic / new-lexer.coffee
Last active October 14, 2016 12:24
A less entangled and coupled lexer for Coffeescript and the token stream output for itself
###
A set of functions to tokenize a string.
`lexer` is meant to be the entry point to analyse a string. It takes two
parameters, a string containing code and an associated (file) name, and returns
the created set of tokens.
The set of tokens returned by `lexer` is aggregated in `tokenize`, which is
called initially with the result of `initialToken`. This is necessary for the
@JimPanic
JimPanic / gist:e9bc60f738afca7b9116
Created January 22, 2016 12:14
first valid search reply
~/p/d/a/ldap_server master $ ldapsearch -H 'ldap://localhost:4040/' -D 'a' -b 'dc=foo,dc=example,dc=com' '(foo=bar)' a
ldap_bind: Success (0)
matched DN: a
additional info: Authenticated!
# extended LDIF
#
# LDAPv3
# base <dc=foo,dc=example,dc=com> with scope subtree
# filter: (foo=bar)
# requesting: a
@JimPanic
JimPanic / snowflake.pp
Created November 19, 2015 23:47
profile::snowflake
# Add this profile to be able to define a list of further profiles to include
# in hieradata.
#
# This lets you compose a role with other profiles to create "very special
# snowflake" configurations.
class profile::snowflake {
$profiles = hiera_array('profiles::include', [])
contain $profiles
}
@JimPanic
JimPanic / gist:a76de4422e45f6c63db8
Created August 29, 2015 14:28
Changing the prompt in fish; and making it permanent
$ function fish_prompt; set_color white; echo -n $USER:(echo $PWD | sed -e "s|$HOME|~|"); set_color normal; echo -n ' $ '; end
apanek: ~/blog $ funcsave fish_prompt
@JimPanic
JimPanic / gist:9654d85332be88228e1f
Created June 17, 2015 17:35
Ruby, I hate you. Or: how puppet called by bundle exec rake spec does something else than puppet called by me.
# bundle exec rspec
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -S rspec spec/classes/bond/setup_spec.rb spec/defines/bond/debian_spec.rb spec/defines/bond/redhat_spec.rb spec/defines/bond_spec.rb spec/unit/network_facts_spec.rb spec/unit/provider/network_config/interfaces_spec.rb spec/unit/provider/network_config/redhat_spec.rb spec/unit/provider/network_route/redhat_spec.rb spec/unit/provider/network_route/routes_spec.rb spec/unit/type/network_config_spec.rb spec/unit/type/network_route_spec.rb --color
...............FFFF.FF...................................................................................................................................................................................................**.*.***.......................................
Pending:
Puppet::Type::Network_config when validating the attribute options should be a descendant of the KeyValue property
# on conversion to specific type
# ./spec/unit/type/network_config_spec.rb:69
@JimPanic
JimPanic / gist:0b3d6522404ca5189ad9
Created September 9, 2014 17:40
define object properties in coffeescript
with_defaults = (object, defaults) ->
f = (previous, current) ->
unless Object.hasOwnProperty(previous, current)
previous[current] = object[current]
previous
Object.keys(object).reduce f, defaults
# "Fancy" version of Object.defineProperty that stores and applies a given
use std::iter::Range;
fn main() {
println!("I am such a great program. I can count to ten.")
let start = 1;
let stop = 10;
start = 2;
for i in natural_range(start, stop) {
@JimPanic
JimPanic / ensure.coffee
Last active December 25, 2015 10:09
EnsureType .. enforced ducktyping in javascript
# Ensure given object implements methods and has properties according to the
# given interface.
#
# An interface may look as follows:
#
# DuckType = {
# getFoo: 'function', # Expect function foo
# setFoo: [ 'function', 3 ], # Expect function bar, taking at least 3 arguments
# bar: 'property',
# boo: [ 'property', 'string' ]