Skip to content

Instantly share code, notes, and snippets.

@aprilmintacpineda
aprilmintacpineda / bubblesort.java
Last active December 24, 2017 12:09
bubble sort implementation in Java with tests and performance measurement. I used this for my experiment entitled `fun-with-bubble-sort`.
/**
* NOTE from the developer:
* You only need to manipulate the codes inside the main function, the rest of the codes are
* the core functionality of the program and requires no refactoring
*/
import java.util.Random;
public class TestSuite {
public static void main(String [] args) {
@aprilmintacpineda
aprilmintacpineda / bubblesort.py
Last active December 24, 2017 12:10
bubble sort implementation in Python with tests and performance measurement. I used this for my experiment entitled `fun-with-bubble-sort`.
# NOTE from the developer:
# You only need to manipulate the codes BELOW, the rest of the codes
# are the core functionality of the program and requires no refactoring
import time
import math
from random import randint
# generates random data for testing purpose
def generateRandomTestData(dataLength, maxNumber):
@aprilmintacpineda
aprilmintacpineda / bubblesort.php
Last active December 24, 2017 12:10
bubble sort implementation in PHP with tests and performance measurement. I used this for my experiment entitled `fun-with-bubble-sort`.
<?php
$ten = 10;
$hundred = 100;
$thousand = 1000;
$ten_thousand = 10000;
$hundred_thousand = 100000;
$million = 1000000;
// very self-explanatory
@aprilmintacpineda
aprilmintacpineda / bubblesort.js
Last active December 24, 2017 12:11
bubble sort implementation in JavaScript with tests and performance measurement. I used this for my experiment entitled `fun-with-bubble-sort`.
var ten = 10,
hundred = 100,
thousand = 1000,
ten_thousand = 10000,
hundred_thousand = 100000,
million = 1000000;
// very self-explanatory
// int numberOfTests, int max, int dataLength, boolean showSortedArray = false, runTest = true
doIt(ten, million, million);
@aprilmintacpineda
aprilmintacpineda / longestConsecutiveSubstr-longestCommonSubstring.js
Created December 28, 2017 16:20
Longest Common Substring & longest consecutive substring javascript implementation.
function longestConsecutiveSubstr(str) {
var longestConsecutiveSubstr = '';
var leftOff = 1;
for (var a = 0; a < str.length - 1; a = leftOff) {
var newLongestConsecutiveSubstr = '';
for (var b = a + 1; b < str.length; b++) {
if (str[a] == str[b]) {
newLongestConsecutiveSubstr += str[a];
@aprilmintacpineda
aprilmintacpineda / bubble-sort-pseudocode.md
Last active December 28, 2017 16:22
ALGORITHM: Pseudo code for bubble sort. I used this for my experiment entitled `Fun with JS, PHP, PY, and Java`.

Bubble Sort pseudocode

Bubble sort is composed of two loops, one inside the other, the idea is to push the largest number on the right most side of the list, one by one.

Key factors

For the sake of discussion, we'll call a the outer loop and b the inner loop.

  • a starts at list.length - 1, last step occurs at 0.
  • b starts at 0, last step occurs at a - 1, i.e., if a = 3, then last step of b would be 2.
@aprilmintacpineda
aprilmintacpineda / Longest Common Substring & longest consecutive substring.md
Last active December 29, 2017 01:45
ALGORITHM: Pseudo code for `Longest Common Substring & longest consecutive substring`

Fun with strings!

Longest Common Substring & longest consecutive substring

The idea here is to get the longest common substring of two or more strings. For example, given the strings Heeeeeeeelllllloooo and teeeeeeeestoooo, it will return the string eeeeeeee, because it is the longest common string of the two.

Criteria for deciding if a string is the longest commong substring.

@aprilmintacpineda
aprilmintacpineda / myscript.sh
Created May 19, 2018 13:27 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@aprilmintacpineda
aprilmintacpineda / gist:db6239d54909ff044a45ead1bd583cc0
Created June 10, 2018 03:14 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@aprilmintacpineda
aprilmintacpineda / docs.md
Last active November 26, 2018 04:29
JS code speed tests

Looping through elements

http://jsben.ch/UgRvN

  • Accesses length property every loop.
  • Accesses length property only once and saves it into a constant.
  • Uses forEach method.

Removing an element of an array