Skip to content

Instantly share code, notes, and snippets.

View jgoslow's full-sized avatar

Jonas Goslow jgoslow

View GitHub Profile
@jgoslow
jgoslow / permissions_ssh.bash
Last active June 9, 2016 17:45
Here are some things you can do with Gists in GistBox.
Default:
find * -type d -exec chmod 755 {} \;
find * -type f -exec chmod 644 {} \;
For Groups:
find * -type d -exec chmod 775 {} \;
find * -type f -exec chmod 664 {} \;
@jgoslow
jgoslow / scroll-to-div.jquery
Last active August 13, 2022 18:00
JS Scrolling functions
function scrollToDiv(target) {
var loc = $(target).offset();
jQuery("html,body").animate({
scrollTop: loc.top-150//,
//scrollLeft: loc.left
});
return false;
}
@jgoslow
jgoslow / format-params-object-to-url.js
Last active August 13, 2022 18:13
URL javascript functions
function formatParamsObjectToURL( params ){
return "?" + Object
.keys(params)
.map(function(key){
return key+"="+encodeURIComponent(params[key])
})
.join("&")
}
@jgoslow
jgoslow / delete-cookie.js
Last active August 13, 2022 17:50
Cookie JS Functions
@jgoslow
jgoslow / Limit String Length - end of word
Last active September 29, 2018 22:42
Limits the length of a string but ensures you end on a word
// javascript word cut
function cut(n) {
return function textCutter(i, text) {
var short = text.substr(0, n);
if (/^\S/.test(text.substr(n)))
return short.replace(/\s+\S*$/, "");
return short;
};
}
@jgoslow
jgoslow / lyra-modal-mixin.scss
Last active August 13, 2022 17:49
Lyra Modal SCSS Mixin
//Modal styles - mostly based on Bootstrap
@mixin modal() {
position: fixed;
pointer-events: none;
opacity: 0;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
@jgoslow
jgoslow / custom-excerpt-length.php
Last active August 13, 2022 18:09
Wordpress Excerpt PHP Functions
/**
* Filter the except length to 20 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
@jgoslow
jgoslow / scrollbar.css
Created May 2, 2020 17:13
How to style scrollbars in CSS (May 2020)
/* Coursey of https://alligator.io/css/css-scrollbars */
/* The emerging W3C standard
that is currently Firefox-only */
* {
scrollbar-width: thin;
scrollbar-color: blue orange;
}
/* Works on Chrome/Edge/Safari */
@jgoslow
jgoslow / terminal-cors-test.js
Last active August 13, 2022 17:46
cors scripts
function corsTest(url) {
console.log("cors-test");
var http = new XMLHttpRequest();
http.open('GET', url, true);
http.onreadystatechange = function() {//Call a function when the state changes.
console.log(http.responseText)
}
@jgoslow
jgoslow / throttle.js
Created August 13, 2022 18:02
Throttle and Debounce JS Functions
/**
* Debounce Function
* to reduce # of events fired
* example: Scroll listeners
*/
function debounce(callback, interval) {
let debounceTimeoutId;
return function(...args) {
clearTimeout(debounceTimeoutId);