Skip to content

Instantly share code, notes, and snippets.

View mindplace's full-sized avatar
🎯
Focusing

Esther Leytush mindplace

🎯
Focusing
View GitHub Profile
@mindplace
mindplace / fisher_yates_shuffle.rb
Created February 17, 2017 22:53
Fisher-Yates shuffle algorithm
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 May 1, 2024 00:17
Pushing your first project to github

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 November 24, 2016 02:54 — forked from CristhianMotoche/101.md
101 Template

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

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.
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)}
class Array
def my_each(&prc)
i = 0
while i < self.count
prc.call(self[i])
i += 1
end
self
end
end
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];
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) {
def to_binary(number)
returning = []
if number.odd?
returning << 1
number -= 1
end
while number > 0
i = 1
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;
}