Skip to content

Instantly share code, notes, and snippets.

View ypsilon-p's full-sized avatar

Yannik Preiß ypsilon-p

  • Cologne
View GitHub Profile
@ncou
ncou / interval.js
Created April 17, 2016 21:38 — forked from jasdeepkhalsa/interval.js
setTimeout and setInterval with pause and resume
// http://stackoverflow.com/questions/7279567/how-do-i-pause-a-window-setinterval-in-javascript
function RecurringTimer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@jakebellacera
jakebellacera / ICS.php
Last active April 19, 2024 09:06
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*