Skip to content

Instantly share code, notes, and snippets.

@broofa
broofa / checkForUndefinedCSSClasses.js
Last active Sep 30, 2022
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
View checkForUndefinedCSSClasses.js
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())
@davidmroth
davidmroth / compile_cpuminer-multi.sh
Last active Feb 25, 2021
Compile cpuminer-multi for Raspberry Pi
View compile_cpuminer-multi.sh
#!/bin/bash
#
# WARNING: CPU MINING IS UNPROFITABLE! (FOR HOBBY / EXPERIMENT / RESEARCH ONLY)
#
# RASPBERRY PI CPUMINER-MULTI SETUP SCRIPT
#
# RASPBERRY PI, DOGE, DOGECOIN, PROHASHING.COM, LITECOIN, MINING
#
@davidmroth
davidmroth / .bash_profile
Last active Nov 11, 2022
Homebrew Setup Mac M1
View .bash_profile
# !!! IMPORTANT
# Must point to the correct director or this entire script breaks
eval $(/opt/homebrew/bin/brew shellenv)
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/usr/local/google-cloud-sdk/path.bash.inc' ]; then . '/usr/local/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/usr/local/google-cloud-sdk/completion.bash.inc' ]; then . '/usr/local/google-cloud-sdk/completion.bash.inc'; fi
@jkutner
jkutner / atik-indi-phd2-raspbian-instructions.md
Last active Nov 18, 2022
Turn a Raspberry Pi into an Astrophotography Autoguider
View atik-indi-phd2-raspbian-instructions.md
@ricjcosme
ricjcosme / dump-restore
Created Sep 13, 2017
DUMP / RESTORE PostgreSQL Kubernetes
View dump-restore
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@tablekat
tablekat / main.ts
Created Jun 30, 2016
Making gmail push notifications to webhook
View main.ts
import * as request from 'request';
import * as fs from 'fs';
import * as readline from 'readline';
var google = require('googleapis');
var googleAuth = require('google-auth-library');
/*************** STEPS
- made a project on https://console.cloud.google.com/cloudpubsub/topicList?project=testmabs thing?
@mikejolley
mikejolley / functions.php
Last active Jul 29, 2022 — forked from claudiosanches/functions.php
WooCommerce - Hide shipping rates when free shipping is available.
View functions.php
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
@KorvinM
KorvinM / wp-supress-private-posts.php
Last active Jun 25, 2022
WordPress: Remove private posts from the main query on the posts page
View wp-supress-private-posts.php
<?php
/* We can use the pre_get_posts action hook to modify a query before it's run.
* http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts*/
add_action( 'pre_get_posts', 'kvn_rem_pp' );
function kvn_rem_pp($query){
if(current_user_can ('read_private_posts') ){
/*restrict to the posts page main query.
*All other views (eg. category archives) unnaffected
*http://codex.wordpress.org/Function_Reference/is_home
*http://codex.wordpress.org/Function_Reference/is_main_query*/
@touilleMan
touilleMan / SimpleHTTPServerWithUpload.py
Last active Nov 27, 2022 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload - Python3 version
View SimpleHTTPServerWithUpload.py
#!/usr/bin/env python3
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
see: https://gist.github.com/UniIsland/3346170
"""
@mlocati
mlocati / color-scale.js
Last active Nov 11, 2022
Javascript color scale from 0% to 100%, rendering it from red to yellow to green
View color-scale.js
// License: MIT - https://opensource.org/licenses/MIT
// Author: Michele Locati <michele@locati.it>
// Source: https://gist.github.com/mlocati/7210513
function perc2color(perc) {
var r, g, b = 0;
if(perc < 50) {
r = 255;
g = Math.round(5.1 * perc);
}
else {