Skip to content

Instantly share code, notes, and snippets.

Alexander Pánek JimPanic

Block or report user

Report or block JimPanic

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
@JimPanic
JimPanic / new-lexer.coffee
Last active Oct 14, 2016
A less entangled and coupled lexer for Coffeescript and the token stream output for itself
View new-lexer.coffee
###
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
View gist:e9bc60f738afca7b9116
~/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 Nov 19, 2015
profile::snowflake
View snowflake.pp
# 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 Aug 29, 2015
Changing the prompt in fish; and making it permanent
View gist:a76de4422e45f6c63db8
$ 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 Jun 17, 2015
Ruby, I hate you. Or: how puppet called by bundle exec rake spec does something else than puppet called by me.
View gist:9654d85332be88228e1f
# 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 Sep 9, 2014
define object properties in coffeescript
View gist:0b3d6522404ca5189ad9
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
View yes! YES!
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 Dec 25, 2015
EnsureType .. enforced ducktyping in javascript
View ensure.coffee
# 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' ]
You can’t perform that action at this time.