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 / reduce-array-method-example-3.html
Last active August 23, 2018 18:00
The Reduce Array Method Example 3
We couldn’t find that file to show.
@mojaray2k
mojaray2k / reduce-array-method-example-2.js
Last active August 23, 2018 17:57
Using The Reduce Array Method Example 2
var primaryColors = [
{color: 'red'},
{color: 'yellow'},
{color: 'blue'}
];
// What we want to end up with:
// ["red", "yellow", "blue"]
// sometimes the first argument is call the accumulator
@mojaray2k
mojaray2k / reduce-array-method-example-1.js
Last active August 23, 2018 18:00
Using The Reduce Array Method Example 1
var numbers = [10, 20, 30];
var sum = 0;
for (var i = 0; i < numbers.length; i++){
sum += numbers[i];
}
console.log("For loop way: ",sum);
// Results are: "For loop way: "
// 60
@mojaray2k
mojaray2k / pubsub.js
Created August 11, 2018 07:35 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@mojaray2k
mojaray2k / rmp.md
Created March 11, 2018 18:30
Revealing module pattern example

The revealing module pattern

One of the major problems with JavaScript is the absence of namespacing. Programs that run in the global scope polluting it with data that comes from both internal application code and dependencies. A popular technique to solve this problem is called the revealing module pattern, and it looks like the following:

const module = (() => {
 const privateFoo = () =&gt; {...};
@mojaray2k
mojaray2k / query.md
Last active January 28, 2018 09:27
GitHub GraphQL Operations and Variables
query FirstNOrgMembers($login: String!, $n: Int!) {
  organization(login: $login) {
    id
    name
    members(first: $n) {
      edges {
        node {
          id
 name
@mojaray2k
mojaray2k / postgres-cheatsheet.md
Created January 26, 2018 04:52 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@mojaray2k
mojaray2k / README.md
Created January 23, 2018 16:55 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@mojaray2k
mojaray2k / window.js
Last active December 31, 2017 10:05
JS Window and This
var sayAge = function() {
console.log(this.age);
}
var me = {
age: 42
}
sayAge();
window.age = 42;
sayAge();
@mojaray2k
mojaray2k / new.js
Last active December 31, 2017 09:56
JS new keyword
var Animal = function(color, name, type) {
this.color = color;
this.name = name;
this.type = type;
}
var zebra = new Animal('black and white', 'Zorro', 'Zebra');
// When the "new" keyword is invoked a new object is created and saved as "this"