Skip to content

Instantly share code, notes, and snippets.

@pascalmaddin
pascalmaddin / bash_profile_colors
Created February 7, 2014 14:04
prompt colors for .bash_profile
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
@pascalmaddin
pascalmaddin / terminal-prompt
Created February 7, 2014 14:05
my terminal prompt
# change prompt
export PS1=$'\n\[\033[0;36m\]\u\[\033[0m\]: \[\033[1;33m\]\w\[\033[0m\] \n\xe2\x86\x92 '
@pascalmaddin
pascalmaddin / svg-with.png-fallback.js
Created May 28, 2014 07:15
Fallback für svg-Grafiken mit Modernizr
if(!Modernizr.svg) {
$('img[src$="svg"]').attr('src', function() {
return $(this).attr('src').replace('.svg', '.png');
});
}
@pascalmaddin
pascalmaddin / consolelog.js
Created June 2, 2014 12:25
This tiny bit of code will help you identify where the logging is being called from. The nice thing is it works in the browser and in node. Source: http://remysharp.com/2014/05/23/where-is-that-console-log/
['log', 'warn'].forEach(function(method) {
var old = console[method];
console[method] = function() {
var stack = (new Error()).stack.split(/\n/);
// Chrome includes a single "Error" line, FF doesn't.
if (stack[0].indexOf('Error') === 0) {
stack = stack.slice(1);
}
var args = [].slice.apply(arguments).concat([stack[1].trim()]);
return old.apply(console, args);
@pascalmaddin
pascalmaddin / get_posts_from_category.php
Created June 23, 2014 13:16
WordPress: get posts from category (including some args)
query_posts( array( 'category__and' => array($cat_id), 'posts_per_page' => 1, 'orderby' => 'rand' ) );
while (have_posts()) : the_post();
// show stuff here
endwhile;
wp_reset_query();
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
// _config.scss
$base-font-size: 16px;
$support-legacy: true;
@mixin rem($value, $base: $base-font-size) {
@pascalmaddin
pascalmaddin / sharing.html
Created October 16, 2014 14:49
Simple Social Media Sharing Links without Third Party Javascript in WordPress
<!-- Twitter -->
<a href="https://twitter.com/home?status=Your%20custom%20tweet%20with%20blanks.">Share on Twitter</a>
<a href="https://twitter.com/home?status=Check%20out%20this%20article%20by%20@ikalli:%20<?php the_title(); ?> <?php the_permalink(); ?>">Share on Twitter</a>
<!-- Facebook -->
<a href="https://www.facebook.com/sharer/sharer.php?u=http://mydomain.com/articletitle">Share on Facebook</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>">Share on Facebook</a>
<img src="small.jpg" srcset="small.jpg [smallwidth]w, large.jpg [largewidth]w" alt="Alt Text" />
@pascalmaddin
pascalmaddin / countTo.js
Last active August 29, 2015 14:09
jQuery Plugin für das hochzählen einer Zahl bis zu einem numerischen Ziel
(function($) {
$.fn.countTo = function(options) {
// merge the default plugin settings with the custom options
options = $.extend({}, $.fn.countTo.defaults, options || {});
// how many times to update the value, and how much to increment the value on each update
var loops = Math.ceil(options.speed / options.refreshInterval),
increment = (options.to - options.from) / loops;
return $(this).each(function() {
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {