Skip to content

Instantly share code, notes, and snippets.

View acemir's full-sized avatar
🥁
Tocando o terror 🔊🎵🎶

Acemir Sousa Mendes acemir

🥁
Tocando o terror 🔊🎵🎶
View GitHub Profile
@acemir
acemir / MyRequestsCompleted.js
Last active March 21, 2016 07:59
Waits multiple ajax calls response
var MyRequestsCompleted = (function() {
var numRequestToComplete, requestsCompleted, callBacks, singleCallBack;
return function(options) {
if (!options) options = {};
numRequestToComplete = options.numRequest || 0;
requestsCompleted = options.requestsCompleted || 0;
callBacks = [];
var fireCallbacks = function() {
@acemir
acemir / gist:49ab59e6392008ec3eb2eb0f2ff1eb80
Created November 16, 2017 02:16
Covert line endings of all files in folder to Unix format
find ./ -type f -exec dos2unix {} \;
@acemir
acemir / countVisibleWords.js
Last active May 30, 2018 19:52
countVisibleWords
function countVisibleWords(el){
var padding, em, numChars, numWords;
var text = $(el).text();
var textArr = text.split(' ');
var max = el.clientHeight;
var tmp = document.createElement(el.tagName.toLowerCase());
tmp.className = el.className + " -temp";
// document.body.appendChild(tmp);
@acemir
acemir / gist:204612360042109a33e1d372761ad877
Created June 29, 2018 16:05
Match literal \r\n and trasform to <p></p>
// Match literal \r and literal \n
'<p>' + (str || '').split(/(?:\\[rn])+/g).join('</p><p>') + '</p>';
// Match all carriage returns \r, newlines \n and also literal \r and literal \n
'<p>' + (str || '').split(/(?:\\[rn]|[\r\n]+)+/g).join('</p><p>') + '</p>';