Skip to content

Instantly share code, notes, and snippets.

View mojaray2k's full-sized avatar

Amen Moja Ra mojaray2k

  • Miami, Fl
View GitHub Profile
@mojaray2k
mojaray2k / unique-array-values-js.md
Created May 28, 2020 15:48
3 Ways to get unique values from an array in Javascript

Here are 3 ways to retrieve unique values from arrays in Javascript

  1. The array.filter method which is a higher order function which means it takes a function as it's argument.
const someArray = ['😁', '💀', '💀', '💩', '💙', '😁', '💙'];

const getUniqueValues = (array) => (
  array.filter((currentValue, index, arr) => (
		arr.indexOf(currentValue) === index
@mojaray2k
mojaray2k / rest-api-pitfalls.md
Last active March 2, 2024 17:37
This is about the pitfalls of rest api’s
  1. Deciding on a url schema gets tough when we begin to have heavily nested relationships of data.

  2. When fetching heavily nested data wecan easily run into situations where we make to many http requests to get the data we need.

  3. We are vulnerable to overfetching data.

@mojaray2k
mojaray2k / jsbin.burut.html
Last active September 19, 2023 15:42
CSS only custom-styled select Todd Parker - Filament Group Inc. How this works: This styles a native select consistently cross-platform with only minimal CSS. The native select is then styled so it is essentially invisible (no appearance, border, bg) leaving only the select's text visible. There is a wrapper around the select that has the majori…
<html>
<head>
<title>Select styles with CSS only</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
background-color: #fff;
font-family: helvetica, sans-serif;
margin: 4% 10%
}
@mojaray2k
mojaray2k / typescript-compiler-config-optons.md
Created May 23, 2020 16:17
Common TypeScript compiler and tsconfig options

TypeScript Compiler and TS Config Options

You can store the TS compiler configuration in the file called tsconfig.json. You’ll usually add this file to the root directory of your project, together with the package.json.

When you launch the compiler, it reads the tsconfig.json from the folder you launched it from, to get the instructions about how to compile your project (e.g., which source files to compile, where to store the output, etc).

The compiler reads the tsconfig.json from the folder where you run it. Also, you can tell the compiler where to look for the config using the -p option:

tsc -p tsconfig.server.json The structure of the tsconfig.json looks like this:

@mojaray2k
mojaray2k / reduce-array-method-example-5.js
Last active April 2, 2023 14:41
The Reduce Array Method Example 5
/**
* Reducing Properties
* Use the 'reduce' helper to create an object that tallies the number of sitting and standing desks.
* The object returned should have the form '{ sitting: 3, standing: 2 }'.
* The initial value has been provided to you.
* Hint: Don't forget to return the accumulator object (the first argument to the iterator function)
*/
var desks = [
{ type: 'sitting' },
@mojaray2k
mojaray2k / react-registration-form-using-useState.md
Last active February 3, 2023 09:06
Sample React Registration form Using UseState Hook

React Registraton Form using useState Hook

import React, { Fragment, useState } from "react";
import { Link } from "react-router-dom";
import axios from "axios";

const Register = () => {
  const [formData, setFormData] = useState({
    name: "",
@mojaray2k
mojaray2k / nginx.conf
Last active January 27, 2023 21:04
NGINX Multiple Server Block file to serve multiple Node Applications on Multiple Domains on A GoDaddy Dedicated Server
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
@mojaray2k
mojaray2k / Bootstrap 1
Created March 6, 2013 06:15
This is a fallback Script for Bootstrap CDN
//bootstrapfallback.js
//<!-- BOOTSTRAP JS WITH LOCAL FALLBACK-->
//<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
//<script> if(typeof($.fn.modal) === 'undefined') {document.write('<script src="//www.mysite.com/js/v/bootstrap-2.1.1.js"><\/script>')}</script>
//<!-- BOOTSTRAP CDN FALLBACK CSS-->
//<script>$(document).ready(function() {
var bodyColor = $('body').css("color"); if(bodyColor != 'rgb(51, 51, 51)') {$("head").prepend("<link rel='stylesheet' href='//www.mysite.com/css/fw/bootstrap-combined-2.1.1.css' type='text/css' media='screen'>");}

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@mojaray2k
mojaray2k / instafeedjsaccess.md
Last active May 22, 2022 10:40
Getting Instagram Access Token for http://intafeedjs.com

#Use this URL to get your client authorized for Instafeed.JS plugin for Instagram.

  1. First login into your Instargam account
  2. Then go to https://www.instagram.com/developer/
  3. At the top click on the Button that says "Manage Clients".
  4. If you have not Register a new client.
  5. Fill out everything and where it says redirect url put this url: http://instafeedjs.com
  6. Then on the security tab make sure you uncheck "Disable implicit OAuth"
  7. Finally use this link to authoruize Instafeed. Where it says "[Client ID]" replace that including the brackets with your clientID from instagram:
  8. https://instagram.com/oauth/authorize/?client_id=[Client ID]&redirect_uri=http://instafeedjs.com&amp;response_type=token