Skip to content

Instantly share code, notes, and snippets.

View jgoslow's full-sized avatar

Jonas Goslow jgoslow

View GitHub Profile
@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 / 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 / copy-Input-value-to-clipboard
Created August 13, 2022 18:16
Clipboard JS Helper Functions
function copyInputValueToClipboard(input) {
input.select();
document.execCommand("copy");
console.log(`${input.value} copied to clipboard!`)
}
@jgoslow
jgoslow / element-is-visible
Created August 13, 2022 18:18
Element In View JS Helper Functions
/**
* Check if Element is in View
*/
function elementIsVisible(el, offset) {
const rect = el.getBoundingClientRect();
return (
rect.top < window.innerHeight && rect.bottom - offset >= 0
);
}
@jgoslow
jgoslow / slack.reminder.snippet
Created October 5, 2022 17:01
Daily standup reminder snippet for Slack
/remind #channel “Time to post your Daily Update
Y: What you do yesterday?
T: What are you working on today?
B: Do you have any blockers?” at 10AM every weekday.