Skip to content

Instantly share code, notes, and snippets.

View klarstil's full-sized avatar
🏠
Working from home

Stephan Pohl klarstil

🏠
Working from home
View GitHub Profile
@klarstil
klarstil / feature-detection.js
Last active December 12, 2015 04:28
Simple feature detection
/**
* Tests if a property has a vendor prefix and returns the properly
* property.
*
* @param {string} prop - Property to test
* @param {string} propGroup - Group where the test property is located
* @returns {*} If the property was found, it will be returned. Otherwise false
* @private
*/
var _getVendorPrefix = function(prop, propGroup) {
@klarstil
klarstil / uninstall.sh
Created April 5, 2013 06:40
Uninstall git on Mac OS X
#!/bin/bash
if [ ! -r "/usr/local/git" ]; then
echo "Git doesn't appear to be installed via this installer. Aborting"
exit 1
fi
echo "This will uninstall git by removing /usr/local/git/**/*, /etc/paths.d/git, /etc/manpaths.d/git"
printf "Type 'yes' if you sure you wish to continue: "
read response
if [ "$response" == "yes" ]; then
sudo rm -rf /usr/local/git/
@klarstil
klarstil / style.css
Last active December 15, 2015 22:59
Truncate text using CSS
.is-truncate {
width: 250px; /** Adjust width to your needs */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@klarstil
klarstil / jquery.counter.js
Last active December 17, 2015 13:38
Simple counter
;(function ( $, window, document, undefined ) {
"use strict";
var pluginName = 'timer',
defaults = {
'baseCls': 'timer',
'separator': ' ',
'date': new Date("6 7, 2013 10:0:0")
};
@klarstil
klarstil / install-twig-bundle-sublime.sh
Created May 22, 2013 06:44
Auto-Installation command which installs the Twig Bundle from @Anomareh for Sublime 2
git clone https://github.com/Anomareh/PHP-Twig.tmbundle.git && mkdir ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Twig/ && mv PHP-Twig.tmbundle* ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Twig/
@klarstil
klarstil / jquery.star-rating.js
Last active September 11, 2018 16:11
Simple star rating
;(function ( $, window, document, undefined ) {
"use strict";
var pluginName = 'starRating', _lastActive = -1,
defaults = {
baseCls: 'star-rating',
activeCls: 'is-active',
hoverCls: 'is-hover',
nonInteractiveCls: 'is-non-interactive'
};
@klarstil
klarstil / format-string.js
Created July 1, 2013 11:16
Simple method which fills out the placeholders in a string
/**
* Formats a string and replaces the placeholders.
*
* @example format('<div class="%0"'>%1</div>, [value for %0], [value for %1], ...)
*
* @param {String} str
* @param {Mixed}
* @returns {String}
*/
var format = function (str) {
@klarstil
klarstil / hex2rgb.js
Created July 1, 2013 11:17
Simple method which converts a hex string (6 chars) to an array with rgb values
/**
* Private helper method which parses an hex string to a rgb.
*
* @param hexStr
* @returns {Array}
*/
var hex2rgb = function(hexStr) {
var hex = parseInt(hexStr.substring(1), 16),
r = (hex & 0xff0000) >> 16,
g = (hex & 0x00ff00) >> 8,
;(function($) {
/**
* Formats a given number (or number as a string)
*
* @param {Number|String} num
* @param {Object} [userOpts] User configuration
* @returns {String|Boolean}
*/
var formatNumber = function(num, userOpts) {
var defaults = {
@klarstil
klarstil / dot-animation.js
Created July 10, 2013 10:06
Simple dot animation
;(function($) {
var flashingDots = function(el) {
var dots = el.data('default-value') || el.html(),
i = 0;
if(!el.data('default-value')) {
el.data('default-value', el.html());
}
return {
el: el,