Skip to content

Instantly share code, notes, and snippets.

View JonathanSchndr's full-sized avatar
work smart, not hard

Jonathan Schneider JonathanSchndr

work smart, not hard
View GitHub Profile
@rigwild
rigwild / aes.js
Last active April 6, 2023 04:42
Easily encrypt string or object using Crypto-JS AES encryption
'use strict'
const password = 'secure secret key'
const encrypt = (content, password) => CryptoJS.AES.encrypt(JSON.stringify({ content }), password).toString()
const decrypt = (crypted, password) => JSON.parse(CryptoJS.AES.decrypt(crypted, password).toString(CryptoJS.enc.Utf8)).content
// Encrypt
const encryptedString = encrypt('This is a string', password)
const encryptedObject = encrypt({ test: 'This is an object' }, password)
@schmidt1024
schmidt1024 / svg.js
Created June 3, 2015 13:59
Replace all SVG images with inline SVG using jQuery
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@PadreZippo
PadreZippo / embed.html
Last active September 30, 2023 17:10
iframes with constant aspect ratios
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<!-- This iframe will always fill the parent width, but will remain at 16:9 aspect ratio -->
<div class="ratio-16-9">
<iframe class="ratio-inner" src="https://sketchfab.com/models/{{model_id}}/embed"></iframe>
@kouphax
kouphax / encoded_fonts.edn
Last active December 26, 2023 12:36
font awesome fonts -> base64 encoded data uri -> edn/sql
{"fa-adjust" "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEUAAABQCAYAAABPlrgBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAACARJREFUeJztnHtsFNcZxc+5u9jmoTogWnv9XptCY6hoVbW0TRUqpJBETaOoCCSUKm1pI0X8EUUkFSnYjBYb8kBIRWmFAlKiRKQgQlpRSkTVKqRUbXFU2obwKGB2edi7mFKTFgzG3p3TP8CEhx93dnd215V/f3lmvu+7Z4/Xd+beO9fAGGOMMcYYvsJcNRRzaktKXM4WArMFTQdQS6IMQimo8QIMxX5Blwl2A+oEGIXBESL1t/LI6dMElAutvpkigOec+ply8RiI+ZDmgCzKoF6CwnsidhfT7J4aaf9vNvXeStZNOf18zeRxRYHvS1hCcla26wMAhF5AO2m4qTwS3Zvtb1DWTDm/oiaUDASWA3wSxIRs1R0R4SDlrikPnNrBCNxslMzYlMSzZRPdCRN/QmIZgPFZ0JQewj8ILgu1nNybaamMTEk44Ufk8ucgajIVkjWkrTR8JhSJnk+3RFqmdDmNk1Lq3QBgSboN+4mgf0n4YVVLbFc6+Z5N6Wiqm2GM2QlgRjoN5hJJ6ypMzQpG/pD0kufJlE6nbj5cvk3yU97k5Q9Je4p6ixZ9et2xS7Y51qYkVoUXusBbBMelJy+f6IDbV/xg1Yv//LdNtJUpiaa6RS7NVhImI2mAKHwoqM0QH4mMATgvpC7TDWwG8Y1M6o/Q+EG3v2iejTEjmhJvrn9Y0K9JBtPWI70v8k0yuKsycvzCoO2sqt8D4MF027DSAbSBV+dVRhJXhosb9oMmmhpmunC3p2OIBBfUFjLwUuXq9iNe8/2AwBxp/JtysGi4B70hP2z38vrSq8bdSXCS18YlvR8Qny5viX3kNddvCCyIu+HngdjaoWIG7SMEsLdIGwk2eGzzKoCnKlpi88pbowVnyCewpbO5/r6hrg5q
@minwe
minwe / shake.event.js
Created March 31, 2014 07:21
Detect a shake in iOS Safari with Javascript
// See this awesome blog post: http://www.jeffreyharrell.com/blog/2010/11/creating-a-shake-event-in-mobile-safari/
if (typeof window.DeviceMotionEvent != 'undefined') {
// Shake sensitivity (a lower number is more)
var sensitivity = 20;
// Position variables
var x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
@gerbenvandijk
gerbenvandijk / Mark parent navigation active when on custom post type single page
Last active January 1, 2024 21:22
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
@zenman
zenman / snippet.php
Last active October 2, 2018 11:55
Archives by Category
<?php
/*
Plugin Name: Archives for a category
Plugin URI: http://kwebble.com/blog/2007_08_15/archives_for_a_category
Description: Adds a cat parameter to wp_get_archives() to limit the posts used to generate the archive links to one or more categories.
Author: Rob Schlüter
Author URI: http://kwebble.com/
Version: 1.4b
Copyright
@markmarkoh
markmarkoh / gist:2969317
Created June 21, 2012 23:55
World Map Geo JSON data
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@scribu
scribu / gist:906872
Created April 7, 2011 01:21
'price' sortable column example
<?php
// Register the column
function price_column_register( $columns ) {
$columns['price'] = __( 'Price', 'my-plugin' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'price_column_register' );

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables