Skip to content

Instantly share code, notes, and snippets.

View dubistdu's full-sized avatar

Jasmine F dubistdu

  • FL
View GitHub Profile
def pyramid(numbers)
Array.new(numbers) { |i| [1] * (i + 1) }
end
function pyramid(n) {
return Array(n).fill(1).map((elemeent, index) => Array(index + 1).fill(1));
}
def min_min_max(array)
sorted = array.sort
sorted_all=[*sorted.first..sorted.last]
[sorted.first, (sorted_all-sorted).min, sorted.last]
end
def split_and_add(arr, n)
n.times { arr.length.odd? ? arr.unshift(0) : arr
arr = arr.each_slice(arr.length/2).to_a.transpose.map { |x| x.sum }
}
arr
end
@dubistdu
dubistdu / perimeter_of_squares_in_a_rectangle.md
Last active May 8, 2019 12:56
perimeter_of_squares_in_a_rectangle

ruby

def perimeter(n)
  num = [0,1]
  i = 0
  until i == n do
    num << num[i] + num [i+1]
    i += 1
 end
@dubistdu
dubistdu / soduku.md
Created March 4, 2019 16:15
soduku kata
def validSolution(board)
  return false if board.flatten.include?(0)
  board.map {|a| a.uniq.count == 9}.include?(false) ? false : board
  square_of_3 = board.map { |a| a.each_slice(3).to_a }
  s1=square_of_3[0][0].zip(square_of_3[1][0],square_of_3[2][0])
  s2=square_of_3[0][1].zip(square_of_3[1][1],square_of_3[2][1])
  s3=square_of_3[0][2].zip(square_of_3[1][2],square_of_3[2][2])
  
  s4=square_of_3[3][0].zip(square_of_3[4][0],square_of_3[5][0])
@dubistdu
dubistdu / gist:d64f8a4c560e8507dfd0efd234cbc373
Last active February 1, 2019 20:07
Multiples of 3 or 5

*JS

const solution = (number) => {
  return (number < 1 ? 0 : [...Array(number).keys()].filter(num => num % 3 == 0 || num % 5 == 0).reduce((a,b) => a+b));
}

*ruby

@dubistdu
dubistdu / terminal_flicker.md
Last active October 4, 2018 03:12
Troubleshoot - Terminal Gone!

Issue I had was terminal flashing and disappearing after removing Zsh while Terminal app was still running

Solution
  • Before removing shell, I should have switched to bash using chsh -s /bin/bashsince I can't uninstall zsh as I was using zsh!

    • It should have been chsh -s /bin/bash
    • to swich back to bash temporarily
    • then uninstall / reinstall zsh
    • then chsh -s /usr/local/bin/zsh to switch back to zsh
  • Since I didn't switch to bash first....

@dubistdu
dubistdu / git commands.md
Last active September 29, 2018 19:18 — forked from scootcho/git commands.md
git commands #git #commands

initialize git depository in the current directory

git init .

display the git remote/origin

cat .git/config
@dubistdu
dubistdu / RAILS_5_CHEATSHEET.md
Created September 17, 2018 00:32 — forked from harrietty/RAILS_5_CHEATSHEET.md
Ruby on Rails 5 Cheatsheet

Ruby on Rails Cheatsheet (5.1)

Architecture

RVM

$ rvm list - show currently installed Rubies