Skip to content

Instantly share code, notes, and snippets.

View xewl's full-sized avatar
👁️‍🗨️

Ken Verhaegen xewl

👁️‍🗨️
View GitHub Profile
@groggu
groggu / nsCountryCpdes.php
Created October 12, 2015 20:06
Convert standard ISO country codes to NetSuite's constants
/***
* Convert standard ISO country codes to NetSuite's world
*
* @param $isoCode
*
* @return string|bool
*/
public function convertCountryCode($isoCode)
{
@maschill92
maschill92 / demos.cfg
Last active December 27, 2022 20:08
A CS:GO config file to make watching demos much easier.
//----------------------------- MISC -------------------------------\\
//------------------------------------------------------------------\\
sv_cheats "1"
sv_showimpacts "0"
sv_showimpacts_time "2.5"
//---------------------------- BINDS -------------------------------\\
//------------------------------------------------------------------\\
bind "SPACE" "demo_togglepause" // pause/play demo
bind "c" "r_cleardecals" // get rid of bulletholes and black residue from grenade explosions
@humantorch
humantorch / http_accept_language.php
Last active February 26, 2021 21:37
Compare supported languages with HTTP_ACCEPT_LANGUAGE in a users' browser.
<?php
// Languages we support
$available_languages = array("zh-cn", "ca", "es", "fr", "af","nl", "sp", "en");
$default_language = "en"; // a default language to fall back to in case there's no match
function prefered_language($available_languages, $http_accept_language) {
global $default_language;
$available_languages = array_flip($available_languages);
@zackkatz
zackkatz / maybe-parse-json.js
Last active July 13, 2020 21:25
WordPress admin-ajax.php JSON parser - Parse JSON string that may contain HTML elements before the output. See https://katz.co/?p=7671
/**
* Parse JSON string that may contain HTML elements - requires jQuery
*
* @param {string} string JSON text to attempt to parse
* @returns {object} Either JSON-parsed object or object with a message key containing an error message
*/
function maybe_parse_json( string ) {
var json_object;
// Parse valid JSON
@cluppi
cluppi / after.sh
Created March 19, 2015 19:01
Turning SSL on for Homestead
#!/bin/sh
# Config for SSL.
echo "--- Making SSL Directory ---"
mkdir /etc/nginx/ssl
echo "--- Copying $i SSL crt and key ---"
openssl req -nodes -new -x509 -keyout /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.crt -subj "/C=US/ST=NY/L=NYC/O=Dis/CN=www.example.com"
echo "--- Turning SSL on in nginx.conf. ---"
@trslater
trslater / custom-registration.php
Last active May 12, 2020 13:47
Custom Registration Plugin
<?php
/*
Plugin Name: Custom Registration
Description: Updates user rating based on number of posts.
Version: 1.1
Author: Tristan Slater w/ Agbonghama Collins
Author URI: http://kanso.ca
*/
@p3t3r67x0
p3t3r67x0 / pseudo_elements.md
Last active February 25, 2025 22:27
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
<?php
/**
* Get the file size of any remote resource (using get_headers()),
* either in bytes or - default - as human-readable formatted string.
*
* @author Stephan Schmitz <[email protected]>
* @license MIT <http://eyecatchup.mit-license.org/>
* @url <https://gist.github.com/eyecatchup/f26300ffd7e50a92bc4d>
*
* @param string $url Takes the remote object's URL.
@kane-c
kane-c / woocommerce-force-shipping-pickup.php
Created July 23, 2014 05:40
WordPress WooCommerce: Force local pickup as the only shipping option when products in the cart require it.
<?php
// Force pickup as a shipping option if one or more products in the catalog is marked as pickup only.
// To do this, add a shipping class with the slug 'pickup-only' then set products with that class as required.
// Add this script to your theme's functions.php or similar.
function hideShippingWhenPickupRequired($rates, $package)
{
foreach ($package['contents'] as $item) {
$product = $item['data'];
$shippingClass = $product->get_shipping_class();
@christiaanwesterbeek
christiaanwesterbeek / splitsAdres.js
Last active March 30, 2025 22:47
Splitsen van een nederlands adres naar straat, huisnummer en toevoeging middels een regular expression. Deutsch-Adressen werden jetzt auch unterstützt.
let re = /^(\d*[\wäöüß\d '\/\\\-\.]+)[,\s]+(\d+)\s*([\wäöüß\d\-\/]*)$/i
let adressen = [
'Dorpstraat 2',
'Dorpstr. 2',
'Laan 1933 2',
'18 Septemberplein 12',
'Kerkstraat 42-f3',
'Kerk straat 2b',
'42nd street, 1337a',
'1e Constantijn Huigensstraat 9b',