Skip to content

Instantly share code, notes, and snippets.

View Cafnio's full-sized avatar

Nuno C Cafnio

  • Portugal
View GitHub Profile
@Cafnio
Cafnio / CountryToCode.cs
Last active October 25, 2019 10:29
(C#) Class to Convert Country To ISO-3166 alpha 2 code and Vice-Versa
public class CountryToCode
{
Dictionary<string, string> allCountries = new Dictionary<string, string>
{
{ "BD", "Bangladesh" },
{ "BE", "Belgium"},
{ "BF", "Burkina Faso"},
{ "BG", "Bulgaria"},
{ "BA", "Bosnia and Herzegovina"},
{ "BB", "Barbados"},
@Cafnio
Cafnio / .js
Last active May 8, 2019 17:48
Wordpress fixed widget bar with Jquery
jQuery( document ).ready(function() {
var fixmeTop = 100; // get initial position of the element
jQuery(window).scroll(function() { // assign scroll event listener
var distanceBottom = jQuery(document).height() - (jQuery(document).scrollTop() + jQuery(window).height());
var currentScroll = jQuery(window).scrollTop(); // get current position
if (currentScroll >= fixmeTop && distanceBottom > 540) { // apply position: fixed if you
jQuery('#secondary').css({ // scroll to that element or below it
@Cafnio
Cafnio / countryISO.js
Last active June 4, 2019 08:39
Find country by iso code
var countries = [
{ key: "BD", value: "Bangladesh" },
{ key: "BE", value: "Belgium" },
{ key: "BF", value: "Burkina Faso" },
{ key: "BG", value: "Bulgaria" },
{ key: "BA", value: "Bosnia and Herzegovina" },
{ key: "BB", value: "Barbados" },
{ key: "WF", value: "Wallis and Futuna" },
{ key: "BL", value: "Saint Barthelemy" },
{ key: "BM", value: "Bermuda" },
@Cafnio
Cafnio / list.text
Created October 25, 2019 10:30
Council List Portugal ( Lista de Concelhos)
Abrantes
Águeda
Aguiar da Beira
Alandroal
Albergaria-a-Velha
Albufeira
Alcácer do Sal
Alcanena
Alcobaça
Alcochete
@Cafnio
Cafnio / functions.php
Last active June 19, 2020 15:06
WooCommerce: Deny Automatic Login Upon Registration (Specific Roles)
//Add the following content to functions.php
function filter_woocommerce_registration_auth_new_customer( $true, $newWserId ) {
$roles = get_userdata( $newWserId )->roles;
if ( !in_array( 'customer', $roles )) {
return false;
}
return $true;
};
export const LIST_COUNTRIES: string[] = ["Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bosnia and Herzegovina", "Barbados", "Wallis and Futuna", "Saint Barthelemy", "Bermuda", "Brunei", "Bolivia", "Bahrain", "Burundi", "Benin", "Bhutan", "Jamaica", "Bouvet Island", "Botswana", "Samoa", "Bonaire, Saint Eustatius and Saba ", "Brazil", "Bahamas", "Jersey", "Belarus", "Belize", "Russia", "Rwanda", "Serbia", "East Timor", "Reunion", "Turkmenistan", "Tajikistan", "Romania", "Tokelau", "Guinea-Bissau", "Guam", "Guatemala", "South Georgia and the South Sandwich Islands", "Greece", "Equatorial Guinea", "Guadeloupe", "Japan", "Guyana", "Guernsey", "French Guiana", "Georgia", "Grenada", "United Kingdom", "Gabon", "El Salvador", "Guinea", "Gambia", "Greenland", "Gibraltar", "Ghana", "Oman", "Tunisia", "Jordan", "Croatia", "Haiti", "Hungary", "Hong Kong", "Honduras", "Heard Island and McDonald Islands", "Venezuela", "Puerto Rico", "Palestinian Territory", "Palau", "Portugal", "Svalbard and Jan Mayen", "Paraguay",