Skip to content

Instantly share code, notes, and snippets.

View chukitow's full-sized avatar

Ivan velasquez chukitow

View GitHub Profile
@chukitow
chukitow / flatten_array.rb
Last active May 30, 2019 00:40
Custom flatten method
require 'minitest/autorun'
class FlattenArray
def self.for(collection)
new(collection).call
end
def initialize(collection)
@collection = collection
end
@chukitow
chukitow / fibonacci.rb
Last active November 28, 2015 21:47
fibonacci closest numbers
require 'net/http'
require 'json'
KUESKI_TOKEN = 'fbxfDZRWCxmdhxHfM-Q'
fibonacci_sequence = []
def fibonacci(x, cache = {})
return x if x <= 1
cache[x] ||= fibonacci(x-1, cache) + fibonacci(x-2, cache)
@chukitow
chukitow / reverse words
Last active October 28, 2015 22:55
reversing words
/*
Instructions:
Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed. Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.
Test Cases:
Test.assert_equals(spinWords("Hey fellow warriors"), "Hey wollef sroirraw")
Test.assert_equals(spinWords("This is a test"), "This is a test")
Test.assert_equals(spinWords("This is another test"), "This is rehtona test")
@chukitow
chukitow / parenthesis balanced
Created October 28, 2015 22:53
Given a String formed only by parenthesis check if they are well balanced (Every parenthesis that opens closes).
var stringGiven = "(()()(()))",
auxContainer = [],
finalContainer = [];
for(var i=0; i < stringGiven.length; i++){
if(stringGiven[i] === "("){
auxContainer.push(stringGiven[i]);
}
else{
if(auxContainer.length){
% PORTADA
\begin{titlepage}
\begin{center}
\vspace*{-1in}
\begin{figure}[htb]
\begin{center}
\includegraphics[width=8cm]{logo_udc}
#include <18F4550.h>
#device adc = 10
#fuses XT, PUT, NODEBUG , NOBROWNOUT , NOPROTECT , NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, bits = 8 , parity = N ,xmit=PIN_C6, rcv=PIN_C7)
void read_adc_chanel();
void evaluate_aceleration();
float adc_sensor_1 = 0;
#include <18F4520.h>
#device adc = 10
#fuses XT, PUT, NODEBUG , NOBROWNOUT , NOPROTECT , NOLVP
#use delay(clock=16000000)
#use rs232(baud=9600, bits = 8 , parity = N ,xmit=PIN_C6, rcv=PIN_C7)
void read_adc_chanel();
float adc_sensor_1 = 0;
float adc_sensor_2 = 0;
_serialPort = new SerialPort();
// Allow the user to set the appropriate properties.
_serialPort.PortName = SetPortName(_serialPort.PortName);
_serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate);
_serialPort.Parity = SetPortParity(_serialPort.Parity);
_serialPort.DataBits = SetPortDataBits(_serialPort.DataBits);
_serialPort.StopBits = SetPortStopBits(_serialPort.StopBits);
_serialPort.Handshake = SetPortHandshake(_serialPort.Handshake);
int testLed = 13;
int dotDelay = 200;
int hertz = 500000;
int tonePin = 4;
String data;
//define the morse code for the alphabet and numbers
char* letters[] = {
@chukitow
chukitow / JAVA MYSQL CONNECTION
Created September 29, 2014 20:59
JAVA MYSQL CONNECTION
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.chukitow.ci.actions;
import java.sql.Connection;
import java.sql.DriverManager;
/**