Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ricardo Sánchez ricardodsanchez

🏠
Working from home
View GitHub Profile
@ricardodsanchez
ricardodsanchez / settings.json
Created Mar 27, 2020
Basic VS Code settings
View settings.json
{
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"files.autoSave": "afterDelay",
"files.associations": {
"*.md": "markdown"
},
"window.zoomLevel": 0,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
@ricardodsanchez
ricardodsanchez / tasks.json
Created Mar 18, 2019
VS Code: Open file in browser task - MacOS
View tasks.json
{
"version": "0.1.0",
"command": "Chrome",
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": ["${file}"]
}
@ricardodsanchez
ricardodsanchez / getFrequency
Created Oct 2, 2014
Get frequency of words in a string and return the list of them ordered by most frequent first
View getFrequency
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 / consolelog.min.js
Created Aug 19, 2014
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.
View consolelog.min.js
window.log = function () { log.history = log.history || []; log.history.push(arguments); if (this.console) { console.log(Array.prototype.slice.call(arguments)) } };
@ricardodsanchez
ricardodsanchez / countries-continents-ISO-3166-codes
Created Aug 19, 2014
SQL Script to create tables with country names, continent names and ISO-3166 codes.
View countries-continents-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 / Create-Symbolic-Link
Created Aug 19, 2014
Create symbolic links in Windows
View Create-Symbolic-Link
@ricardodsanchez
ricardodsanchez / WordCount
Last active Aug 29, 2015
Count the number of words in a text editor, text box or text area and display total number of words as you type
View WordCount
$('#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);
});