Skip to content

Instantly share code, notes, and snippets.

View GabrielModog's full-sized avatar
🤠

Gabriel Tavares GabrielModog

🤠
View GitHub Profile
@GabrielModog
GabrielModog / ReverseArray.js
Created February 27, 2020 01:06
reverse an array was simple
/*
The map() method creates a new array populated with the results
of calling a provided function on every element in the calling array.
.map(currentValue, index||optional||, currentArray||optional||)
*/
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const reversedArray = arr.map((v, k, array) => array[array.length - 1 - k])
@GabrielModog
GabrielModog / matrixrotation.js
Created February 11, 2020 14:30
messy script to rotate matrix image
let matrix = [
[7, 8, 9],
[1, 2, 3],
[4, 5, 6],
]
for(let i = 0; i < matrix.length; i++){
for(let j = i; j < matrix.length; j++){
let temp = matrix[i][j]
matrix[i][j] = matrix[j][i]
@GabrielModog
GabrielModog / fixSignalingMessage.js
Last active February 1, 2021 02:47
fixi order of signal metadata
const original =
`v=0
o=bulma bulma@capsule.corporation.com
s=
t=0
m=audio 123 rtp
a=128kbps
a=no-echo
a=filters
a=dragon-effect
@GabrielModog
GabrielModog / typewriter-animation.js
Last active November 23, 2020 03:44
simple animation of type writing
var i = 0;
var txt = 'Lorem ipsum typing effect!';
var speed = 100;
function typeWrite(){
if(i < txt.length){
document.getElementById("demo").innerHTML += txt.charAt(i);
i++;
}
@GabrielModog
GabrielModog / observer.js
Last active November 23, 2020 03:50
simple observer pattern
function Subject(){
this.observers = []
}
Subject.prototype = {
subscribe: function(fn) {
this.observers.push(fn)
},
unsubscribe: function(rmv){
this.observers = this.observers.filter(fn => {
@GabrielModog
GabrielModog / factory__example__000.js
Last active May 6, 2020 04:25
simple factory pattern
function Developer(name){
this.name = name
this.type = "Developer"
}
function Tester(name){
this.name = name
this.type = "Tester"
}
@GabrielModog
GabrielModog / SumOfRange.js
Last active November 23, 2020 03:49
Sum of range - Eloquent Javascript Exercises
/*
Write a range function that takes two arguments, start and end, and returns an array
containing all the numbers from start up to (and including) end.
Next, write a sum function that takes an array of numbers and returns the sum of these numbers.
Run the example program and see whether it does indeed return 55.
As a bonus assignment, modify your range function to take an optional third argument that indicates
the “step” value used when building the array. If no step is given, the elements go up by increments
of one, corresponding to the old behavior. The function call range(1, 10, 2) should return [1, 3, 5, 7, 9].
@GabrielModog
GabrielModog / countLetters.js
Last active November 13, 2019 01:50
Count characters - Eloquent Javascript Exercises
/* ELOQUENT JAVASCRIPT EXERCISES
Write a function countBs that takes a string as its only argument and returns a numbe
that indicates how many uppercase “B” characters there are in the string.
Next, write a function called countChar that behaves like countBs, except it takes
a second argument that indicates the character that is to be counted (rather than counting
only uppercase “B” characters). Rewrite countBs to make use of this new function.
*/
const countBs = (str) =>{
@GabrielModog
GabrielModog / MakePath.js
Created February 20, 2019 17:53
Making path with a simple function
// @gabrielmodog - 02/20/2019 - 14:50
// initialize
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
// number of lines
const counter = 90;
// canvas screen size
canvas.width = 400;
@GabrielModog
GabrielModog / pilula.lua
Last active September 1, 2018 03:17
A help library for lua projects || Still a working in progress
-- library to help with game engines and games and another applications
-- Pilula.lua || @GabrielModog
-- WORKING IN PROGRESS
-- Modification 18:41 - 11 August 2018
-- Modification 19:44 - 27 August 2018
-- simplification
local ti = table.insert
local tr = table.remove