Skip to content

Instantly share code, notes, and snippets.

View vicegd's full-sized avatar

Vicente García Díaz vicegd

View GitHub Profile
@vicegd
vicegd / Quicksort.java
Last active February 23, 2020 08:03
Sorting algorithm: Quicksort method
public class Quicksort {
public void sort(int[] elements) {
quickSort(elements, 0, elements.length-1);
}
/**
* Gets the position of the median of the three (left, right and
* the element which position is in the center between them, and
* moves the elements to order them
@vicegd
vicegd / ImprovedBubble.java
Created February 23, 2020 07:59
Sorting algorithm: Bubble method with sentinel
public void sort(int[] elements) {
int i = 1;
boolean hasChange = true;
while (hasChange && (i < elements.length)){
hasChange = false;
for (int j = elements.length - 1; j >= i; j--){
if (elements[j-1] > elements[j]){
int temp = elements[j];
elements[j] = elements[j-1];
@vicegd
vicegd / DirectSelection.java
Last active February 23, 2020 07:58
Sorting algorithm: Direct selection method
public void sort(int[] elements) {
int posMin;
for (int i = 0; i < elements.length-1; i++) {
posMin = findPosMin(elements, i); //O(n)
int temp = elements[i];
elements[i] = elements[posMin];
elements[posMin] = temp;
}
}
@vicegd
vicegd / DirectInsertion.java
Created February 23, 2020 07:56
Sorting algorithm: Direct insertion method
public void sort(int[] elements) {
int j;
int pivot;
for (int i = 1; i < elements.length; i++) {
pivot = elements[i];
j = i-1;
while (j >= 0 && pivot < elements[j]) {
elements[j+1] = elements[j];
@vicegd
vicegd / Bubble.java
Last active February 23, 2020 07:52
Sorting algorithm: Bubble method
public void sort(int[] elements) {
for (int i = 1; i < elements.length; i++) {
for (int j = elements.length - 1; j >= i; j--) {
if (elements[j-1] > elements[j]){
int temp = elements[j];
elements[j] = elements[j-1];
elements[j-1] = temp;
}
}
}
@vicegd
vicegd / 0_reuse_code.js
Created February 13, 2016 16:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vicegd
vicegd / index.html
Last active February 11, 2016 09:56
Reveal.JS - parallax
Reveal.configure({
parallaxBackgroundImage: 'images/parallax.jpg', //Parallax background image
parallaxBackgroundSize: '', //CSS syntax, e.g. "2100px 900px" //Parallax background size
parallaxBackgroundHorizontal: 100, //Number of pixels to move the parallax background per slide (horizontal)
parallaxBackgroundVertical: 100 //Number of pixels to move the parallax background per slide (vertical)
});
@vicegd
vicegd / index.html
Last active February 8, 2016 18:12
Reveal.JS - video
<section>
<h2>Y por qué no un video?</h2>
<video width="320" height="240" controls>
<source src="videos/mov_bbb.mp4" type="video/mp4">
<source src="videos/mov_bbb.ogg" type="video/ogg">
</video>
</section>
@vicegd
vicegd / index.html
Last active February 8, 2016 16:13
Reveal.JS - initialize (dependencies)
Reveal.initialize({
//Parameters values...
//Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
@vicegd
vicegd / index.html
Last active February 8, 2016 16:02
Reveal.JS - initialize
Reveal.initialize({
controls: true, //Display controls in the bottom right corner
progress: true, //Display a presentation progress bar
slideNumber: true, //Display the page number of the current slide
history: true, //Push each slide change to the browser history
keyboard: true, //Enable keyboard shortcuts for navigation
overview: true, //Enable the slide overview mode
center: true, //Vertical centering of slides
touch: true, //Enables touch navigation on devices with touch input
loop: false, //Loop the presentation