Skip to content

Instantly share code, notes, and snippets.

Alexander absent1706

Block or report user

Report or block absent1706

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
View dict-without-keys.py
def dict_without_keys(data_: dict, keys: list):
"""
Example:
from dictdiffer import diff
assert list(diff(
dict_without_keys(listing.to_dict(), ['_id', '_cls', 'created_date', 'updated_date', 'rooms[].id', 'photos']),
dict_without_keys(normal_listing_dict, ['photos'])
View svd-from-scratch.py
# this method works well on ALL data
# see https://towardsdatascience.com/my-notes-for-singular-value-decomposition-with-interactive-code-feat-peter-mills-7584f4f2930a
import numpy as np
from sklearn import preprocessing
np.set_printoptions(precision=2)
X = np.array([
[1,2,3],
[4,10,1],
[5,3,2],
View datascience-visualize-grid-cv.py
def visualize_grid_cv_params(grid_cv):
df = pd.DataFrame(grid_cv.cv_results_['params'])
df['score'] = grid_cv.cv_results_['mean_test_score']
fig, axes = plt.subplots(1, len(grid_cv.param_grid), sharey=True, figsize=(15,4))
i = 0
for param in grid_cv.param_grid:
data = df.groupby(param).mean()['score'].to_dict()
param_values = list(data.keys())
View animate-on-scroll.html
<style>
/* aos = animate on scroll */
/* ================== Fade ================== */
[class^='aos-fade'] {
opacity: 0;
transition: 1s;
}
[class^='aos-fade'].aos-animate {
opacity: 1;
@absent1706
absent1706 / diy-jquery-delegated-handling.html
Created Oct 6, 2017
DIY jQuery delegated events handling like $(document).on('click', '.child', handler)
View diy-jquery-delegated-handling.html
<!DOCTYPE html>
<html>
<head>
<script>
/* Core function which does event delegation like jQuery http://www.qopy.me/MpAEDJZiQKutDbKGuOEdQA
* Writing
* addDelegatedEventListener(parent, eventName, childSelector, handler)
*
* Is absolutely equivalent to writing jQuery's code:
* $(parent).on(eventName, childSelector, handler)
@absent1706
absent1706 / ko-mapping.html
Last active Oct 5, 2017
Knockout mapping for filling observableArray with view models from AJAX request
View ko-mapping.html
<!DOCTYPE html>
<html>
<body>
<button data-bind="click: loadProducts">Load Products</button>
<ul data-bind="foreach: products">
<li>
<span data-bind="text: id"></span>
<span data-bind="text: name"></span>
</li>
@absent1706
absent1706 / Pagination.php
Last active May 31, 2017
PHP pagination class
View Pagination.php
<?php
class Pagination
{
public $page;
public $totalCount;
public $perPage;
public $hasNext;
public $hasPrev;
@absent1706
absent1706 / cells.less
Created May 24, 2017
LESS mkedia objects (.cell)
View cells.less
.fulltable {
display: table;
width: 100%;
}
/* See bootstrap's media.less for code that inspired this one*/
& {
@_padding: 10px;
@_padding-thin: 5px;
@_padding-thick: 20px;
@absent1706
absent1706 / 2-lines-ellipsis.html
Created May 23, 2017
css 2-line ellipsis with gradient example
View 2-lines-ellipsis.html
<style>
.relative {
position: relative;
}
.absolute-rightbottom {
position: absolute;
right: 0;
bottom: 0;
}
View mediabody-oneline-fix.less
/*
* If you have
* .oneline {
* overflow: hidden;
* white-space: nowrap;
* text-overflow: ellipsis
* }
*
* inside Bootstrap's .media-body, i.g.:
*
You can’t perform that action at this time.