Skip to content

Instantly share code, notes, and snippets.

View mtio's full-sized avatar
📍
pull it push it branch it fork it ... technology

Chris mtio

📍
pull it push it branch it fork it ... technology
View GitHub Profile
@mtio
mtio / rank.php
Created April 20, 2016 19:06
Getting a condensed array associated by a key term and making it an index-able array. Sorting that array by a specified key. Also start of a removeOutliers function.
protected function removeOutliers($terms)
{
$dataToCheck = ['searchVolume'];
$sorted = $this->sortTerms($terms, 'searchVolume');
foreach($dataToCheck as $dataTerm) {
$house = [];
$mean = 0;
foreach($sorted as $data) {
array_push($house, $data[$dataTerm]);
$mean += $data[$dataTerm];
@mtio
mtio / gulpfile.js
Last active February 16, 2021 10:05
Simple gulp file to run Composer install
'use strict';
// Besure gulp-composer is installed
// npm install --save gulp-composer
var gulp = require('gulp');
var composer = require('gulp-composer');
gulp.task('default', ['composer']);
@mtio
mtio / ExplodingCamels
Created May 3, 2016 22:40
How to explode a camel cased string
filters: {
'explodingCamels': function(string) {
var toReturn = '';
for (var i = 0; i < string.length; i++) {
var character = string.charAt(i);
if (isNaN(character * 1)) {
if (i != 0 && character == character.toUpperCase()) {
toReturn += ' ';
}
}
<!doctype html>
<html>
<head>
<!-- jQuery import -->
<script src="https://code.jquery.com/jquery-latest.js"></script>
<!-- Latest compiled and minified JavaScript -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> -->
<!-- Latest compiled and minified CSS
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
@mtio
mtio / mergeTwoArraysPHP
Created May 17, 2016 18:10
Merge two arrays with common values into a single array.
array_map(function($val) {
if (array_search($val, $this->cities) === false) {
$this->cities[] = $val;
}
}, array_merge($popConcert, $popSports));
@mtio
mtio / webservices.php
Last active May 17, 2016 21:05
Registering taxonomies with wordpress
public function register_taxonomies()
{
$tags = [
'performer' => [
'name' => _x( 'Performers', 'taxonomy general name' ),
'singular_name' => _x( 'Performer', 'taxonomy singular name' ),
'search_items' => __( 'Search Performers' ),
'all_items' => __( 'All Performers' ),
'parent_item' => null,
$cats = [
'parent',
'children',
'grandchildren'
];
$args = [];
for ($i = 0; $i < count($cats); $i++) {
@mtio
mtio / JavascriptObjectStringToJsonString.php
Last active June 21, 2016 19:43
Takes a string that was a Javascript object and formats it to a JSON String
<?php
private function formatJsObjectToJson($jsObjectString)
{
return implode(',', array_map( function($y) { if (!$y) { return '""'; } return $y; }, explode(',', preg_replace_callback('/({|,)(\w*):+/', function($e) { return $e[1] . '"' . $e[2] . '":'; }, $jsObjectString))));
}
@mtio
mtio / mixins.js
Created July 15, 2016 21:39
Handy mixins for any Vuejs file
module.exports = {
filters: {
'format_kebab_case' : function(str) {
var x = str.split('_');
x.forEach(function(el, i) {
x[i] = this.replaceAt(el, 0, el.charAt(0).toUpperCase())
}, this);
return x.join(' ');
random