Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🏴

Elvis Morales elvismdev

🏴
View GitHub Profile
@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 );
}, [] );
}
@elvismdev
elvismdev / jenkins_wpsvn_deploy.sh
Last active August 30, 2022 18:35 — forked from BFTrick/deploy.sh
Deploy from Jenkins to WordPress.org SVN
# In your Jenkins job configuration, select "Add build step > Execute shell", and paste this script contents.
# Replace `______your-plugin-name______`, `______your-wp-username______` and `______your-wp-password______` as needed.
# main config
WP_ORG_USER="______your-wp-username______" # your WordPress.org username
WP_ORG_PASS="______your-wp-password______" # your WordPress.org password
PLUGINSLUG="______your-plugin-name______"
CURRENTDIR=`pwd`
MAINFILE="______your-plugin-name______.php" # this should be the name of your main php file in the wordpress plugin
@elvismdev
elvismdev / wp-ctrl-addthis-sidebar.php
Last active July 6, 2017 06:13
Controls the display of the AddThis Sharing Sidebar style using the show/hide Addthis sharing radio buttons in admin post add/edit page. When using the plugin Share Buttons by AddThis for WordPress (https://wordpress.org/plugins/addthis/), this code snippet aims to resolve this problem described here https://wordpress.org/support/topic/include-a…
<?php
/**
* Controls the display of the AddThis Sharing Sidebar style using the
* show/hide Addthis sharing radio buttons in admin post add/edit page.
*/
add_action( 'wp', 'ctrl_addthis_sidebar' );
function ctrl_addthis_sidebar() {
if ( get_post_meta( get_the_ID(), '_at_widget', true ) == 0 ) {
global $AddThis_addjs_sharing_button_plugin;
remove_action( 'wp_footer', array( $AddThis_addjs_sharing_button_plugin, 'output_script' ) );
@elvismdev
elvismdev / require-post-title.php
Last active November 2, 2022 12:08
Require post title at backend WordPress editor
<?php
add_action( 'edit_form_advanced', 'force_post_title' );
function force_post_title( $post ) {
// List of post types that we want to require post titles for.
$post_types = array(
'post',
'report',
// 'event',
@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 / 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 / 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 / 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 / FindMultipleGenesFromFile.java
Last active July 4, 2023 05:30
A Java small class to find all the genes from a DNA string stored in a plain text file. 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 from a DNA string file and using StorageResource class.
*
* @author (Elvis Morales)
* @version (1.0)
*/
import edu.duke.*;
import java.io.File;
@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) {