Skip to content

Instantly share code, notes, and snippets.

View armandocanals's full-sized avatar
👾
0_0

Armando Canals armandocanals

👾
0_0
View GitHub Profile
@armandocanals
armandocanals / largeSum.js
Created May 2, 2016 23:50
Sum Large Numbers in JavaScript
function add(num1, num2) {
num1 = num1.split('');
num2 = num2.split('');
num1 = num1.map(function (num) {
return parseInt(num, 10);
});
num2 = num2.map(function (num) {
return parseInt(num, 10);
@armandocanals
armandocanals / react-copybutton.js
Last active April 5, 2019 06:26
Copy button using native browser range
import React from 'react';
class CopyButton extends React.Component {
constructor(props) {
super(props);
this.buttonText = props.buttonText;
this.copyText = props.textToCopy;
this.onCopied = this.onCopied.bind(this);
@armandocanals
armandocanals / fire-lentils.txt
Last active September 4, 2018 18:38
🔥Lentil Recipe
Lentil Recipe
1. Add Lentils and Chicken Broth + Water to large pot
(3-to-1 ratio of broth to lentils, more or less)
2. Put on stove on high with lentil/broth combo.
3. As the pot is heating up, prepare the following:
@armandocanals
armandocanals / getElementsByClassName.js
Last active July 27, 2017 15:30
Recursive method to find elements by class name
function getElementsByClassName(className) {
var elements = document.body,
matches = [];
function traverse(node) {
for(var i = 0; i < node.childNodes.length; i++) {
if(node.childNodes[i].childNodes.length > 0) {
traverse(node.childNodes[i]);
}
@armandocanals
armandocanals / vagrant-tips.md
Created January 31, 2017 11:45
Hanging HGFS Ubuntu 12.04 / Vagrant

Fix hanging HGFS: Read more here

echo "answer AUTO_KMODS_ENABLED yes" | sudo tee -a /etc/vmware-tools/locations
@armandocanals
armandocanals / baofeng.txt
Last active November 9, 2016 01:25
baofeng HAM setup: quick review
Turn the radio on
GO to menu item #40 and RESET the radio
Menu item #14 for either English voice or Voice OFF
Press EXIT on the keypad
Push orange VFO/MR button to go to Frequency mode and program in repeater frequency
Press MENU then push #1 for frequency stepping. 10K for ham repeater use.
Push #13 for CTCSS on transmit for repeater use.
Push #25 for repeater shift. Options are NEG(-) POS(+) or off for simplex
Item #26 for off shift repeater use. You want 00.600 for ham radio repeaters.
@armandocanals
armandocanals / Character_Frequency.rb
Last active December 28, 2015 09:29
Most frequent letters, in order, occurring in the 1000 most common words (http://www.giwersworld.org/computers/linux/common-words.phtml)
# This is a dump of the word list
text = File.read ARGV[0]
words = text.split("\n")
hash = {}
words.each do |word|
word.each_char do |l|
hash[l] ||= 0
if hash.keys.include?(l)
hash[l] += 1
@armandocanals
armandocanals / anagram.rb
Last active December 14, 2015 12:18
Group all words that are anagrams of one another
#!/usr/bin/ruby
# Group all words that are anagrams of one another
# example:
# sample set of words
# dict = %w[cat tar war store core orb bro rat]
# $ ruby anagram.rb
# expect
# {
# "act"=>["cat"],
class Node
attr_accessor :next, :data
def push(str)
new_node= Node.new
new_node.data = str
node = self
while node.next
@armandocanals
armandocanals / retina_detect
Created March 20, 2012 02:07
Detect retina asset in DOM using javascript
function retina(selector) {
var element = document.querySelector(selector);
var images = Array.prototype.slice.apply(element.getElementsByTagName("img"));
var extension = "_2x";
if (window.devicePixelRatio === 2) {
images.forEach(function(img, idx) {
var src = img.getAttribute('src');
img.setAttribute('src', src.replace(/(\.jpg|\.png|\.gif)$/, extension + '$&'));
img.onerror = function(evt) {
img.setAttribute('src', src);