Skip to content

Instantly share code, notes, and snippets.

@mlbd
mlbd / How to detect if a WordPress plugin is active.php
Created November 19, 2017 13:02 — forked from llgruff/How to detect if a WordPress plugin is active.php
A function you can use to check if plugin is active/loaded for your plugins/themes
<?php
/**
* Detect if a WordPress plugin is active
* A function you can use to check if plugin is active/loaded for your plugins/themes
* @link //gist.github.com/llgruff/c5666bfeded5de69b1aa424aa80cc14f
*/
// When coding plugins that rely on another one, like Private Content for bbPress or Visual Attributes for WooCommerce, you need to make if the WordPress Plugin is active to initialize your plugin routines or display a notice saying that the required plugin must be activated. In this tutorial we’ll see how to detect whether a certain plugin is active in a couple of ways.
## 1. Check whether a certain class or function or constant exists
@pcuenca
pcuenca / openelm-coreml.py
Created April 30, 2024 09:55
Convert OpenELM to Core ML (float32)
import argparse
import numpy as np
import torch
import torch.nn as nn
import coremltools as ct
from transformers import AutoTokenizer, AutoModelForCausalLM
# When using float16, all predicted logits are 0. To be debugged.
compute_precision = ct.precision.FLOAT32
compute_units = ct.ComputeUnit.CPU_ONLY
@sindresorhus
sindresorhus / esm-package.md
Last active May 1, 2024 07:18
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@SorenSaket
SorenSaket / main.odin
Last active May 1, 2024 07:17
GLFW, OpenGL Window Tutorial in Odin language
// GLFW and OpenGL example with very verbose comments and links to documentation for learning
// By Soren Saket
// semi-colons ; are not requied in odin
//
// Every Odin script belongs to a package
// Define the package with the package [packageName] statement
// The main package name is reserved for the program entry point package
// You cannot have two different packages in the same directory

GitHub pages deployment using SSH keys

  1. Create a GitHub workflow file;

    mkdir .github
    mkdir .github/worflows
    touch ci.yml
@noghartt
noghartt / cc.md
Last active May 1, 2024 07:14
Resources to learn more about Computer Science and related stuffs
@antonshilov
antonshilov / NullableExtensions.kt
Last active May 1, 2024 07:11
Kotlin extension function for nullable types to cast them to non-null or get a default value
/**
* Kotlin extension function for nullable types to cast them to non-null or get a default value
*/
public inline fun <T> T?.or(default: T): T = this ?: default
@hectorzin
hectorzin / synchronize_todo_list.yaml
Last active May 1, 2024 07:11
Synchronize 2 Home Assistant todo list
blueprint:
name: "Synchronize 2 Home Assistant todo list"
description:
This blueprint for Home Assistant synchronizes 2 to-do lists. Originally designed to sync Google Keep lists with the Bring shopping list, its versatility allows syncing any list. Currently limited to syncing only active items, those marked as completed are removed from the lists
source_url: https://gist.github.com/hectorzin/53f9811ff2d6a673af9ff3a9801df7af
domain: automation
input:
google_list:
name: List 1
description: Select your first list to synchronize
@adityaprakashgupta
adityaprakashgupta / country.py
Created August 9, 2020 10:48
All Countries
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai