Skip to content

Instantly share code, notes, and snippets.

@MikelArnaiz
MikelArnaiz / config.xml
Created October 25, 2016 15:12
Ionic config.xml example with icon and splash screen paths
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.hello.world" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Hello World</name>
<description>
</description>
<author>
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
@MikelArnaiz
MikelArnaiz / gist:531d4a31780aad9c0c548ccb033092a3
Created November 7, 2016 11:22
Javascript regex to remove HTML comments
( |\t)*?<!--(.|\s)*?-->( |\t)*/gm
https://regex101.com/r/OraWn4/4
<!-- comment with whitespaces before tag --> <div>
<div> <!-- comment with whitespaces after tag -->aa
@MikelArnaiz
MikelArnaiz / betterCloak.js
Created November 25, 2016 09:59
A better ng-cloak angularjs directive. Hide elements until ng-hide and ng-show finish
angular.module('myApp')
.directive('betterCloak', function() {
return {
scope: {
'ngHide': '=',
'ngShow': '='
},
link: function(scope,element, attrs){
if (typeof scope.ngHide == 'undefined' && typeof scope.ngShow == 'undefined' || scope.ngHide === false || scope.ngShow === true) {
$(element).addClass('better-cloak-ready');
@MikelArnaiz
MikelArnaiz / gist:713b81ffdbb68ff836833760bbcf0a06
Created June 6, 2017 11:33
Random hex string / password node
require('crypto').randomBytes(64).toString('hex');
@MikelArnaiz
MikelArnaiz / 010_increment_build_numbers.js
Last active June 26, 2017 12:09
Cordova hook for incrementing build numbers. Increases only the platform you build
#!/usr/bin/env node
// Fork of:
// https://gist.github.com/ohh2ahh/f35ff6e0d9f8b4268cdb
// Save hook under `project-root/hooks/before_build/`
//
// Don't forget to install xml2js using npm
// `$ npm install xml2js`
@MikelArnaiz
MikelArnaiz / functions.php
Created August 11, 2017 14:19
How to add jQuery from CDN in Wordpress or how to disable jQuery
function disable_jQuery() {
if(!is_admin()){
wp_deregister_script('jquery');
}
}
function add_jQuery_from_cdn(){
if(!is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://code.jquery.com/jquery-2.2.4.min.js', null, null, true);
Keys with Dutch keyboard
' Apostrophe: right key of semicolon
" Quotation Mark: right key of semicolon+shift
‘ Left Single Quotation Mark: alt+[
“ Left Double Quotation Mark: alt+]
’ Right Single Quotation Mark: alt+shift+[
” Right Double Quotation Mark: alt+shift+]
´ Acute Accent: alt+e
` Grave Accent: left key of z
@MikelArnaiz
MikelArnaiz / getListOfType.ts
Last active June 5, 2020 15:45
Ensure getting an array with all items of a TypeScript type
/**
This util is a trick to ensure you get an array with all the elements of a type.
You have to pass an object with all the possible types as keys, and true as a value (arbitrarily chosen to be true)
*/
export const getListOfType = <A extends string>(obj: Record<A, true>): A[] => {
return keys(obj);
};
function keys<O extends object>(o: O): Array<keyof O> {
return Object.keys(o) as Array<keyof O>;
// https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
export enum TimeZoneOffset {
UTC_Minus_12_00 = '-12:00',
UTC_Minus_11_00 = '-11:00',
UTC_Minus_10_00 = '-10:00',
UTC_Minus_09_30 = '-09:30',
UTC_Minus_09_00 = '-09:00',
UTC_Minus_08_00 = '-08:00',
UTC_Minus_07_00 = '-07:00',
UTC_Minus_06_00 = '-06:00',
@MikelArnaiz
MikelArnaiz / sort.ts
Last active September 16, 2020 07:45
Sort compare curried function to access obj string properties values
// https://stackoverflow.com/a/61476921/1355416
type FilteredKeys<T, U> = { [P in keyof T]: T[P] extends U ? P : never }[keyof T]
const compareStrings = <T extends object>(key: FilteredKeys<T, string>) => (a: T, b: T): number => {
const valA = (a[key] as unknown) as string
const valB = (b[key] as unknown) as string
return valA.localeCompare(valB)
}