Skip to content

Instantly share code, notes, and snippets.

View scsskid's full-sized avatar
:octocat:

Benedikt Gregor scsskid

:octocat:
View GitHub Profile
//Font Smoothing
//src: http://maximilianhoffmann.com/posts/better-font-rendering-on-osx
@mixin font-smoothing($value: on) {
@if $value == on {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@else {
@scsskid
scsskid / js-debounce-and-throttle.js
Last active September 28, 2020 11:56
[Throttle Debounce] David Walsh
// src: https://davidwalsh.name/javascript-debounce-function
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
@scsskid
scsskid / window.open.js
Last active August 29, 2020 07:07
window.open with working CMD/ctrl key (open in new tab funcionality)
//src: https://davidwalsh.name/window-open
someElement.addEventListener('click', function(e) {
var url = someElement.get('data-url');
if(e.metaKey || e.ctrlKey || e.button === 1) {
window.open(url);
}
else {
window.location = url;
/**
* Convert font-size from px to rem with px fallback
*
* @param $size - the value in pixel you want to convert
*
* e.g. p {@include fontSize(12px);}
*
*/
// Function for converting a px based font-size to rem.
@scsskid
scsskid / css-visually-hidden.css
Created February 17, 2018 12:35
CSS: Visually hidden
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}
@mixin not($ignorList...) {
//if only a single value given
@if (length($ignorList) == 1){
//it is probably a list variable so set ignore list to the variable
$ignorList: nth($ignorList,1);
}
//set up an empty $notOutput variable
$notOutput: '';
//for each item in the list
@each $not in $ignorList {
@scsskid
scsskid / .htaccess
Last active April 27, 2018 20:23
Prevent File Caching src: https://stackoverflow.com/a/11724596
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
<?php
function addUrlParam($url, $param) {
$url_parts = parse_url($url);
parse_str($url_parts['query'], $params);
$params[$param[0]] = $param[1];
$url_parts['query'] = http_build_query($params);
//return http_build_url($url_parts); //pecl
return $url_parts['scheme'] . '://' . $url_parts['host'] . $url_parts['path'] . '?' . $url_parts['query'];
}
@mixin breakpoint($class) {
@if $class == xs {
@media (max-width: 767px) { @content; }
}
@else if $class == sm {
@media (min-width: 768px) { @content; }
}
@else if $class == md {
search/replace
Find what: ^\n
or
Find what: ^[\s]*?[\n\r]+
Replace With: (nothing, leave in blank).