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 / ybisect.py
Last active December 18, 2015 22:29
Bisect based formula testing
"""Bisect based formula testing.
Implements bisect_lt, bisect_le, bisect_ge, bisect_gt from scratch using `yfun`
# http://code.google.com/codejam/contest/2418487/dashboard
>>> r, t = 10**16, 10**18
>>> yfun = lambda x: (2*(10**16) + (2*x) -1) * x
Given bisect_le(yfun, y, range(N))
>>> bisect_le(yfun, t, range(t))
49
@lukmdo
lukmdo / gist:5564189
Last active December 17, 2015 06:19
Command line shortcuts
  • ^A move cursonr to Begin of line
  • ^E move cursonr to End of line
  • ^D delete current char
  • ^W delete word left to current char
  • ^U delete everything left to current char
  • ^K delete everything right to current char
  • ^T transpose
  • ^F (right arrow) move cursonr to Next char
  • ^B (left arrow) move cursonr to Prev char
  • ^P bring Prev history cmd
@lukmdo
lukmdo / gist:5105021
Last active October 15, 2017 06:12
intrigued by python signal capabilities [async]
"""Got intriged with signal capabilities (http://docs.python.org/2/library/signal.html)
I define simple ``asyncall`` function thats takes numner seconds and deffered function (similar window.setTimeout(n_ms, func/code_literal))
>>> asyncall(5, lambda *args: say('A'))
>>> asyncall(10, lambda *args: say('B'))
>>> asyncall(2, lambda *args: say('C'))
C
A
B
@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
@lukmdo
lukmdo / gist:4688861
Created February 1, 2013 03:09
Misc datasets to play with
@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))
# 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: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
@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:4526413
Last active December 11, 2015 01:49
Mac macports comands

MacPorts ACTIONS

✔ search
port search vim
port search --regex 'docbook.*[0-9]+'
✔ info