Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home I guess

James Futhey kidGodzilla

🏠
Working from home I guess
View GitHub Profile
@kidGodzilla
kidGodzilla / random-name.js
Created Nov 12, 2018
Generate a random name in adj-noun format as a placeholder (aquatic ninja, calculating banjo, etc.)
View random-name.js
function randomName () {
var adjectives = "aback,abaft,abandoned,abashed,aberrant,abhorrent,abiding,abject,ablaze,able,abnormal,aboard,aboriginal,abortive,abounding,abrasive,abrupt,absent,absorbed,absorbing,abstracted,absurd,abundant,abusive,acceptable,accessible,accidental,accurate,acid,acidic,acoustic,acrid,actually,adHoc,adamant,adaptable,addicted,adhesive,adjoining,adorable,adventurous,afraid,aggressive,agonizing,agreeable,ahead,ajar,alcoholic,alert,alike,alive,alleged,alluring,aloof,amazing,ambiguous,ambitious,amuck,amused,amusing,ancient,angry,animated,annoyed,annoying,anxious,apathetic,aquatic,aromatic,arrogant,ashamed,aspiring,assorted,astonishing,attractive,auspicious,automatic,available,average,awake,aware,awesome,awful,axiomatic,bad,barbarous,bashful,bawdy,beautiful,befitting,belligerent,beneficial,bent,berserk,best,better,bewildered,big,billowy,bite-Sized,bitter,bizarre,black,black-And-White,bloody,blue,blue-Eyed,blushing,boiling,boorish,bored,boring,bouncy,boundless,brainy,brash,brave,brawny,
@kidGodzilla
kidGodzilla / hide-idle-cursor.js
Created Nov 12, 2018
Hide Idle Cursor until mousemove after 5s delay
View hide-idle-cursor.js
$(function () {
$(document).mousemove(function () {
$('html, body').css({ cursor: 'default' });
clearTimeout(window.ttimer);
window.ttimer = setTimeout(function () {
$('html, body').css({ cursor: 'none' });
}, 5000)
});
});
@kidGodzilla
kidGodzilla / alphanumeric-lookup.js
Last active Aug 14, 2017
Generates an Alphabetic or Alphanumeric index lookup
View alphanumeric-lookup.js
// Build an alphabetic / alphanumeric index lookup
// Scales three characters deep
// Should work for any int up to i = 143,364 when alphabetic (object-safe keys) Math.pow(s.length, 3) + Math.pow(s.length, 2) + s.length
// This can be scaled further by extending s to include digits, characters, etc. (242,234 if alphanumeric)
function generateLookup (length) {
var s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Alphabetic
// var s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; // Alphanumeric
var lookup = [];
View mailthisto-ajax-example.js
// The following example POSTS data to mailthis.to, redirects the user to a confirmation page, and then sends an email (upon the successful completion of Recaptcha verification)
$.post('https://mailthis.to/test@example.com', {
email: 'foo@bar.co',
_subject: 'hi!',
message: 'Test'
}).then(function () {
location.href = 'https://mailthis.to/confirm'
});
View mailthisto-example.html
<form action="https://mailthis.to/example" method="POST" encType="multipart/form-data">
<h3>Contact Form (example)</h3>
<!-- Name -->
<input type="email" name="name" placeholder="Your name">
<!-- Email -->
<input type="email" name="email" placeholder="you@mail.com">
<!-- Phone Number -->
<input type="text" name="phone" placeholder="+1 (255) 555-5555">
<!-- Textarea (Message) -->
<textarea name="message" placeholder="Enter your message here" style="height:90px"></textarea>
View image-optimizer.js
$('img').each(function () {
var w = $(this).width();
var h = $(this).height();
var nw = $(this).prop('naturalWidth');
var nh = $(this).prop('naturalHeight');
var s = $(this).attr('src') || $(this).attr('_src');
if (s.indexOf('://') === -1) {
var pn = location.pathname;
pn = pn.split('/');
View smallchat-embed-refactored.html
<script>
(function() {
window.Smallchat = {
config: {
"slackTeamId": "T4Z8BNW22",
"scChannelId": "-Ki28NFzPezMcBRn19Da",
"slackChannelId": "G51S6B4J3",
"uid": "-Ki28DCbmqvLWP7mK_93"
},
appearance: {
View keybase.md

Keybase proof

I hereby claim:

  • I am kidgodzilla on github.
  • I am futhey (https://keybase.io/futhey) on keybase.
  • I have a public key whose fingerprint is E65C 7E23 BD6C 2A14 3559 AD07 A364 DD33 53CC AD03

To claim this, I am signing this object:

View simple-primes.js
// ES5 :)
function isPrime (n) {
for (i = 2; i < n; i++)
if (n % i === 0) return false
return true
}
// ES6 (readable)
isPrime = n => { for (i = 2; i < n; i++) if (n % i === 0) return false; return true }
@kidGodzilla
kidGodzilla / raf-performance-checking.js
Created Aug 4, 2016
Using requestAnimationFrame() for performance checking
View raf-performance-checking.js
/**
* Performance Checking
*
* Will enable and disable a flag on the window object
* When Javascript performance suffers, so that optional features
* Can be Disabled or delayed
*/
(function () {
var lastTimestamp = + new Date();
You can’t perform that action at this time.