Skip to content

Instantly share code, notes, and snippets.

View Artistan's full-sized avatar

Charles Peterson Artistan

View GitHub Profile
@Artistan
Artistan / CLI.class.php
Created September 24, 2015 17:45 — forked from moiaune/CLI.class.php
Simple IO class for php CLI.
/*
* Description: Simple IO class for php CLI
* Author: Mads Aune
*/
if(!defined("STDIN")) { define('STDIN', fopen('php://stdin', 'r')); }
class CLI {
public static function getLine($prompt = '') {
echo $prompt . "> ";
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.
@Artistan
Artistan / .bash_profile
Created November 15, 2013 21:48
bash_profile settings
# USE cg img; // will show 2 lines before and 15 lines after match.
alias cg="find . -path '*/.svn/*' -prune -o -path '*/.git/*' -prune -o -path '*compiled*' -prune -o -type f -print | xargs -e grep -A 15 -B 2 --color -rnisIe "
# USE f img;
alias f="find . -path '*/.svn/*' -prune -o -path '*/.git/*' -prune -o -path '*compiled*' -prune -o -type f -print | xargs -e grep --color -rnisIe "
@Artistan
Artistan / find_and_replace.sh
Created November 15, 2013 21:50
find and replace
f 'findthistext' | xargs sed -i -e 's/findthistext/replacewiththistext/g';
# replace members/upload.php with upload.php
f 'members\/upload\.php' | xargs sed -i -e 's/members\/upload\.php/upload\.php/g';
# using my .bash_profile
# prevents changes to .svn and .git files!!!
f 'findthistext' | xargs sed -i -e 's/findthistext/replacewiththistext/g';
@Artistan
Artistan / bootstrapCDN.html
Created February 17, 2016 01:50 — forked from planetoftheweb/bootstrapCDN.html
Bootstrap 3 CDN Page Code
<!-- HEAD SECTION -->
<!-- IE Edge Meta Tag -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
@Artistan
Artistan / 1. jquery.ejax-query-datatables.js
Last active March 8, 2016 18:41
elastic search datatables query
/*! Ejax Datatables - v0.0.1 - 2016-02-19
* Copyright (c) 2016 charles peterson; Licensed MIT */
(function ($) {
/**
* debug_ejax = console.log alot of crap
* elastic_json = the query for elastic
* pkey = key to define the object data structure if y`ant to
* serverUrl = elasticsearch server search path
* callbackSearch = callback to change the search for your elastic_json based on databases search updates made by the user
* callbackRow = callback to modify result row
var location_timeout = setTimeout(function () {
navigator.geolocation.clearWatch(WatchID);
self.findLocationByIP(callback);
}, 15000);
var WatchID = navigator.geolocation.watchPosition(
function (position) { // Success callback
clearTimeout(location_timeout);
// use this transport for "blob" data type
// http://artandlogic.com/2013/11/jquery-ajax-blobs-and-array-buffers/
(function($){
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
@Artistan
Artistan / recursive.find.js
Last active April 3, 2016 23:54
Find properties within a javascript object/array
function recursiveIterationKey(object,matchKey) {
var found=false;
for (var property in object) {
if (object.hasOwnProperty(property)) {
if (typeof object[property] == "object"){
if(recursiveIterationKey(object[property])){
found=true;
break;
} else if(matchKey==property) {
found = true;
@Artistan
Artistan / object_join.js
Created May 4, 2016 04:18 — forked from lucasdavila/object_join.js
Joining javascript key-value objects as string.
Object.prototype.join = function(glue, separator) {
var object = this;
if (glue == undefined)
glue = '=';
if (separator == undefined)
separator = ',';
return $.map(Object.getOwnPropertyNames(object), function(k) { return [k, object[k]].join(glue) }).join(separator);