Skip to content

Instantly share code, notes, and snippets.

@koteq
koteq / mal-season-friends-watching.user.js
Created April 14, 2016 22:27
MAL Season Friends Watching
// ==UserScript==
// @name MAL Season Friends Watching
// @version 1.0
// @match http://myanimelist.net/anime/season
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js
// @require https://cdn.rawgit.com/patik/within-viewport/1.0.0/withinviewport.js
// @require https://cdn.rawgit.com/patik/within-viewport/1.0.0/jquery.withinviewport.js
// @require https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js
// ==/UserScript==
@koteq
koteq / git-ls-dublicates.sh
Created December 12, 2015 19:29
git wrong case dublicates
git ls-files | sort -f | uniq -cid | wc -l
@koteq
koteq / App.java
Created September 14, 2015 15:57
Teh MVC... kind of
public class App {
public static void main(String[] args) {
NumberModel model = new NumberModel();
NumberController controller = new NumberController(model);
}
}
@koteq
koteq / ruble_format.php
Last active September 8, 2016 12:58
Ruble format #currency #money
<?php
/**
* Formats a number as a ruble currency string for web.
*
* @param float $number The number to be formatted.
* @param int $decimals [optional]
* @param boolean $trim_zero_decimals [optional]
* @param boolean $add_currency_suffix [optional]
* @return string A formatted version of number.
# coding: utf-8
# based on http://baguzin.ru/wp/?p=7873
import re
class AssParser:
def __init__(self):
self.dialog_re = re.compile(r'Dialogue:(?:[^,]*,){9}(.*)')
@koteq
koteq / lomarengas.user.js
Last active August 29, 2015 14:06
lomarengas.fi distance from border control points
// ==UserScript==
// @name lomarengas distance matrix
// @description shows distance from border control points
// @version 20140910
// @match http://www.lomarengas.fi/*
// @updateURL https://gist.github.com/thekot/339e229ddb59ff66c8d0/raw/lomarengas.user.js
// ==/UserScript==
var map_canvas = document.querySelector('#map_canvas');
var geo = document.querySelector('div[itemprop="geo"]');
@koteq
koteq / mal_sort_plan2watch.js
Last active September 23, 2021 19:40
myanimelist.net sort plan to wach by rank #mal
// go to your myanimelist.net
// click "Plan to Watch"
// scrooll all the way down
// exec this from console
const calc_weight = function (score, users) {
const mean = 7.0;
const minimum = 30000.0;
return (score * users + mean * minimum) / (users + minimum); // imdb top250
};
@koteq
koteq / wallpaper_resize.bat
Last active August 29, 2015 14:00
Sigma for unsharp calculated by formula [screen ppi]/150 and for screen 1366x768 15.6" (100.45 ppi) it's equal to 0.669
for %%f in (*.png *.jpg) do convert "%%f" ^
-filter Lanczos -resize "1366x768^" ^
-unsharp 0x0.669+0.4+0.008 ^
-gravity center -extent 1366x768 ^
-set filename:f "%%t_%%wx%%h.png" "png:%%[filename:f]"
rem or use this cmdline:
rem for %f in (*.png *.jpg) do convert "%f" -filter Lanczos -resize "1366x768^" -unsharp 0x0.669+0.4+0.008 -gravity center -extent 1366x768 -set filename:f "%t_%wx%h.png" "png:%[filename:f]"
@koteq
koteq / gist:9973243
Last active August 29, 2015 13:58
phpstorm <?= spacing ?> regex
http://youtrack.jetbrains.com/issue/WI-17096
Ctrl + R
(<\?=?) ([^\s])|([^\s]) (\?>)
$1$2$3$4
@koteq
koteq / disable_output_buffering.php
Last active December 1, 2022 04:32
How to disable output buffering
<?php
// http/1.1 header to disable browsers cache
header('Cache-Control: no-cache');
// tell nginx to disable buffering
header('X-Accel-Buffering: no');
// disable apache mod_gzip and mod_deflate
apache_setenv('no-gzip', 1);