Skip to content

Instantly share code, notes, and snippets.

@proxpero
proxpero / Iso369_1.swift
Created March 19, 2018 13:18
A Swift 4.0 enum representing ISO 639-1 codes (used to classify languages)
// taken 2018-03-19 from wikipedia. https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
public enum Iso639_1: String {
case ab = "AB"
case aa = "AA"
case af = "AF"
case ak = "AK"
case sq = "SQ"
case am = "AM"
case ar = "AR"
@johnnyw
johnnyw / SKActionTransitionColor.swift
Created February 23, 2018 07:44
[SpriteKit] Custom SKAction to transition the fill/stroke color of an SKShapeNode.
import CoreGraphics
import SpriteKit
extension SKAction {
static func transitionStrokeColor(from: SKColor, to: SKColor, duration: TimeInterval) -> SKAction {
return transitionColor(from: from, to: to, duration: duration, fill: false)
}
static func transitionFillColor(from: SKColor, to: SKColor, duration: TimeInterval) -> SKAction {
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 15, 2024 16:08
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@easaw
easaw / woo-check-if-has-shipping-class.php
Created August 26, 2017 00:43
Check if the Woocommerce cart has product with a certain Shipping Class
/**
* From https://isabelcastillo.com/woocommerce-check-shipping-class
* Check if the cart has product with a certain Shipping Class
* @param string $slug the shipping class slug to check for
* @return bool true if a product with the Shipping Class is found in cart
*/
function cart_has_product_with_shipping_class( $slug ) {
global $woocommerce;
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by [email protected] on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
@fxm90
fxm90 / UIColor+Initializers.swift
Last active August 11, 2020 08:45
Create UIColor from RGB, RGBA, Hex or Hex-String ("#ffffff")
public extension UIColor {
/// Create color from RGB(A)
///
/// Parameters:
/// - absoluteRed: Red value (between 0 - 255)
/// - green: Green value (between 0 - 255)
/// - blue: Blue value (between 0 - 255)
/// - alpha: Blue value (between 0 - 255)
///
@CodeMyUI
CodeMyUI / css-rain-effect.markdown
Created October 24, 2016 06:30
CSS Rain Effect

CSS Rain Effect

Looks best with a taller window/layout.

Rain drop elements animate down the screen, stem element inside animates to disappear toward the end of the drop's fall, splat element animates after the stem disappears.

JavaScript used to randomly position drop elements across the screen, slightly randomize their animation duration and delay, and also stagger their top position. Randomizing delay makes sure the drops don't fall in one sheet, randomizing duration keeps them from falling in the same constant synchronization. Staggering top position makes it so the splats don't fall in a single line.

Splatters are unfortunately disabled by default as it is rather intensive and significantly lowers framerate on most machines (in Chrome that is--FireFox and Edge are smoother actually). You can hit the splat toggle to turn it on. The effect is achieved by putting a dotted border-top on an ellipse element, and animating it from scale(0) to scale(1). You can get a better look at it by enabli

@khanlou
khanlou / Fonts.swift
Created October 6, 2016 21:10
Print all fonts in Swift 3
UIFont.familyNames.forEach({ familyName in
let fontNames = UIFont.fontNames(forFamilyName: familyName)
print(familyName, fontNames)
})
@contemplate
contemplate / functions.php
Last active May 14, 2024 23:46
WooCommerce - Allow guest checkout for certain products when Guest checkout is Disabled globally
/*--------------------------------------
Woocommerce - Allow Guest Checkout on Certain products
----------------------------------------*/
// Display Guest Checkout Field
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
@carlynorama
carlynorama / dictionary_sorting.swift
Last active April 10, 2021 04:31
One line sorting of dictionaries Swift 2.1, both by key and by value examples.
let myDictionary = [
"20" : "banna",
"60" : "apple",
"30" : "cucumber",
"10" : "starfruit"
]
//assume that sort() kinda takes 2 arguments i.e. sort(dictionary element a, dictionary element b)
//woriking its way down the array (http://www.sorting-algorithms.com/bubble-sort)
//compare the 0th assumed parameter(a) with the 1st assumed parameter (b), using the key (0 after decimal)