Skip to content

Instantly share code, notes, and snippets.

View jordanrios94's full-sized avatar
๐Ÿ˜Ž
looking at a screen

Jordan Rios jordanrios94

๐Ÿ˜Ž
looking at a screen
  • 101Ways
  • London
View GitHub Profile
@jordanrios94
jordanrios94 / two_stacks_one_queue.js
Last active February 1, 2023 06:33
Coding Exercise - Queue From Stacks
/*
Implement a Queue data structure using two stacks.
- Do not create an array inside of the 'Queue' class.
- Queue should implement the methods 'add', 'remove', and 'peek'.
*/
class Stack {
constructor() {
this.data = [];
}
@jordanrios94
jordanrios94 / weave.js
Created February 1, 2023 05:37
Coding Exercise - Weave
/*
Implement the 'weave' function.
- Weave receives two queues as arguments and combines the contents of each into a new, third queue
- The third queue should contain the alternating content of the two queues
- The function should handle queues of different lengths without inserting 'undefined' into the new one
- Do not access the array inside of any queue, only use the add, remove, and peek functions
@jordanrios94
jordanrios94 / fibonacci.js
Created February 1, 2023 05:11
Print out the n-th entry in the Fibonacci series. The Fibonacci series is an ordering of numbers where each number is the sum of the preceding two.
// Iterative Fib (Linear runtime)
function fibItr(n) {
const result = [0, 1];
for (let i = 2; i <= n; i++) {
const a = result[n - 1];
const b = result[n - 2];
result.push(a + b);
}
@jordanrios94
jordanrios94 / spiral_matrix.js
Last active January 31, 2023 06:23
Write a function that accepts an integer N and returns a NxN spiral matrix.
// matrix(3);
// [[1, 2, 3],
// [8, 9, 4],
// [7, 6, 5]]
// matrix(4);
// [[1, 2, 3, 4],
// [12, 13, 14, 5],
// [11, 16, 15, 6],
// [10, 9, 8, 7]]
@jordanrios94
jordanrios94 / spacings.json
Created February 7, 2022 18:05
OneHub Spacings
[
{
"name": "dynamic0020",
"value": "dynamic0020"
},
{
"name": "dynamic0050",
"value": "dynamic0050"
},
{
@jordanrios94
jordanrios94 / src_App.tsx
Last active June 5, 2020 15:00
React and Redux Setup in Typescript
import React from 'react';
import { getStore } from './store';
import { Provider } from 'react-redux';
import Component from './components/Component'
const App = () => {
const store = getStore()
return (
<Provider store={store}>
@jordanrios94
jordanrios94 / db.json
Created May 14, 2020 16:28
JSON Server + NGROK
{
"blogposts": []
}
@jordanrios94
jordanrios94 / createTranslation.js
Created March 21, 2020 16:28
A simple script that uses Google Translate API to translate content form JS object into different languages.
const fs = require('fs');
const keys = require('../config/keys');
const { Translate } = require('@google-cloud/translate').v2;
const translate = new Translate({
projectId: keys.googleProjectKey,
keyFilename: '../google_authentication.json'
});
@jordanrios94
jordanrios94 / index.js
Created March 13, 2019 15:38
JS Approach To Clamp Line
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
export default class ClampLines extends PureComponent {
constructor(props) {
super(props);
this.element = null;
this.original = props.text;
this.watch = true;
@jordanrios94
jordanrios94 / Component.js
Created January 23, 2019 14:50
HOC Scaffold Redux + React Router DOM
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchAdmins } from '../actions';
import requireAuth from '../components/hocs/requireAuth';
class AdminsListPage extends Component {
componentDidMount() {
this.props.fetchAdmins();
}