Skip to content

Instantly share code, notes, and snippets.

@ceeblet
ceeblet / working profile
Created March 7, 2015 00:39
my current working .profile on MacOS
########### alias' ###################
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# -> Prevents accidentally clobbering files.
alias mkdir='mkdir -p'
alias h='history'
alias j='jobs -l'
alias which='type -a'
@ceeblet
ceeblet / find_attrs.py
Created March 10, 2015 20:00
console session - finding attributes that belong to function only, not inherited by object.
def g(x):
return x*x
g
<function g at 0x000000000306A268>
type(g)
<class 'function'>
dir(g)
['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
def f(x):
@ceeblet
ceeblet / function_composition.py
Created March 10, 2015 20:19
console session demonstrating function composition
>>> def compose(g, h):
... def anon(x):
... return g(h(x))
... return anon
...
>>> f3 = compose(f1, f2)
>>> f3("Shillalegh")
<__main__.Func object at 0x100569dd0>('Shillalegh') called
f1('Shillalegh') called
'Shillalegh'
@ceeblet
ceeblet / index.html
Created May 4, 2015 20:39
Drawing SVG Shapes with D3 Drawin Shapes w/ D3 = // source http://jsbin.com/raboraputi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Drawin Shapes w/ D3 = " />
<meta charset="utf-8">
<title>Drawing SVG Shapes with D3</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<h3>SVG Bar</h3>
@ceeblet
ceeblet / index.html
Created May 5, 2015 13:26
Drawing SVG Shapes with D3 Drawin Shapes w/ D3 = // source http://jsbin.com/yeremu
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Drawin Shapes w/ D3 = " />
<meta charset="utf-8">
<title>Drawing SVG Shapes with D3</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<svg width="250" height="50">
@ceeblet
ceeblet / keybase.md
Created February 10, 2016 18:16
keybase.md

Keybase proof

I hereby claim:

  • I am ceeblet on github.
  • I am ceeblet (https://keybase.io/ceeblet) on keybase.
  • I have a public key whose fingerprint is 3464 DE5B 6D62 C8FB 20AD 6BD1 8256 1EC7 EA81 3A0E

To claim this, I am signing this object:

import argparse
fqdn = "domain.com"
def mongo_by_url(uri):
uri_pieces = uri.split(":")
data = {
"user": uri_pieces[1].replace("//", ""),
@ceeblet
ceeblet / dict_case_switch.py
Created March 20, 2018 13:46
dicts as case or switch
def dispatch_if(operator, x, y):
if operator == 'add':
return x + y
elif operator == 'sub':
return x - y
elif operator == 'mul':
return x * y
elif operator == 'div':
return x / y
else:
@ceeblet
ceeblet / python_list_syntax
Created April 5, 2018 15:38
Python's list slice syntax: a few fun and useful things
# Python's list slice syntax can be used without indices
# for a few fun and useful things:
# You can clear all elements from a list:
>>> lst = [1, 2, 3, 4, 5]
>>> del lst[:]
>>> lst
[]
# You can replace all elements of a list
@ceeblet
ceeblet / openSSL_solution.txt
Created April 9, 2018 16:57
errors installing cryptography_one solution
brew install openssl
then brew gives a hint:
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables: