Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Esther Leytush mindplace

🎯
Focusing
View GitHub Profile
@mindplace
mindplace / fisher_yates_shuffle.rb
Created Feb 17, 2017
Fisher-Yates shuffle algorithm
View fisher_yates_shuffle.rb
def shuffle(array)
counter = array.length - 1
while counter > 0
# item selected from the unshuffled part of array
random_index = rand(counter)
# swap the items at those locations
array[counter], array[random_index] = array[random_index], array[counter]
@mindplace
mindplace / git_and_github_instructions.md
Last active Nov 27, 2022
Pushing your first project to github
View git_and_github_instructions.md

1. Make sure git is tracking your project locally

Do you need a refresher on git? Go through Codecademy's git course.

  1. Using your terminal/command line, get inside the folder where your project files are kept: cd /path/to/my/codebase. → You cannot do this simply by opening the folder normally, you must do this with the command line/terminal.
    → Do you need a refresher on using your command line/terminal? I've compiled my favorite resources here.

  2. Check if git is already initialized: git status

@mindplace
mindplace / 101.md
Created Nov 24, 2016 — forked from CristhianMotoche/101.md
101 Template
View 101.md

My 101 for learning any language

The following lists will be implemented in any new language that I'd like learn. I'll apply TDD for everyone of these examples.

Easy

The following list:

  • Calculator
  • Sorting and Search algorithms
    • Bubble sort
    • Quick sort
  • Merge sort
View file-commands.md

Input/Output

Goals

  • Know how to use gets to read input.
  • Know why chomp is often used to clean input.
  • Know the difference between print and puts.
  • Know how to open a file
    • Know how to read a line from a file.
    • Know how to read in all the lines from a file.
View my_map.rb
class Array
def my_map(&prc)
new = []
self.my_each{|item| new << prc.call(item)}
new
end
def my_select(&prc)
selected = []
self.my_each{|item| selected << item if prc.call(item)}
View my_each.rb
class Array
def my_each(&prc)
i = 0
while i < self.count
prc.call(self[i])
i += 1
end
self
end
end
View browser_grocery_list.js
function newList() {
var listString = prompt("Welcome to GroceryListMaker!\n\n" +
"Enter items with quantities like so:\n"
+ "2 apples, 1 tomato, 3 pomegranates, 1 sugar");
var list = {};
listString = listString.split(", ");
for (var i=0; i < listString.length; i++) {
var quant = listString[i].split(" ")[0];
var item = listString[i].split(" ")[1];
View to_binary.js
function toBinaryNumber(number) {
var returning = new Array;
if (number % 2 != 0) {
returning[0] = 1;
number -= 1;
}
while (number > 0) {
i = 1;
while (Math.pow(2, i) <= number) {
View to_binary.rb
def to_binary(number)
returning = []
if number.odd?
returning << 1
number -= 1
end
while number > 0
i = 1
View from_binary.js
function BinaryConverter(binNum) {
var numArray = binNum.toString().split("").reverse();
var number = 0;
for (var i=0; i < numArray.length; i++) {
var num = parseInt(numArray[i]);
var location = Math.pow(2, i);
number += num * location;
}
return number;
}