Skip to content

Instantly share code, notes, and snippets.

View jgoslow's full-sized avatar

Jonas Goslow jgoslow

View GitHub Profile
@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 / delete-cookie.js
Last active August 13, 2022 17:50
Cookie JS Functions
@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 / 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 / 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 {} \;