Skip to content

Instantly share code, notes, and snippets.

View maksadbek's full-sized avatar
💭
Chilling

Maksadbek maksadbek

💭
Chilling
View GitHub Profile

Directive for displayed math (math that takes the whole line for itself).

The directive supports multiple equations, which should be separated by a blank line:

.. math::

(a + b)^2 = a^2 + 2ab + b^2 (a - b)^2 = a^2 - 2ab + b^2

In addition, each single equation is set within a split environment, which means that you can have multiple aligned lines in an equation, aligned at & and separated by \\:

def heapify(a, n, i):
largest = i
l = 2 * i + 1
r = 2 * i + 2
if l < n and a[i] < a[l]:
largest = l
if r < n and a[largest] < a[r]:
largest = r
def search(arr, l, r, x):
if r >= l:
mid = int(l + (r - l)/2)
if len(arr) <= mid:
return mid
if arr[mid] == x:
return r, mid
elif arr[mid] > x:
return search(arr, l, mid-1, x)
@maksadbek
maksadbek / pythononeliners.txt
Created April 3, 2019 22:21 — forked from miku/pythononeliners.txt
python one liners!
Some useful Python one-liners taken from http://www.reddit.com/r/Python/comments/fofan/suggestion_for_a_python_blogger_figure_out_what/
All modules listed are part of the standard library and should work with Python 2.6+
How to use:
$ python -m [module] [arguments]
calendar - does default to displaying a yearly calendar, but it has a bunch of options (args are year or year month, options are HTML output, calendar locale, encoding, and some type-specific stuff, see python -m calendar -h)
cgi, dumps a bunch of information as HTML to stdout
@maksadbek
maksadbek / attack.md
Created March 29, 2019 15:51 — forked from timruffles/attack.md
Chrome/Gmail attack received 11/03/2016. Not sure if the Chrome meta refresh + data:text,html technique is novel.

The following attack will display a "you've been signed out" page for GMail, and attempt to steal your account credentials.

DO NOT PUT ANY ACCOUNT CREDENTIALS INTO ANY TABS CREATED AFTER VISITING THESE LINKS :)

I received an email in my GMail inbox with a fake attachment image, styled to look like the real GMail attachment UI:

fake

This linked to a page that ended up displaying a fake "you've been signed out" link, via the data:text/html... URL feature of Chrome:

@maksadbek
maksadbek / color-theme-seamus-magit.el
Created February 21, 2019 08:56 — forked from underhilllabs/color-theme-seamus-magit.el
magit section for emacs color theme
;; magit stuff!!
(magit-file-header ((t (:foreground "violet"))))
(magit-hunk-header ((t (:foreground "blue"))))
(magit-header ((t (:foreground "cyan"))))
(magit-tag-label ((t (:background "blue" :foreground "orange"))))
(magit-diff-add ((t (:foreground "MediumSlateBlue"))))
(magit-diff-del ((t (:foreground "maroon"))))
(magit-item-highlight ((t (:background "#000012"))))
@maksadbek
maksadbek / dijkstra_with_heur.py
Last active February 16, 2019 08:02
Dijkstra'a shortest path algorithm with heuristic function. That is equivalent to A star.
"""
source: https://en.wikipedia.org/wiki/A*_search_algorithm#Pseudocode
Not sure it is correct. Because pseudocode uses openset and closed set.
In this implementation only one of the is used - openset, it is a heap.
"""
import queue
import math
import sys
@maksadbek
maksadbek / pre-push.sh
Created February 15, 2019 13:37 — forked from vlucas/pre-push.sh
Prevent Pushes Directly to Master
#!/bin/bash
# @link https://gist.github.com/mattscilipoti/8424018
#
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
@maksadbek
maksadbek / jupyter.service
Created February 15, 2019 11:15 — forked from whophil/jupyter.service
A systemd script for running a Jupyter notebook server.
# After Ubuntu 16.04, Systemd becomes the default.
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config=/home/phil/.jupyter/jupyter_notebook_config.py