Skip to content

Instantly share code, notes, and snippets.

View signalpillar's full-sized avatar

Volodymyr Vitvitskyi signalpillar

View GitHub Profile
;; function to kill buffer and close other window without switching to it
(defun kill-other-buffer-and-window ()
(interactive)
(kill-buffer (other-buffer))
(delete-other-windows))

I like tools that have some philosophy underneath and in this topic I will talk about Markdown. I also wanted to tell some words about Gist but I think you will explore its benefits while reading my dev notes as small gists.

Markdown (MD)

This is one of things I have opened relatively recently. Amazing approach how to think about any text in context of formatted document, in context that document has to be presented in readable way so must be marked up. Even in case if there is no support (Outlook, zim, skype or even git comments) for this markup I write text in MD as it declares very basic level how to express formatting. For instance all keywords I mark using back-quotes and so on.

I believe that every new product oriented for IT person if it has editable forms must support markdown. For instance, different popular products with web-client have tons of problems regarding text fileds. WYSIWYG that does basics in formatting require from my side anormouse amount of movements.

There must be stan

@signalpillar
signalpillar / web_as_pdf.py
Created July 18, 2013 07:11
Idea of web-page scraper to pdf
# install python htmldoc pdftk
import os
from subprocess import Popen
pdfs = []
DEPTH = 20
for i in xrange(1, DEPTH):
@signalpillar
signalpillar / repl.py
Created July 24, 2013 07:38
Below you will find interesting fact of how python works when collision happens, CPython ( & Pypy & Jython) behaviour in such case is called **probing** http://stackoverflow.com/questions/327311/how-are-pythons-built-in-dictionaries-implemented
>>> dict = {1: 2}
>>> dict[1] = 3
>>> dict
{1: 3}
>>> class A:
... def __hash__(self):
... return 1
...
>>> class B:
... def __hash__(self):
from itertools import dropwhile, takewhile
def read_file_content(path):
'@types: str -> str'
with open(path, 'r') as f:
return f.read()
def line_matches_keyword(line):
return line.find('Traceback') == -1

Concurrency VS Parallelism

Recently, at OHUG (Odessa Haskell User Group), we have raised a question: what is the difference between Parallelism and Concurrency. And seems like I have conflated terms Multitasking and Parallelism and want here to recap for myself the difference between these popular terms

  • Parallelism - means that two or more calculations happen simultaneously
    • form [haskell.org][4]
      • The term Parallelism refers to techniques to make programs faster by performing several computations in parallel. This requires hardware with multiple processing units. In many cases the sub-computations are of the same structure, but this is not necessary. Graphic computations on a GPU are parallelism.
    • from [Rob Pike presentation - Concurrency is not Parallelism (it's better)][3]
  • Parallelism is about doing lots of things at once.
@signalpillar
signalpillar / future_callbacks.py
Last active December 23, 2015 02:39
keep future/deffered API clean - when it comes to have list of functions to build a chain - don't. Leave this for the client code of API timer.set_callback(callback_fn) timer.remove_callback(callback_fn)
from itertools import imap
def create_future():
future = ...
# add tulip-like callback chain
fns = [first_callback_fn, second_callback_fn, third_callback_fn]
future.set_callback(tulip_chain(fns))
# in case you want to remove some of the functions in the chain
# just modify list of functions - you gain much more flexibility
@signalpillar
signalpillar / dev_with_git.md
Created October 7, 2013 13:06
Development with Git

Intro

The goal of this page is to suggest yet another one flow how to develop with Git. The goal of the flow itself is to make history more clearer and linear.

Flow

Given two branches develop and M42_feature_branch

We already did some development in the feature branch and even passed review. Next step is to merge changes into develop

git checkout develop

@signalpillar
signalpillar / busywait.hy
Last active August 29, 2015 13:56
hy on cherrypy
; standard imports
(import random)
; 3rd-party imports
(import [cherrypy [config quickstart expose]])
(def choices [
[
(import [collections [defaultdict]]
[itertools [starmap]]
[codecs [open]]
[sys [argv]]
[pprint [pprint]]
[functools [partial :as Fn]])
(def DELIMITERS u",.;:!?")
(defn parse-words [line]