Skip to content

Instantly share code, notes, and snippets.

View qwertypants's full-sized avatar
🧶

Wilkins Fernandez qwertypants

🧶
View GitHub Profile
const glob = require('glob');
const jsFiles = glob.sync('src/**/*.js');
const tsFiles = glob.sync('src/**/*.ts');
const tsxFiles = glob.sync('src/**/*.tsx');
const allTsFiles = tsFiles.concat(tsxFiles);
console.log(`There are ${jsFiles.length} .js files in the 'src' directory.`);
console.log(`There are ${allTsFiles.length} .ts/x files in the 'src' directory.`);
console.log(`${Math.round((allTsFiles.length / jsFiles.length) * 100)}% of the files are TypeScript files.`);
@qwertypants
qwertypants / popup.js
Created October 25, 2016 23:21
Popup window
/**
* Opens a new browser window
* @param {String} url The url of the window to open
* @param {String} name The name of this window
* @param {Number} width Window width
* @param {Number} height Window height */
const PopUpWindow = (url, name, width, height)=> {
// Center the window
let _width = width || 450,
_height = height || 300,
@qwertypants
qwertypants / async-social.js
Created June 11, 2012 20:14
Inspired by http://socialitejs.com/, asynchronously load twitter/facebook scripts based on event
$(function($) {
'use strict';
var srcs = {
twitter: {
id: 'Twitter',
get: function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
@qwertypants
qwertypants / gist:2655710
Created May 10, 2012 20:34
Generate prime numbres
function genPrimes(min, max){
var isPrime, primes = [];
for (var i = min; i <= max; i++) {
isPrime = true;
for (var j = min; j * j <= i; j++) {
if (i % j === 0) {
isPrime = false;
break;
}
}
@qwertypants
qwertypants / mediaQueries.css
Last active October 3, 2015 07:07
CSS Media Queries template
/* source: all over the interwebz */
/*------------------------ Smartphones ------------------------ */
/* Portrait & Landscape */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* styles */
}
/* Landscape */
@qwertypants
qwertypants / jQueryUI_shell.html
Created August 23, 2011 15:48
jQuery UI setup
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://static.jquery.com/ui/css/base2.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/blitzer/jquery-ui.css" type="text/css" media="all" />
<!--http://ajax.googleapis.com/ajax/libs/jqueryui/[UI.VERSION]/themes/[THEME-NAME]/jquery-ui.css-->
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
@qwertypants
qwertypants / ellipsis.js
Created July 20, 2011 18:25
Add ellipsis to any text. Choose amount of words to show.
function ellipsis(numOfWords, text, wordCount ) {
wordCount = text.trim().replace(/\s+/g, ' ').split(' ').length;
if(numOfWords <= 0 || numOfWords === wordCount){
return text;
} else {
text = text.trim().split(' ');
text.splice(numOfWords, wordCount, '...');
return text.join(' ');
}
}
@qwertypants
qwertypants / loadjs.js
Created June 15, 2011 17:25
Super tiny JS loader
// {Boolean} c Condition
// {String} f File name
var loadjs = function(c,f) {
var l = f.length;
if ( c && f.substring(l - 3, l) === ".js") {
var j = document.createElement('script');
j.type = 'text/javascript';
j.src = f;
j.async = false;
if (typeof j != "undefined") {
@qwertypants
qwertypants / appleIcons.html
Created February 5, 2011 20:44
Apple icons
<link rel="apple-touch-icon" href="touch-icon-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="touch-icon-iphone4.png" />
<!--src:http://bit.ly/gWFA6M-->
@qwertypants
qwertypants / jQueryLint.js
Created January 11, 2011 20:13 — forked from buzzedword/jQueryLint.js
jQuery lint bookmarklet
javascript:(function(){(function(){var el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px 10px 5px 10px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';function getLint(url){var script=document.createElement('script');script.src=url;var head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;}};head.appendChild(script);}function getScript(url,success){var script=document.createElement('script');script.src=url;var head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=