Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🏴

Elvis Morales elvismdev

🏴
View GitHub Profile
@elvismdev
elvismdev / GrayScaleConverter.java
Last active January 5, 2016 05:17
A Java small class to convert colorful images into grayscale. The library edu.duke is a dependency for the class to work, it should be added into the Java IDE to compile with no errors. Download link http://www.dukelearntoprogram.com/downloads/archives/courserajava.jar
/**
* Create a gray scale version of an image by setting all color components of each pixel to the same value.
*/
import edu.duke.*;
import java.io.File;
public class GrayScaleConverter {
//I started with the image I wanted (inImage)
public ImageResource makeGray(ImageResource inImage) {
//I made copy of the original image with color which will be the one later returned in grayscale
@elvismdev
elvismdev / BatchInversions.java
Created January 5, 2016 06:32
A Java small class to invert colors in image files. The library edu.duke is a dependency for the class to work, it should be added into the Java IDE to compile with no errors. Download link http://www.dukelearntoprogram.com/downloads/archives/courserajava.jar
/**
* Inverts colors in a image file (photographic negative).
*
* @author (Elvis Morales)
* @version (1.0)
*/
import edu.duke.*;
import java.io.File;
@elvismdev
elvismdev / FindGene.java
Last active January 11, 2016 04:23
A Java small class to find a protein within a strand of DNA represented as a string of C, G, T, A letters. The library edu.duke is a dependency for the class to work, it should be added into the Java IDE to compile with no errors. Download link http://www.dukelearntoprogram.com/downloads/archives/courserajava.jar
/**
* Finds a protein within a strand of DNA represented as a string of c,g,t,a letters.
* A protein is a part of the DNA strand marked by start and stop codons (DNA triples)
* that is a multiple of 3 letters long.
*
* @author Duke Software Team
*/
import edu.duke.*;
import java.io.*;
@elvismdev
elvismdev / FindWebLinks.java
Last active January 11, 2016 04:32
A Java small class to read the lines from a given URL location/webpage and print each URL that is a link from another defined website. The library edu.duke is a dependency for the class to work, it should be added into the Java IDE to compile with no errors. Download link http://www.dukelearntoprogram.com/downloads/archives/courserajava.jar
@elvismdev
elvismdev / double-size-image.js
Created January 22, 2016 03:41
Double the size of an image with pure JavaScript
var inImage = new SimpleImage( "yourimage.png" );
print( inImage );
var outImage = new SimpleImage( inImage.getWidth() *2, inImage.getHeight() *2 );
for ( var pixel of outImage.values() ) {
var x = Math.floor( pixel.getX() /2 );
var y = Math.floor( pixel.getY() /2 );
@elvismdev
elvismdev / default.vcl
Created February 25, 2016 22:33 — forked from reifman/default.vcl
Example Varnish VCL Configuration e.g. /etc/varnish/default.vcl
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
@elvismdev
elvismdev / todo-react.html
Last active February 28, 2016 00:37
Sample ToDo App from the ReactJS WorkShop by Refresh Miami https://www.refreshmiami.com/event/refresh-miami-workshop-reactjs-primer/. (Miami, Coral Gables, 02-27-2016)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Refresh Miami ReactJS</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
@elvismdev
elvismdev / spotify.html
Last active February 28, 2016 01:02
Sample Spotify Search and Play WebApp. Lesson from ReactJS WorkShop by Refresh Miami https://www.refreshmiami.com/event/refresh-miami-workshop-reactjs-primer/. (Miami, Coral Gables, 02-27-2016)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Refresh Miami ReactJS</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
@elvismdev
elvismdev / FindMultipleGenes.java
Created January 11, 2016 08:57
A Java small class to find all the genes in a DNA string. The library edu.duke is a dependency for the class to work, it should be added into the Java IDE to compile with no errors. Download link http://www.dukelearntoprogram.com/downloads/archives/courserajava.jar
/**
* Find all the genes in a DNA string.
*
* @author (Elvis Morales)
* @version (1.0)
*/
public class FindMultipleGenes {
public int findStopIndex(String dna, int index) {
@elvismdev
elvismdev / array_dechunk.php
Last active June 16, 2017 05:28
De-chunks an array, opposite of array_chunk() http://php.net/manual/en/function.array-chunk.php
function array_dechunk( $array ) {
return array_reduce( $array, function ( $carry, $item ) {
return array_merge( $carry, $item );
}, [] );
}