Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/env python | |
#coding:utf-8 | |
""" | |
gauth.py | |
Adam Hupp <adam at hupp.org> | |
module for transparent authentication to (some) google services |
#!/usr/bin/env python | |
""" | |
$ echo "ciao" | python is_regular_file.py - <(cat comments.vim) comments.vim | |
'<stdin>' is not a regular file | |
'/dev/fd/63' is not a regular file | |
'comments.vim' is a regular file | |
""" | |
import os | |
import sys |
#-*- coding:utf-8 - *- | |
def load_dataset(): | |
"Load the sample dataset." | |
return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]] | |
def createC1(dataset): | |
"Create a list of candidate item sets of size one." |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
guard 'shell' do | |
watch(/(.*).(?:haml|ya?ml)/) do |file| | |
haml_file = file.first.gsub(/ya?ml/,'haml') | |
html_file = file.first.gsub(/[yh]a?ml/,'html') | |
puts "Converting #{haml_file} to #{html_file}" | |
`haml #{haml_file} > #{html_file} --trace` | |
end | |
end |
# Step 1: Set priveleges | |
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all | |
Starting... | |
Setting allow all users to YES. | |
Setting all users privileges to 1073742079. | |
Done. | |
# Step 2: Allow VNC clients |
# maybe.py - a Pythonic implementation of the Maybe monad | |
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# |
def multi(dispatch_fn): | |
def _inner(*args, **kwargs): | |
return _inner.__multi__.get( | |
dispatch_fn(*args, **kwargs), | |
_inner.__multi_default__ | |
)(*args, **kwargs) | |
_inner.__multi__ = {} | |
_inner.__multi_default__ = lambda *args, **kwargs: None # Default default | |
return _inner |
What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.
In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.
Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th
# Put this function to your .bashrc file. | |
# Usage: mv oldfilename | |
# If you call mv without the second parameter it will prompt you to edit the filename on command line. | |
# Original mv is called when it's called with more than one argument. | |
# It's useful when you want to change just a few letters in a long name. | |
# | |
# Also see: | |
# - imv from renameutils | |
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste) |