Skip to content

Instantly share code, notes, and snippets.

View chrisciampoli's full-sized avatar

Christopher Ciampoli chrisciampoli

View GitHub Profile
@chrisciampoli
chrisciampoli / highlightit.js
Last active December 3, 2020 21:05
My plugin version
/*!
* URL Highlighter by Christopher Ciampoli (2014)
*
!
*/
(function($) {
$.fn.highlightit = function() {
$this = this;
var debug = false;
@chrisciampoli
chrisciampoli / list.js
Last active March 13, 2024 11:11
Javascript List ADT (Abstract Data Type)
function List() {
this.listSize = 0;
this.pos = 0;
this.dataStore = []; // initializes an empty array to store list elements
this.clear = clear;
this.find = find;
this.toString = toString;
this.insert = insert;
this.append = append;
this.remove = remove;
@chrisciampoli
chrisciampoli / gist:29ace906deb80f05763e
Created October 8, 2014 21:12
jQuery.Ajax Scaffold
$.ajax({
url: url,
type: type,
dataType: dataType,
data: data,
beforeSend: function(data) {
beforeSend(data);
},
success: function(data) {
success(data);
@chrisciampoli
chrisciampoli / scaled.php
Created October 15, 2014 18:29
Create a scaled image from PHP
/**
* Creates scaled version of source image, optionally cropping.
* Handles scaling and centering in target size properly.
*
* $options = array(
* 'upload_dir' => thumbnail destination directory (required)
* 'thumb_name' => thumbnail filename in destination directory (required)
* 'dst_width' => target image width (required)
* 'dst_height' => target image height (required)
* 'target_format' => format to save to, defaults to source format, one of 'imagejpeg','imagegif','imagepng'
@chrisciampoli
chrisciampoli / meta.js
Created November 2, 2014 06:09
Get image sizes from meta
function getMeta(url, fn) {
var sizes = {};
$('<img />').attr("src", url).load(function() {
var dims = {
w: this.width,
h: this.height
};
$(this).trigger({
type: "imgLoaded",
height: dims.h,
@chrisciampoli
chrisciampoli / gist:4ae0f87510a696939593
Last active August 29, 2015 14:10
Custom Calendar
sctr.addModule('calendar', function() {
/**
Creates a 7 day week
@param prev
@param next
TODO: move prev, next into their own methods to update curr
*/
var bindSortable, checkImage, checkWeek, initWeek, processResults, renderWeek, saveSchedule, updatePool;
@chrisciampoli
chrisciampoli / jquery.custom-calendar.js
Last active August 29, 2015 14:11
jQuery Calendar Plugin (Custom Cal)
/**
The basic premise of this plugin is that you start out with a header
which displays the month/week, and the next/prev buttons. You are
then free to setup you own rendering of the actual calendar week
in a div of your choosing. Sample usage as follows:
Your calendar control header: <div id="cal-header"><h4 id="week-title"></h4></div>
Calendar initialize: $('#cal-header').chriscal({
'body': define your calendar body here,
'next_btn': define your next button to change to next week,
function AngleCalc() {
function fromTime(min, hour){
var minPercent = minutesToPercent(min),
hrPercent = hoursToPercent(hour, minPercent),
minDegree = percentageToDegree(minPercent),
hrDegree = percentageToDegree(hrPercent),
smallAngle = smAngle(minDegree, hrDegree),
largeAngle = lgAngle(minDegree, hrDegree);
@chrisciampoli
chrisciampoli / sortem
Created April 22, 2015 23:57
Sort them~
var downloadables = document.getElementsByClassName('download-links');
for (var op = 0;op < downloadables.length;++op) {
var list = downloadables[op];
var items = list.childNodes
console.log(items);
var itemsArr = [];
for (var i in items) {
if (items[i].nodeType == 1) {
@chrisciampoli
chrisciampoli / removeem
Created April 27, 2015 20:45
Remove KEYS from PHP to JSON
private function fix_keys($array) {
$numberCheck = false;
foreach ($array as $k => $val) {
if (is_array($val)){
$array[$k] = $this->fix_keys($val);
}
if(is_numeric($k)){
$numberCheck = true;
}
}