Skip to content

Instantly share code, notes, and snippets.

View bohman's full-sized avatar

Linus Bohman bohman

View GitHub Profile
@bohman
bohman / gist:9526448
Last active August 29, 2015 13:57
example on how to modify queries with filters in wordpress
//---------------------------------
// Modify these taxonomy pages to show all posts
// and sort them alphabetically
//---------------------------------
add_filter('posts_orderby', 'mashcat_alphabetical');
add_filter('post_limits', 'mashcat_limits');
function mashcat_alphabetical($orderby) {
if(!is_admin() && (is_tax('foreign-apis') || is_tax('api-tags') || is_tax('mashup-tags'))) {
input[data-onoff]:empty {
margin-left: -9999px;
}
input[data-onoff]:empty ~ label {
position: relative;
float: left;
height: 22px;
line-height: 22px;
text-indent: 50px;
@bohman
bohman / css.css
Created November 3, 2014 07:13
When SASS becomes a sledgehammer for a nail
/* This is a shorter way to do it with css */
[class*="btn"] {
min-width: 100px;
padding: 1em;
border-radius: 1em;
}
.btn--twitter {
color: #fff;
background: #55acee;
}
@bohman
bohman / .gitignore_global
Created December 5, 2014 12:33
My global gitignore. Kept here for reference.
# Compiled source #
###################
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
@bohman
bohman / htmlstrip.js
Created May 11, 2011 11:00
Just a small thing I wanted to show someone else. I dislike it, because it's bad.
.replace(/<(?:.|\s)*?>/g, '')
.replace(/&auml;/gi, 'ä')
.replace(/&Auml;/gi, 'Ä')
.replace(/&ouml;/gi, 'ö')
.replace(/&Ouml;/gi, 'Ö')
.replace(/&aring;/gi, 'å')
.replace(/&Aring;/gi, 'Å')
.replace(/&amp;/gi, '&')
.replace(/&rdquo;/gi, '\"')
.replace(/&quot;/gi, '\"')
@bohman
bohman / getdb.sh
Created March 20, 2012 10:23
Database dump script
#!/usr/bin/env bash
# Remote database credentials
RDBNAME=""
RDBUSER=""
RDBPASS=""
# Local database credentials
LDBNAME=""
LDBUSER=""
@bohman
bohman / gist:2844242
Last active October 5, 2015 17:28
Random sharing thingies if you only want to use links
<a target="_blank" href="https://twitter.com/intent/tweet?text=YOUR-TITLE&url=YOUR-URL&via=TWITTER-HANDLE">Tweet</a>
<a target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=YOUR-URL">Share on Facebook</a>
<a target="_blank" href="https://plus.google.com/share?url=YOUR-URL">Plus on Google+</a>
<a target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url=YOUR-URL&title=YOUR-TITLE&summary=YOUR-SUMMARY&source=YOUR-URL">Share on LinkedIn</a>
<a target="_blank" href="http://pinterest.com/pin/create/button/?url=YOUR-URL&description=YOUR-DESCRIPTION&media=YOUR-IMAGE-SRC">Pin on Pinterest</a>
@bohman
bohman / sort_array_on_value.php
Created September 12, 2012 07:29
sort_array_on_value() - sorting multidimensional arrays into hyperspace
//
// Easy lil' sorting thingamajig. Mad creds to Antonio Navarro of 040.
//
function sort_array_on_value($array_to_sort, $sort_on_value, $descending = false) {
$sortArr = array();
foreach ($array_to_sort as $key => $value) {
$sortArr[$key] = $value[$sort_on_value];
}
@bohman
bohman / stretch.css
Last active December 11, 2015 02:19
Stretch: simple way to stretch boxes to edge of screen without additional elements. Here's a good article with description: http://css-tricks.com/full-browser-width-bars/
.center {
width: 980px;
margin-left: auto;
margin-right: auto;
}
html, body {
overflow-x: hidden; /* Prevents horizontal scroll */
}
@bohman
bohman / wp_update_url.sql
Created January 16, 2013 16:04
Simple query to update URLs in a WP install. Useful when moving a site. Wrote it a long time ago, lost it when my computer got stolen, was frustrated, decided to store it here.
SET @oldurl = 'dev1.nollfyranoll.se';
SET @newurl = 'pilgrimsvagen.se';
UPDATE wp_posts SET POST_CONTENT = replace(POST_CONTENT, @oldurl, @newurl);
UPDATE wp_posts SET GUID = replace(GUID, @oldurl, @newurl);
UPDATE wp_options SET OPTION_VALUE = replace(OPTION_VALUE, @oldurl, @newurl);