Skip to content

Instantly share code, notes, and snippets.

View ayoola-solomon's full-sized avatar
:octocat:
WIP 🚓

Solomon Ayoola ayoola-solomon

:octocat:
WIP 🚓
View GitHub Profile
@ayoola-solomon
ayoola-solomon / fellows.js
Last active March 13, 2016 13:03
Refactoring a nodejs function
var peers = function(req, res) {
var peers = [];
models.Fellow
.findById(req.params.id)
.then(function(fellow) {
if (fellow) {
switch (fellow.level) {
case 'D0A - MONTH ONE':
case 'D0B - SIMULATIONS':
case 'D0C - SIMULATIONS':
@ayoola-solomon
ayoola-solomon / fellows.js
Last active November 13, 2015 15:23
Refactor function
var peers = function(req, res) {
try {
findPeers(req.params.id, function(err, data) {
if (data) {
res.status(200).json(data);
}
else {
res.status(404).json({
message: 'Fellows does not exist'
});
'use strict';
var models = require('../../../server/models/');
var should = require('should');
describe('Fellow', function() {
var mockFellow;
beforeEach(function(done) {
mockFellow = {
uid: 'google:12345678',
var input = [4, 900, 500, 498, 4];
function walrusWeight(input) {
var target = 1000;
var optimum = 0;
var sums = [];
sums.push(optimum);
for(var i=0; i < input.length; i++) {
var newSums = [];
for(var j=0; j < sums.length; j++) {
@ayoola-solomon
ayoola-solomon / deploy_with_ebcli3_on_circleci.md
Last active April 8, 2016 16:32 — forked from RobertoSchneiders/deploy_with_ebcli3_on_circleci.md
Settings to deploy to AWS Elastic Beanstalk on CircleCi (EB Cli 3)

This is how I configured the deploy of my rails apps to AWS Elastic Beanstalk through CircleCI.

Configure Environments Variables

On Project Settings > Environment Variables add this keys:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
    The aws user must have the right permissions. This can be hard, maybe, this can help you.

Create a bash script to create the eb config file

@ayoola-solomon
ayoola-solomon / a_mongodb_to_s3_backup.sh
Created April 10, 2016 22:36 — forked from lazarofl/a_mongodb_to_s3_backup.sh
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"
@ayoola-solomon
ayoola-solomon / index.html
Last active June 27, 2017 17:17
Collapsible created by Soulman - https://repl.it/JEHx/26
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Smava Collapsible</title>
<style>
.collapsible__content {
max-height: 20em;
@ayoola-solomon
ayoola-solomon / Smava SortUsers.js
Created June 27, 2017 17:21
Smava SortUsers created by Soulman - https://repl.it/JEGC/7
function usersComparator(userA, userB) {
if (userA.active !== userB.active) {
return userA.active - userB.active
}
if(userA.registrationDate !== userB.registrationDate) {
return userA.registrationDate - userB.registrationDate;
}
return userA.requestedAmount - userB.requestedAmount;
@ayoola-solomon
ayoola-solomon / index.html
Created July 30, 2017 12:27
Date.prototype.strftime test with YUI created by Soulman - https://repl.it/Josn/12
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Date.prototype.strftime test with YUI</title>
</head>
<body class="yui-skin-sam">
<div id="yui-main">
<div id="testReport"></div>
const array = [[1, 2, [3]] , 4];
const flatten = (array) => {
// reduce traverses the array and we return the result
return array.reduce((acc, b) => {
// if is an array we use recursion to perform the same operations over the array we found
// else we just concat the element to the accumulator
return acc.concat(Array.isArray(b) ? flatten(b) : b);
}, []); // we initialize the accumulator on an empty array to collect all the elements
}