Skip to content

Instantly share code, notes, and snippets.

View Vimos's full-sized avatar

Vimos Tan Vimos

View GitHub Profile
how to fix sound archlinux asus c302ca
1. `dsp_fw_release.bin` has to point to `/lib/firmware/intel/dsp_fw_release_v969.bin`
2. in `/usr/share/alsa/ucm/sklnau8825max`:
## `HiFi.conf`
```
@f1recracker
f1recracker / focal_loss.py
Last active September 3, 2023 09:11
PyTorch implementation of focal loss that is drop-in compatible with torch.nn.CrossEntropyLoss
# pylint: disable=arguments-differ
import torch
import torch.nn as nn
import torch.nn.functional as F
class FocalLoss(nn.CrossEntropyLoss):
''' Focal loss for classification tasks on imbalanced datasets '''
@yjzhang
yjzhang / download-medline-data.sh
Created February 1, 2019 23:01
Download all medline citations from ncbi
#!/bin/bash
# downloads all MEDLINE/Pubmed citations in the annual baseline.
for i in $(seq 1 972); do
fname="1"
if ((i < 10)); then
fname="ftp://ftp.ncbi.nlm.nih.gov/pubmed/baseline/pubmed19n000$i.xml.gz"
elif ((i < 100)); then
fname="ftp://ftp.ncbi.nlm.nih.gov/pubmed/baseline/pubmed19n00$i.xml.gz"
@turambar
turambar / KerasModelImportExample.java
Last active July 10, 2018 07:58
Examples of DL4J's Keras model import syntax (assumes Keras Functional API models and DL4J ComputationGraph)
package org.deeplearning4j.nn.modelimport.keras;
import org.deeplearning4j.nn.api.Layer;
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
import org.deeplearning4j.nn.graph.ComputationGraph;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@christopherlovell
christopherlovell / display.py
Last active November 18, 2023 22:22
display youtube video in jupyter notebook
from IPython.display import HTML
# Youtube
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/S_f2qV2_U00?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>')
# Vimeo
HTML('<iframe src="https://player.vimeo.com/video/26763844?title=0&byline=0&portrait=0" width="700" height="394" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe><p><a href="https://vimeo.com/26763844">BAXTER DURY - CLAIRE (Dir Cut)</a> from <a href="https://vimeo.com/dannysangra">Danny Sangra</a> on <a href="https://vimeo.com">Vimeo</a>.</p>')
@renshuki
renshuki / ubuntu_agnoster_install.md
Last active December 30, 2024 16:16
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@m00nlight
m00nlight / gist:1f226777a49cfc40ed8f
Last active March 7, 2022 12:24
Python range minimum query
import sys
import itertools
class RMQ:
def __init__(self, n):
self.sz = 1
self.inf = (1 << 31) - 1
while self.sz <= n: self.sz = self.sz << 1
self.dat = [self.inf] * (2 * self.sz - 1)
@lauris
lauris / fix_django_timezones.sh
Created August 15, 2014 16:21
Fix Django timezones issue: "Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your database and pytz installed?"
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
@hideaki-t
hideaki-t / unzip.py
Created May 18, 2014 07:34
unzipping a zip file with non-utf8 encoding by Python3
import zipfile
import sys
from pathlib import Path
def unzip(f, encoding, v):
with zipfile.ZipFile(f) as z:
for i in z.namelist():
n = Path(i.encode('cp437').decode(encoding))
if v:
@andrequeiroz
andrequeiroz / holtwinters.py
Last active February 3, 2025 04:35
Implementation of Holt-Winters algorithms in Python 2
#The MIT License (MIT)
#
#Copyright (c) 2015 Andre Queiroz
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions: