Skip to content

Instantly share code, notes, and snippets.

View ricardodsanchez's full-sized avatar
🏠
Working from home

Ricardo Sánchez ricardodsanchez

🏠
Working from home
View GitHub Profile
@ricardodsanchez
ricardodsanchez / WordCount
Last active August 29, 2015 14:00
Count the number of words in a text editor, text box or text area and display total number of words as you type
$('#editor').keyup(function () {
typewatch(function () {
// executed only 500 ms after the last keyup event.
var words = $('#editor').html().toString().split(' ');
// get number of words
// add the value of words.length to a label, or other html element for displaying purposes as shown below
$('.word-count').text(words.length);
}, 500);
});
@ricardodsanchez
ricardodsanchez / Create-Symbolic-Link
Created August 19, 2014 13:13
Create symbolic links in Windows
@ricardodsanchez
ricardodsanchez / countries-continents-ISO-3166-codes
Created August 19, 2014 13:15
SQL Script to create tables with country names, continent names and ISO-3166 codes.
/**
* Country names, continent names and ISO-3166 codes.
*/
CREATE TABLE CONTINENTS (
CODE CHAR(2) NOT NULL, --'Continent code',
CONTINENT_NAME VARCHAR(255),
PRIMARY KEY (CODE)
);
-- Grant Access
@ricardodsanchez
ricardodsanchez / consolelog.min.js
Created August 19, 2014 13:16
This script lets you safely use console log in your web application. Some browsers will throw an error when you have console.log("something") if the developer tools/console window are not open. To avoid this JavaScript errors, use the following script which checks for the existence of the console before trying to use it.
window.log = function () { log.history = log.history || []; log.history.push(arguments); if (this.console) { console.log(Array.prototype.slice.call(arguments)) } };
@ricardodsanchez
ricardodsanchez / getFrequency
Created October 2, 2014 14:59
Get frequency of words in a string and return the list of them ordered by most frequent first
function getFrequency(string, cutOff) {
var cleanString = string.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g,""),
words = cleanString.split(' '),
frequencies = {},
word, frequency, i;
for( i=0; i<words.length; i++ ) {
word = words[i];
frequencies[word] = frequencies[word] || 0;
frequencies[word]++;
@ricardodsanchez
ricardodsanchez / tasks.json
Created March 18, 2019 16:42
VS Code: Open file in browser task - MacOS
{
"version": "0.1.0",
"command": "Chrome",
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": ["${file}"]
}
@ricardodsanchez
ricardodsanchez / settings.json
Created March 27, 2020 23:50
Basic VS Code settings
{
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"files.autoSave": "afterDelay",
"files.associations": {
"*.md": "markdown"
},
"window.zoomLevel": 0,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"