Skip to content

Instantly share code, notes, and snippets.

Ruben Martinez Jr. rubencodes

Block or report user

Report or block rubencodes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Pokemon.js
class Pokemon {
// This is where we'll store all Pokemon.
static all = [];
constructor(name, type, hp, def, atk, legend) {
// Check types of parameters.
const stringsOK = [name, type].every((item) => typeof item === 'string');
const numsOK = [hp, def, atk].every((item) => typeof item === 'number');
const boolsOK = [legend].every((item) => typeof item === 'boolean');
// Throw error as needed.
@rubencodes
rubencodes / auto_tooltips.js
Created Oct 21, 2016
Auto-initialize Tooltips
View auto_tooltips.js
// Get existing tooltips.
let tooltips = $('[data-toggle="tooltip"]').toArray();
// Every 100ms...
setInterval(() => {
// Detect if tooltips have changed.
const latestTooltips = $('[data-toggle="tooltip"]').toArray();
const tooltipsChanged = !tooltips.equals(latestTooltips);
// Update existing tooltips and initialize.
@rubencodes
rubencodes / google.js
Last active May 10, 2018
Find valid .google domains
View google.js
// I ran this with:
// while true; do node ~/Desktop/google.js --max_old_space_size=4096 --optimize_for_size --max_executable_size=4096 --stack_size=4096 && break; done
// This will run the script with 4GB allocated memory, and auto-restart if it crashes (happens sometimes due to out of memory).
const https = require('https');
const fs = require('fs');
// File storage between runs.
const validStorage = '/Users/ruben/Desktop/validURLs.txt';
const attemptsStorage = '/Users/ruben/Desktop/attempts.txt';
View gist:67b75e20fc5b65486c1d73545936ea69
//In config:
{
/*...*/
root: "/",
/*...*/
}
//Then in app:
<link rel="/favicon.ico" />
@rubencodes
rubencodes / .bash_rc
Created Sep 15, 2016
Google Search CLI
View .bash_rc
#Begin GoogleSearch CLI for Mac
function google() {
if [ $1 = "--images" ]; then
open https://google.com/search?tbm=isch\&q="$2"
elif [ $1 = "--news" ]; then
open https://google.com/search?tbm=nws\&q="$2"
else
open https://google.com/search?q="$1"
fi
}
@rubencodes
rubencodes / gist:7eb07907c3625a0c29c1
Created Jul 1, 2015
animateWithDuration with Completion Block
View gist:7eb07907c3625a0c29c1
//Shared from http://stackoverflow.com/questions/30824275/animatewithduration-lacks-completion-block-watchos-2/30960862#30960862
extension WKInterfaceController {
func animateWithDuration(duration: NSTimeInterval, animations: () -> Void, completion: (() -> Void)?) {
animateWithDuration(duration, animations: animations)
let completionDelay = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Double(NSEC_PER_SEC)))
dispatch_after(completionDelay, dispatch_get_main_queue()) {
completion?()
}
}
@rubencodes
rubencodes / console.log in Swift
Last active Nov 13, 2015
Force of habit: I keep trying to use console.log in Swift, to no avail. No longer!
View console.log in Swift
class console {
class func log(arg : Any) {
print(arg)
}
}
console.log("Hello World!")
View designer.html
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
You can’t perform that action at this time.