Skip to content

Instantly share code, notes, and snippets.

//source: http://www.dangayle.com/import-feeds-wordpress-fetch-feed/
function custom_rss($feedUrl = 'http://wordpress.org/news/feed/'){
include_once(ABSPATH . WPINC . '/rss.php');
$feed = $feedUrl;
$rss = fetch_feed($feed);
if (!is_wp_error( $rss ) ) :
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
@jq-87
jq-87 / Reached_the_bottom.js
Created December 2, 2013 16:43
Detect when scroll position is at the bottom of page
$(window).scroll(function(){
var pageHeight = $(document).height(),
windowHeight = $(window).height(),
topDistance = $(document).scrollTop();
if( pageHeight - topDistance == windowHeight) {
//load more content now
console.log('reached the bottom');
@jq-87
jq-87 / even-rows.scss
Created March 11, 2014 16:53
even rows (4 column)
&:nth-child(4n + 1):nth-last-child(2),
&:nth-child(4n + 2):nth-last-child(1) {
width: 49%
}
&:nth-child(4n + 1):nth-last-child(3),
&:nth-child(4n + 2):nth-last-child(2),
&:nth-child(4n + 3):nth-last-child(1) {
width: 33.24%;
}
@jq-87
jq-87 / _box-settings.scss
Created October 5, 2014 21:29
3d box with sass map
//colors
$turquoise: #1abc9c;
$amethyst: #9b59b6;
$silver: #bdc3c7;
$emerland: #2ecc71;
$white: white;
$black: black;
//dimensions
$size: 100px;
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
{
"vscode_custom_css.imports": [],
"editor.fontFamily": "Monaco",
"editor.lineHeight": 24,
"editor.fontLigatures": true,
"explorer.decorations.badges": false,
"window.zoomLevel": 1,
"editor.fontSize": 14,
"editor.tabCompletion": true,
"editor.minimap.showSlider": "always",
@jq-87
jq-87 / vscode_keybinding.json
Created September 21, 2017 15:15
VScode custom key shortcuts
[
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
},
{
"key": "ctrl+1",
"command": "-workbench.action.openEditorAtIndex1"
},
{
@jq-87
jq-87 / scss.json
Created September 29, 2017 18:16
SCSS vscode snippet
{
"Sass Breakpoint": {
"prefix": "bp",
"body": [
"@include bp($1){",
"\t$2",
"}"
],
"description": "Breakpoint mixin"
},
(function(w, d, s) {
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s);
j.async = true;
j.src = '//mysite.com/myscript.js';
f.parentNode.insertBefore(j, f);
})(window, document, 'script');
@jq-87
jq-87 / tryFn.js
Created February 13, 2019 19:03
safely get an object property
const tryFn = (fn, fallback = null) => {
try {
return fn()
} catch (error) {
return fallback
}
}
const favoriteBook = tryFn(() => favorites.reading.book[0])