Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃

Mike Clark wassname

🙃
View GitHub Profile
@wassname
wassname / keras_weighted_categorical_crossentropy.py
Last active Oct 21, 2021
Keras weighted categorical_crossentropy
View keras_weighted_categorical_crossentropy.py
"""
A weighted version of categorical_crossentropy for keras (2.0.6). This lets you apply a weight to unbalanced classes.
@url: https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d
@author: wassname
"""
from keras import backend as K
def weighted_categorical_crossentropy(weights):
"""
A weighted version of keras.objectives.categorical_crossentropy
View LG Smart-TV Blocklist Adlist (for PiHole)
127.0.0.1 us.rdx2.lgtvsdp.com
127.0.0.1 us.info.lgsmartad.com
127.0.0.1 us.ibs.lgappstv.com
127.0.0.1 us.lgtvsdp.com
127.0.0.1 ad.lgappstv.com
127.0.0.1 smartshare.lgtvsdp.com
127.0.0.1 ibis.lgappstv.com
# added after fork
# from https://www.reddit.com/r/pihole/comments/6qmpv6/blacklists_for_lg_webos_tvs/ and others
@wassname
wassname / simple_transformer.py
Last active Sep 22, 2021
Transformer in ~80 lines of code from Thomas Wolf's tweet https://twitter.com/Thom_Wolf/status/1129658539142766592
View simple_transformer.py
"""
Transformer in ~80 lines of code.
From Thomas Wolf's tweet https://twitter.com/Thom_Wolf/status/1129658539142766592.
"""
import torch
from torch import nn
class Transformer(nn.Module):
View exercise.md

Exercise

Description:

  1. first
  2. second
@wassname
wassname / pdshow.py
Last active Sep 22, 2021
show a pandas data frame in full
View pdshow.py
from IPython.display import display
import pandas as pd
def pdshow(df):
"""
This shows a pandas dataframe in full/
Also consider .to_html() and https://pbpython.com/dataframe-gui-overview.html
@wassname
wassname / linux_x380.md
Last active Sep 20, 2021
xubuntu on a Thinkpad Yoga x380
View linux_x380.md

This are a collection of fixes and tweaks I used to get Xubuntu 18.04 LTS working on a lenovo thinkpad X380 yoga laptop.

@wassname
wassname / to_filename.py
Last active Aug 31, 2021
python convert string to safe filename
View to_filename.py
"""
Url: https://gist.github.com/wassname/1393c4a57cfcbf03641dbc31886123b8
"""
import unicodedata
import string
valid_filename_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
char_limit = 255
def clean_filename(filename, whitelist=valid_filename_chars, replace=' '):
View Samsung Smart-TV Blocklist Adlist (for PiHole)
# This is a blocklist to block samsung smart tv's sending meta data at home.
# Please help to collect domains!
# It could be that the TV does not receive any more updates or other services no longer work. Please report such an incident.
abtauthprd.samsungcloudsolution.com
acr0.samsungcloudsolution.com
ad.samsungadhub.com
ads.samsungads.com
amauthprd.samsungcloudsolution.com
api-hub.samsungyosemite.com
@wassname
wassname / CausalConv2d.py
Created Jul 25, 2018
pytorch Causal Conv2d
View CausalConv2d.py
from torch.nn.modules.utils import _pair
class CausalConv2d(nn.Conv2d):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=None, dilation=1, groups=1, bias=True):
kernel_size = _pair(kernel_size)
stride = _pair(stride)
dilation = _pair(dilation)
if padding is None:
padding = [int((kernel_size[i] -1) * dilation[i]) for i in range(len(kernel_size))]
@wassname
wassname / aws_keepassxc.md
Created Sep 1, 2020
How to use keepassxc and browser integration with aws console sign's
View aws_keepassxc.md

For your IAM user you get a csv of credentials like this

User name,Password,Access key ID,Secret access key,Console login link
USERNAME,PASSWORD,ACCESS_KEY,SECRET_KEY,https://0123456.signin.aws.amazon.com/console

If your region is sydney (ap-southeast-2) in keepass you enter:

Title: USERNAME/COMPANY