Skip to content

Instantly share code, notes, and snippets.

View maksadbek's full-sized avatar
💭
Chilling

Maksadbek maksadbek

💭
Chilling
View GitHub Profile
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 / 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
@maksadbek
maksadbek / js.sh
Created February 8, 2019 17:26
Pretty print json from clipboard and open in vim
#!/bin/bash
randname=$(LC_ALL=C cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 5 | head -n 1)
randname="$(date "+%d_%m_%y_")$randname"
randfile="/tmp/$randname"
echo $randname
pbpaste | jq . > $randfile && vim $randfile
@maksadbek
maksadbek / bash.generate.random.alphanumeric.string.sh
Created February 8, 2019 17:25 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
int n = 110000;
int m = 250000;
Adj adj(2, vector<vector<int>>(n));
Adj cost(2, vector<vector<int>>(n));
std::vector<std::pair<Len,Len>> xy(n);
for (int i = 0; i < n; ++i) {
int a = 100000000 - rand() % 200000001, b = 100000000 - rand() % 200000001;