Skip to content

Instantly share code, notes, and snippets.

View PradatiusD's full-sized avatar

Daniel Prada PradatiusD

View GitHub Profile
/**
* Write a function to find the longest common prefix string in an array of strings.
* --------------------------------
* Function to find matching characters and stop at the
* point at which they are different or if the string ends
*
* Worked with https://twitter.com/Spraggsz_ to solve!
* @return {string}
*/
@PradatiusD
PradatiusD / anagram.js
Created September 28, 2020 02:55
anagram.js
function generateAnagram (string, prefix = '', combinations = []) {
for (let i = 0; i < string.length; i++) {
const current = string[i]
let otherChars = ''
for (let j = 0; j < string.length; j++) {
if (j !== i) {
otherChars += string[j]
}
}
if (current.length + otherChars.length === 2) {
@PradatiusD
PradatiusD / git-total-commits.sh
Created February 24, 2020 03:17
git-total-commits.sh
# If you have all your repos on the same folder
# Run the following script to get a total of all your
# commits in all your repos.
rm -f total.txt
for directory in */
do
cd $directory
if [ -d .git ]; then
# Your name goes here, mine would be Daniel Prada
git shortlog -s -n --all --no-merges | grep "Daniel Prada" >> ../total.txt
@PradatiusD
PradatiusD / queue.js
Created January 10, 2020 05:13
Fixed size queue in JavaScript
class Queue {
constructor (size) {
this.slots = []
this.front = 0
this.back = 0
for (let i = 0; i < size; i++) {
this.slots.push(undefined)
}
}
<html>
<head>
<link rel="stylesheet" href="bootstrap.css">
<script src="vue.js"></script>
<style>
.total {
font-size: 3em;
font-weight: 200;
display: block;
}
var columns = ['a','b','c','d','e', 'f', 'g', 'h'];
function compareColumns (array, sizeOfGroup) {
var arrayCutoff = sizeOfGroup - 2;
for (var i = 0; i < array.length - 1; i++) {
var currentLetter = array[i];
var currentLetterIndex = i;
@PradatiusD
PradatiusD / gist:4728285
Created February 7, 2013 03:49
Trying to find a fade in fade out slider that could use any elements on a page (as opposed to only images or list items), and had to end on a final item--as opposed to looping forever. This does that in a simple way. Hope it is useful.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<div>
<img src="http://placehold.it/400x300&text=1" id="1" style="display:none"
/>
<img src="http://placehold.it/400x300&text=2" id="2" style="display:none"
@PradatiusD
PradatiusD / gist:4695745
Last active December 12, 2015 02:08
Here is the newbie developer putting out his favorite mixins from SCSS. These are a mix of one's I've found in CSS tricks, as well as some I've found useful for cross-browser css3. I plan on updating this to the point that anyone can simply use Sublime's Fetch tool to get the latest versions of these without having to download files or search en…
//These are a mix of one's Ive found in CSS tricks, CodeSchool as well as some I've found useful for cross-browser css.
//I've alphabetized and stretched the mixins horizontally to allow users to be able to quickly see all the mixin titles.
// ============================== //
// Alphabetized Mixins //
// ============================== //
@mixin border-radius ($rad) {-moz-border-radius: ($rad);-webkit-border-radius: ($rad); border-radius: ($rad);-khtml-border-radius:($rad);}