Skip to content

Instantly share code, notes, and snippets.

@urre
urre / gist:27bf9b1e16fa32195cc0
Created January 14, 2015 15:21
Simple web scraper in Node
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var superagent = require('superagent');
var jazzgreats = [];
var url = 'https://codex.wordpress.org/WordPress_Versions';
request(url, function(error, response, html) {
if(!error){
@urre
urre / gist:44f6c6d87cc3c201122f
Created January 9, 2015 20:22
WordPress: Get posts from multisite sites (not main site)
<?php
$sites = wp_get_sites();
foreach($sites as $site) :
// Only subsites
if (!is_main_site($site['blog_id'])) :
// Connect to new multisite
@urre
urre / keybase.md
Last active August 29, 2015 14:12
keybase.md

Keybase proof

I hereby claim:

  • I am urre on github.
  • I am urre (https://keybase.io/urre) on keybase.
  • I have a public key whose fingerprint is 763F 83B9 51FA 118E DE95 9888 0B47 509B 6056 2DE2

To claim this, I am signing this object:

@urre
urre / gist:846b89237da760839b3d
Last active January 5, 2021 21:26
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'
@urre
urre / gist:30523173fb22e3a375fa
Created October 27, 2014 13:44
Slick.js slider with thumbnails
$('.specs__slider').slick({
dots: true,
centerMode: true,
focusOnSelect: true,
arrows: false,
customPaging: function(slider, i) {
return '<div class="thumbnails">' +$(slider.$slides[i]).find('img').prop('outerHTML')+ '</div>';
}
});
@urre
urre / devtabs.sh
Last active August 29, 2015 14:06
Simple example dev setup which opens separate tabs in iTerm for different tasks/runners/servers
#!/bin/bash
# **************************************************************************************
#
# Devtabs
#
# Simple example dev setup which opens separate tabs in iTerm for different tasks/runners/servers
# @urre 140715
#
# **************************************************************************************
@urre
urre / Comment regex
Created July 23, 2014 08:48
Regex for finding comments in source code
# Regex for finding comments in source code
(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(//.*)
/**
* Finds this
*/
// And this
@urre
urre / unsplash.sh
Created June 19, 2014 09:06
Fetch image urls from unsplash.com
#!/bin/bash
# **************************************************************************************
#
# Fetch image urls from Unsplash.com
# by @urre
#
# **************************************************************************************
# JSON with 100 images from unsplash.com
@urre
urre / supertumblr.html
Created June 2, 2014 15:03
Tumblr theme for getsuperprints.tumblr.com
<!DOCTYPE html>
<html lang="{block:English}en{/block:English}{block:French}fr{/block:French}{block:German}de{/block:German}{block:Japanese}ja{/block:Japanese}{block:Italian}it{/block:Italian}{block:Spanish}es{/block:Spanish}{block:Polish}pl{/block:Polish}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="nofollow" />
<meta name="robots" content="noindex" />
@urre
urre / bem-scss.md
Created May 27, 2014 10:15
BEM and SCSS

BEM

Advantages of using BEM syntax for CSS are:

  1. Design of the website can change at any time, we must be ready for this HTML/CSS code is developing together with the design, ready to its changes
  2. Programmer and front-end developers are working together on the website codebase, contributing to each other's code
  3. Our CSS classes are easier for other team members to understand as they can easily identify the components in the HTML and also the purpose of the CSS classes.
  4. As classes are prefixed with the block it reduces the likelihood of accidentally having two classes with the same name, useful for larger projects.
  5. Using a naming convention gives your CSS and HTML more consistency making it easier to share code between projects.