Skip to content

Instantly share code, notes, and snippets.

View AyoAlfonso's full-sized avatar
:octocat:
Building

Ayo Alfonso AyoAlfonso

:octocat:
Building
View GitHub Profile
@AyoAlfonso
AyoAlfonso / sample.js
Created November 12, 2018 09:33 — forked from chowryan/sample.js
react setstate?
// Method 1:
class Parent extends Component {
state = { foo: '', bar: '', buzz: '' }
render() {
return (
<Child
setParentState={this.setState}
>
)
@AyoAlfonso
AyoAlfonso / firebaseComments.js
Created October 2, 2018 22:44
A Function For Unfolding Comments on Firebase
let rootCommentsCard = []
let repliesCard = []
function arrangeComments(comments){
for (var commentId in comments) {
let parent = comments[commentId].parent
if (parent[0] == 'root') {
comments[commentId].commentId = commentId
comments[commentId].replies = []
rootCommentsCard.push(comments[commentId])
let array = [{
name: "John",
ranking: 5
}, {
name: "Sam",
ranking: 4
}, {
name: "Timi",
ranking: 1
}, {
function test(){
var h = 'Hello';
var w = 'World';
return w,
console.log(f),
h;
}
console.log(this.test()); //World
function test(){
var h = 'Hello';
var w = 'World';
return (h,w);
}
console.log(this.test()); //World
let evens = []
simpleArray = [0, 12, 16, 12, 10, 7, 9];
simpleArray.forEach(function(e) {
if (e % 2 === 0) {
this.fives.push(e)
}
}.bind(this))
console.log(fives) //[ 0, 12, 16, 12, 10 ]
/* Using the arrow function*/
let evens = []
simpleArray = [0, 12, 16, 12, 10, 7, 9];
simpleArray.forEach(function(e) {
if (e % 2 === 0) {
this.fives.push(e)
}
}.bind(this))
console.log(fives) //[ 0, 12, 16, 12, 10 ]
/* Using the arrow function*/
let user = [Jane, Bane, Deadpool, Thanos]
let state = 0;
let uninvitedUsers = users.filter(user => {
if (user.invite == "notInvited") {
let rangeArray = range(from, to)
for (let i = 0; i < rangeArray.length; i++) {
if (user.rank == rangeArray[i]) {
state += 1
return user, state
}
@AyoAlfonso
AyoAlfonso / gist:c7b20ad9d66f44b982a1e4e8040ae398
Created March 14, 2018 11:16 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@AyoAlfonso
AyoAlfonso / package.json
Created November 21, 2017 17:30
Cron-test
{
"name": "Cron-test",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">= 7.6.0"
},
"now": {
"dotenv": "variables.env.now"
},