Skip to content

Instantly share code, notes, and snippets.

View lukmdo's full-sized avatar
:octocat:
loading...

Lukasz Dobrzanski lukmdo

:octocat:
loading...
View GitHub Profile
@lukmdo
lukmdo / asciify.py
Created November 14, 2012 15:42
Convert unicode to ASCII
#!/usr/bin/python3
"""
>>> some_unicode = u'èṽèṙẏbody ♥ utf8'
>>>
>>> some_unicode.encode('ascii', errors='replace')
b'?????body ? utf8'
>>>
>>> import unicodedata
>>> unicodedata.normalize('NFKD', some_unicode).encode(
@lukmdo
lukmdo / apple shortcuts.md
Created December 6, 2012 17:07
apple shortcuts
Spaces = ```Fn + F8```
Screenshots
-----------
* the whole screen, press ```⌘-⇧-3```
* part of the screen, press ```⌘-⇧-4``` and select the area you want
* to the Clipboard instead of saving as a file press:
* ```^-⌘-⇧-3``` to copy the entire screen
* ```^-⌘-⇧-4``` to copy the selected area
* for curent window, press ```⌘-⇧-4``` then ```Spacebar```
@lukmdo
lukmdo / gist:4526413
Last active December 11, 2015 01:49
Mac macports comands

MacPorts ACTIONS

✔ search
port search vim
port search --regex 'docbook.*[0-9]+'
✔ info
@lukmdo
lukmdo / gist:4546883
Created January 16, 2013 12:44
dummy datetime mocking (Better use a DUMMY class the is cmp/eq True always)
import unittest2 as unittest
from mock import patch
from mock import Mock
from datetime import datetime as dt
class TestMock(unittest.TestCase):
NOW = datetime.datetime(1970, 1, 1, 0, 0)
datetime_mock = Mock(side_effect = lambda *args, **kw:
dt(*args, **kw))
datetime_mock.now.return_value = NOW
@lukmdo
lukmdo / gist:4624695
Last active December 11, 2015 15:59
Bash - last command args shortcut
$ echo a b c d
a b c d
# PCA. - meaning previous command argument
$ echo !* ; # !* is all PCA == echo a b c d
a b c d
$ echo !^ ; # !^ is first PCA == echo a
a
# Ned's .pdbrc
# Print a dictionary, sorted. %1 is the dict, %2 is the prefix for the names.
alias p_ for k in sorted(%1.keys()): print "%s%-15s= %-80.80s" % ("%2",k,repr(%1[k]))
# Print the instance variables of a thing.
alias pi p_ %1.__dict__ %1.
# Print the instance variables of self.
alias ps pi self
@lukmdo
lukmdo / gist:4634074
Last active December 11, 2015 17:19
R notes
### Plots
x <- seq(0, 4, 0.1)
y <- cos(x)
plot(x, y, col=rainbow(12)) # 2-RED, 3-GREEN, 4-BLUE
a <- c(5, 8, 3); names(a)<- c("England", "France", "Norway"); barplot(a)
abline(h, v, lty=3, col="lightgray")
barplot(sin(seq(0, 4, 0.1)))
qplot(Xvect, Yvects)
qplot(weights, prices, col=factor(types))
abline(lm(X~Y))
@lukmdo
lukmdo / gist:4688861
Created February 1, 2013 03:09
Misc datasets to play with
@lukmdo
lukmdo / values.md
Created February 17, 2013 20:54
Core valuses

:octocat: core values

  • optimize for happiness
  • best argument wins
  • make decisions from first principals (values)
  • create superfans
  • be awseome and change the wolrd