Skip to content

Instantly share code, notes, and snippets.

🙈
¯\_(ツ)_/¯

Nikolay Shebanov killthekitten

🙈
¯\_(ツ)_/¯
Block or report user

Report or block killthekitten

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@killthekitten
killthekitten / main.py
Created Jun 9, 2019
flask run + DispatcherMiddleware demo
View main.py
from flask import Flask
from werkzeug.middleware.dispatcher import DispatcherMiddleware
api = Flask("api")
admin = Flask("admin")
app = DispatcherMiddleware(api, {"/admin": admin})
@killthekitten
killthekitten / keep_proportion.py
Created Apr 9, 2019
Illustrates Pixmap regression introduced in PyMuPDF 1.14.13
View keep_proportion.py
import fitz
import io
import requests
PDF_URL = "https://github.com/pymupdf/PyMuPDF/raw/master/examples/colordbHSV.pdf"
PNG_URL = "https://www.onlygfx.com/wp-content/uploads/2018/07/12-grunge-brush-stroke-banner-11.png"
def handle(_):
pdf = requests.get(PDF_URL).content
@killthekitten
killthekitten / keep_proportion.py
Created Apr 3, 2019
Illustration of a bug (a feature?) in pyMuPDF
View keep_proportion.py
import fitz
import io
import requests
PDF_URL = "https://github.com/pymupdf/PyMuPDF/raw/master/examples/colordbHSV.pdf"
PNG_URL = "https://www.onlygfx.com/wp-content/uploads/2018/07/12-grunge-brush-stroke-banner-11.png"
def handle(_):
pdf = requests.get(PDF_URL).content
View main.py
import fitz
import io
import requests
PDF_URL = "https://github.com/pymupdf/PyMuPDF/raw/master/examples/colordbHSV.pdf"
PNG_URL = "https://raw.githubusercontent.com/pymupdf/PyMuPDF/master/examples/hand.png"
def handle(_):
"""
View sgdregressor.py
class SGDRegressor(BaseEstimator):
def __init__(self, eta=10**-3, n_iter=10):
self.mse_ = []
self.weights_ = []
self.eta_ = eta
self.n_iter_ = n_iter
def fit(self, X, y):
X = self._prepend_ones(X)
current_w = np.zeros(X.shape[1], dtype=np.float64, order="C")
@killthekitten
killthekitten / persistent_csrf_token_cookie.rb
Last active Jun 22, 2017
Persistent CSRF token cookie
View persistent_csrf_token_cookie.rb
View bulk_validator.rb
class BulkValidator
attr_accessor :items, :bulk_validations
def initialize(items, validations)
@items = items
@bulk_validations = build_bulk_validations(validations)
end
def candidates
bulk_validations.each do |validation|
View models.rb
class TariffSchemeFeeRule < ActiveRecord::Base
belongs_to :tariff_scheme
belongs_to :fee_rule
belongs_to :currency
validates :currency_id, uniqueness: { scope: [:fee_rule_id, :tariff_scheme_id] }, presence: true
end
class TariffScheme < ActiveRecord::Base
accepts_nested_attributes_for :tariff_scheme_fee_rules, allow_destroy: true
View _activity_field.html.erb
<table>
<tr class='entry_header'>
<th>Task</th>
<% @timesheet.date_range.each do |week_date| %>
<th><%= week_date.to_formatted_s(:short) %></th>
<% end %>
</tr>
<tr class="fields">
<td><%= f.collection_select(:task_id, @tasks, :id, :name, prompt: true) %></td>
<%= f.fields_for :time_entries do |builder|%>
View _box.css.scss
.b-box {
overflow: hidden;
margin: 0 0 20px 0;
border-radius: 7px;
box-shadow: 1px 1px 2px rgba(0, 0, 0, .2);
background: #f4f4f4;
> header {
border-radius: 7px 7px 0 0;
padding: 8px 0 8px 0px;
You can’t perform that action at this time.