Skip to content

Instantly share code, notes, and snippets.

View siamkreative's full-sized avatar

Julien Vernet siamkreative

View GitHub Profile
@siamkreative
siamkreative / sublime_key_bindings.json
Created June 21, 2016 05:22
Sublime Text 3 Key Bindings
[{
"keys": ["f12"],
"command": "chain",
"args": {
"commands": [
["reindent", {
"single_line": false,
"detect_indentation": false,
"tab_size": 4,
"translate_tabs_to_spaces": true
@siamkreative
siamkreative / README.md
Last active January 9, 2017 06:10
Boostrap 4 Navbar Fixed to top. Placement using JavaScript

What Is This?

This is for the fixed to top version of the Boostrap 4 navbar. Instead of setting the padding and top position in CSS, let's use JavaScript to get it dynamically.

How To Use?

It is best to use the pure JavaScript version. It will be executed earlier since it does not require jQuery to be loaded. The vanilla JavaScript version can be used in the <head> section.

If you are a performance concerned developer, your scripts are probably in the footer just before </body>. Therefore, there might be a slight delay before the jQuery snippet is executed. This can lead to elements jumping around...

@siamkreative
siamkreative / ga-snippet.html
Created January 30, 2017 02:36
Google Analytics sample code snippet
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
@siamkreative
siamkreative / tinyMCE-check.js
Created November 28, 2014 09:12
A simple script to check whether TinyMCE is active and visible in WordPress Dashboard
jQuery(document).ready(function ($) {
'use strict';
/*
References
http://codeblow.com/questions/method-to-check-whether-tinymce-is-active-in-wordpress/
https://wordpress.org/support/topic/tinymceactiveeditorgetcontentcontent-does-not-work-with-tinymce-advanced
*/
```php
<?php
// Specific style for iPhone
if( $detect->isiOS() && !$detect->isTablet() ) {
// This fixes position of the bottom bar on iOS 12.4 and above
echo "<style type='text/css'>#nm5viewBtmHolder { position: fixed; bottom: 0; width: 100%; }</style>";
}
?>
@siamkreative
siamkreative / as_customisations.js
Created February 4, 2016 03:34
Example of customisations for Awesome Support: Adding custom fields and conditional logic
jQuery(document).ready(function ($) {
/**
* Get URL Parameters using jQuery
* http://stackoverflow.com/a/21903119
*/
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
@siamkreative
siamkreative / building-cordova-apps-fedora-31-draft.md
Created January 31, 2020 04:38
Building Cordova apps on Fedora 31

Installing and configuring Docker

Install Docker

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf makecache
sudo dnf install docker-ce

Install Docker-Compose

@siamkreative
siamkreative / cf7-horizontal-form.html
Last active July 14, 2020 23:58
Contact Form 7 Horizontal Form
<div class="form-horizontal">
<div class="form-group"><label class="control-label col-md-3">Full Name</label><div class="col-md-9">[text* your-name class:form-control]</div></div>
<div class="form-group"><label class="control-label col-md-3">Email Address</label><div class="col-md-9">[email* your-email class:form-control]</div></div>
<div class="form-group"><label class="control-label col-md-3">Subject</label><div class="col-md-9">[text your-subject class:form-control]</div></div>
<div class="form-group"><label class="control-label col-md-3">Message</label><div class="col-md-9">[textarea your-message x5 class:form-control]</div></div>
<div class="form-group"><div class="col-md-offset-3 col-md-9">[submit class:btn class:btn-primary "Send"]</div></div>
</div>
@siamkreative
siamkreative / pluginLoaded.js
Created March 4, 2016 04:36
Check if a jQuery plugin is loaded. If not, load it using the $.getScript() function.
jQuery(document).ready(function ($) {
'use strict';
function initModal() {
$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
@siamkreative
siamkreative / editorEmptyCheck.js
Created March 28, 2016 03:42
Check if a TinyMCE editor is empty in WordPress
jQuery(document).ready(function ($) {
// Check if TinyMCE is active
if (typeof tinyMCE != "undefined") {
$('form').on('submit', function () {
// Get content of active editor
var editorContent = tinyMCE.activeEditor.getContent();
if ((editorContent === '' || editorContent === null)) {
// Do stuff when TinyMCE is empty
}