Skip to content

Instantly share code, notes, and snippets.

Wilkins Fernandez qwertypants

View GitHub Profile
View popup.js
/**
* 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 / is-it-loaded-yet.js
Created Aug 25, 2015
Fire an event when an window property is ready to be used. This assumes that an external script will add the new property on the window object.
View is-it-loaded-yet.js
// This uses Google tracking as an example
var interval = setInterval(function () {
console.log('searching..')
if (window._gaq) {
_gaq.push(['_trackPageview', 'Something']);
clearInterval(interval);
console.log('stop');
}
}, 10);
View galileo_getIPAddress.ino
void setup() {
system("telnetd -l /bin/sh");
system("echo setup > /dev/ttyGS0");
}
void loop() {
// Original code that prints out all data:
// system("ifconfig eth0 > /dev/ttyGS0");
// Modified code to search for "inet addr" and print out the address
system("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' > /dev/ttyGS0");
// Sleep is used here like the "delay" function to continuously print out the address for us.
@qwertypants
qwertypants / just-say-no...nicely
Last active Aug 29, 2015
Just say no, nicely. A default response to email recruiters.
View just-say-no...nicely
Thank you for considering me for this role.
Unfortunately, I am not looking for any new opportunities at the moment.
I'll be sure to pass this along to anyone I run into that would fit this position.
Respectfully,
<name>
@qwertypants
qwertypants / async-social.js
Created Jun 11, 2012
Inspired by http://socialitejs.com/, asynchronously load twitter/facebook scripts based on event
View async-social.js
$(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
Generate prime numbres
View gist:2655710
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 Oct 3, 2015
CSS Media Queries template
View mediaQueries.css
/* source: all over the interwebz */
/*------------------------ Smartphones ------------------------ */
/* Portrait & Landscape */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* styles */
}
/* Landscape */
View jQueryUI_shell.html
<!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 Jul 20, 2011
Add ellipsis to any text. Choose amount of words to show.
View ellipsis.js
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 Jun 15, 2011
Super tiny JS loader
View loadjs.js
// {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") {
You can’t perform that action at this time.