Skip to content

Instantly share code, notes, and snippets.

View MyGodIsHe's full-sized avatar
🥰

Ilya Chistyakov MyGodIsHe

🥰
View GitHub Profile
@MyGodIsHe
MyGodIsHe / chrome_history_export.js
Created November 5, 2018 11:36
Chrome history export. Open chrome://history/, open dev console, put this code, press PageDown, then P for create result in div.
(function() {
var outDiv = document.createElement("div");
document.body.appendChild(outDiv);
var history_item = document.getElementById("history-app").shadowRoot.getElementById("history").shadowRoot.getElementById("infinite-list").getElementsByTagName("history-item");
var output = new Set();
document.body.onkeydown = function handle(e) {
if (e.keyCode == 34) {
for (item in history_item) {
var item = history_item[item].shadowRoot;
if (!item) continue;
@MyGodIsHe
MyGodIsHe / ordered_int.go
Last active August 26, 2017 16:03
Golang functions to work with sorted array by binary search.
package main
import (
"fmt"
"sort"
)
func OrderedInsert(a []int, j int) []int {
n := len(a)
if n == 0 {
@MyGodIsHe
MyGodIsHe / progress_bar.py
Last active September 18, 2016 01:47
Console Progress Bar on python
import sys
class ProgressBar(object):
def __init__(self, total, prefix='', suffix='', decimals=1, bar_length=100):
"""
Call in a loop to create terminal progress bar
:param total: total iterations
:param prefix: prefix string
:param suffix: suffix string
@MyGodIsHe
MyGodIsHe / habr_tm.py
Last active September 5, 2016 11:23
pip install BeautifulSoup
#!/usr/bin/python
import SocketServer
import SimpleHTTPServer
import urllib
import re
from BeautifulSoup import BeautifulSoup, NavigableString, Tag, PageElement
TARGET = 'habrahabr.ru'
HOST = '127.0.0.1'
@MyGodIsHe
MyGodIsHe / list.py
Created August 2, 2016 10:27
Doubly linked list on python
class Item(object):
def __init__(self, data):
self.prev = None
self.next = None
self.data = data
def delete(self):
if self.prev != None:
self.prev.next = self.next
@MyGodIsHe
MyGodIsHe / vk.com.ads.blocker.user.js
Last active September 14, 2016 07:42
Hide advertising on new.vk.com!
// ==UserScript==
// @name vk ads blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide advertising on vk.com!
// @author Ilya Chistyakov
// @match *://vk.com/*
// @grant none
// ==/UserScript==
@MyGodIsHe
MyGodIsHe / log.py
Created January 19, 2016 19:02
Processing generators
def log(f):
def wrap(*args, **kwargs):
total = 0
t = time.time()
r = f(*args, **kwargs)
total += time.time() - t
if isinstance(r, types.GeneratorType):
try:
while 1:
t = time.time()
@MyGodIsHe
MyGodIsHe / fmerge.py
Last active January 20, 2016 10:33
Merging sorted lists in a functional style
def none_if_except(f, e=Exception):
try:
return f()
except e:
pass
def list_anyway(f, iterable):
values = []
for i in iterable:
@MyGodIsHe
MyGodIsHe / ExtendProceduralMeshLibrary.cpp
Created January 2, 2016 21:14
UE4 procedural transformation from cube to sphere
void UExtendProceduralMeshLibrary::GenerateBoxMesh(FVector BoxSize, FIntVector BoxSegments, TArray<FVector>& Vertices, TArray<int32>& Triangles, TArray<FVector>& Normals, TArray<FVector2D>& UVs, TArray<FProcMeshTangent>& Tangents)
{
BoxSize.X = abs(BoxSize.X); // width
BoxSize.Y = abs(BoxSize.Y); // height
BoxSize.Z = abs(BoxSize.Z); // depth
BoxSegments.X = BoxSegments.X < 1 ? 1 : BoxSegments.X;
BoxSegments.Y = BoxSegments.Y < 1 ? 1 : BoxSegments.Y;
BoxSegments.Z = BoxSegments.Z < 1 ? 1 : BoxSegments.Z;
@MyGodIsHe
MyGodIsHe / wrap.py
Last active August 29, 2015 14:18
Django wrap tag
from django.template.base import Node, Library, TemplateSyntaxError, Context
from django.template.loader import get_template
register = Library()
class WrapControlNode(Node):
"""Implements the actions of the wrap tag."""
def __init__(self, filepath, nodelist):
self.filepath, self.nodelist = filepath, nodelist