Skip to content

Instantly share code, notes, and snippets.

@mouthoftiger
mouthoftiger / gist:fc9a5be2b6b675e53799e5685e2da72c
Created December 3, 2020 02:36
disable WordPress and woocommerce default image sizes
/* tested with WordPress 5.53 & WooCommerce 4.7.1*/
function disable_image_sizes($sizes) {
unset($sizes['small']);
unset($sizes['medium']);
unset($sizes['large']);
unset($sizes['medium_large']);
unset($sizes['1536x1536']);
unset($sizes['2048x2048']);
For this answer, I refer to querySelector and querySelectorAll as querySelector* and to getElementById, getElementsByClassName, getElementsByTagName, and getElementsByName as getElement*.
Main Differences
querySelector* is more flexible, as you can pass it any CSS3 selector, not just simple ones for id, tag, or class.
The performance of querySelector* changes with the size of the DOM that it is invoked on. To be precise, querySelector* calls run in O(n) time and getElement* calls run in O(1) time, where n is the total number of all children of the element or document it is invoked on. This fact seems to be the least well-known, so I am bolding it.
getElement* calls return direct references to the DOM, whereas querySelector* internally makes copies of the selected elements before returning references to them. These are referred to as "live" and "static" elements. This is NOT strictly related to the types that they return. There is no way I know of to tell if an element is live or static programmatically, as
@mouthoftiger
mouthoftiger / tensorflow-wavenet errors
Last active July 31, 2019 23:16
tensorflow-wavenet
W0731 18:11:18.638053 8228 deprecation.py:506]
model.py:27: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
@mouthoftiger
mouthoftiger / SampleRNN
Last active July 31, 2019 23:35
SampleRNN
https://github.com/richardassar/SampleRNN_torch (torch version)
https://github.com/soroushmehr/sampleRNN_ICLR2017
<template>
<div id="homepage">
<h1>Les dernières Articles</h1>
<div class="article" v-for="article in articles">
<h2> {{ article.title }} </h2>
<p> {{ article.content }} </p>
</div>
</div>
</template>
The latest stable release is available on PyPI, and you can install it by saying
pip install librosa
Anaconda users can install using conda-forge:
conda install -c conda-forge librosa
To build librosa from source, say python setup.py build. Then, to install librosa, say python setup.py install. If all went well, you should be able to execute the demo scripts under examples/ (OS X users should follow the installation guide given below).
Alternatively, you can download or clone the repository and use pip to handle dependencies:
@mouthoftiger
mouthoftiger / gist:90a173ad905f8e7991074e2b0bdb9a5d
Created May 28, 2019 15:21
Dynamic CSS in WordPress with Advanced Custom Fields
/* Typography
--------------------------*/
body {
color:<?php the_field('default_text_color','option');?>;
font-size:<?php the_field('default_font_size','option');?>px;
font-family:<?php the_field('default_text_font_family','option');?>;
line-height:<?php the_field('default_text_line_height','option');?>;
}
h1,h2,h3,h4,h5,h6 {
import argparse
import sys
import fnmatch
import os
import numpy as np
import librosa
from sklearn.manifold import TSNE
import json
@mouthoftiger
mouthoftiger / gist:34ff425fd2d0839c690c46651c6c0493
Created February 13, 2019 15:46
Python Script to resize all the images, on a given directory, to a 1024x768 JPEG format.
#!/usr/bin/env python
""PIL""
import Image
import os, sys
def resizeImage(infile, output_dir="", size=(1024,768)):
outfile = os.path.splitext(infile)[0]+"_resized"
extension = os.path.splitext(infile)[1]
@mouthoftiger
mouthoftiger / gettyscrape.py
Created January 23, 2019 18:38
getty scraper
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from bs4 import BeautifulSoup
from urllib import urlretrieve
import os
import Tkinter, Tkconstants, tkFileDialog
import time