Skip to content

Instantly share code, notes, and snippets.

@codekraft-studio
codekraft-studio / limit-words.filter.coffee
Created June 30, 2017 12:22
Angular filter to limit words count in a string
'use strict'
###*
# @ngdoc filter
# @name app.filter:limitWords
# @description Angular filter to limit words count in a string
# # limitWords
###
angular.module 'app'
.filter 'limitWords', ->
@codekraft-studio
codekraft-studio / .htaccess
Last active February 24, 2017 12:02
Force https with htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
@codekraft-studio
codekraft-studio / media-queries.scss
Last active November 17, 2017 13:43
A list of the most used media queries as sass variables.
/**
* Sass-Ready media queries
* Here there are some presets of useful
* media queries breakpoints for various devices
* Usage: @media #{variable-name} { }
* and it will compile to: @media variable-name { }
*
*/
// Devices
@codekraft-studio
codekraft-studio / wp-default.css
Last active October 5, 2016 07:48
A collection of WordPress default generated classes.
/****************************************************
* WP CSS - body_class() *
* The classes generated with body_class() function *
****************************************************/
.rtl {}
.home {}
.blog {}
.archive {}
.date {}
@codekraft-studio
codekraft-studio / wp_term_back_to_parent.php
Last active July 28, 2016 16:06
WordPress function to print a back button to the first term ancestor
/**
* Print a back button to the first term ancestor
*/
function wp_term_back_to_parent($id = null, $args = array()) {
if( !$id ) {
$id = get_query_var('cat');
}
// get term ancestors
@codekraft-studio
codekraft-studio / wp_build_sitemap.php
Last active April 22, 2019 10:12
A comprehensive sitemap generation for WordPress.
<?php
/**
* Suggested default use:
* add_action("publish_post", "wp_build_sitemap");
* add_action("publish_page", "wp_build_sitemap");
* add_action( "save_post", "wp_build_sitemap" );
*
* or manually with arguments: wp_build_sitemap( array('priority' => 1) );
*
@codekraft-studio
codekraft-studio / parsecsv.js
Last active August 7, 2016 09:35
javascript function to parse csv string into array of objects (demo: http://www.codekraft.it/demos/parsecsv)
/**
* Parse a csv string to array of objects
* optionally enclosed by quotes
* delimited by user selectable character
*/
function parseCSV(string, delimiter) {
var lines = string.split(/\r\n|\n/), // get all the lines
colnames = [], // the columns names array
result = []; // the result array