Skip to content

Instantly share code, notes, and snippets.

View seanmcn's full-sized avatar
🐝

Seán McNamara seanmcn

🐝
View GitHub Profile
@seanmcn
seanmcn / jQueryDroppable.js
Last active March 11, 2016 07:41
jQuery Droppable (Accept only one Draggable)
$(".drop_area").droppable({
tolerance: "intersect",
accept: ".drop_item",
greedy: true,
drop : function(event, ui) {
$(this).droppable( "option", "disabled", true );
},
out : function(event, ui) {
$(this).droppable( "option", "disabled", false );
},
@seanmcn
seanmcn / createFilesNumeric.php
Last active December 17, 2015 07:49
Simple script to create any number of files in a folder.
<?php
$count = 1;
while($count <= 20) {
$path = "D:\\web\\www\\website\\folder\\";
$filename = $count.".html";
$file = fopen($path.$filename, "w");
echo $filename." has been created! <br />";
$count++;
}
?>
@seanmcn
seanmcn / MySQL Data to CSV.php
Last active August 29, 2015 14:10
Converts mySQL data to CSV data
<?php
/* Database Info */
$server = "localhost";
$username = "username";
$password = "password";
$databaseName = "databaseName";
/* Table we want to export */
$tableName = "tableName";
/* Optional WHERE Statement */
//$whereStatement = "WHERE field = value";
@seanmcn
seanmcn / Controller_addProject.php
Last active August 29, 2015 14:10
Using Codeigniter Form + Validation Libraries
/*
* Controller for Projects
*/
public function addProject() {
$this->load->helper('form');
$this->load->library('form_validation');
$config = array(
array(
'field' => 'client',
'label' => 'Client Name',
@seanmcn
seanmcn / Model_addProject.php
Last active August 29, 2015 14:10
Using Codeigniter's ActiveRecord
/*
* Model for Projects
*/
function addProject($client, $projectName, $price, $deadline, $notes) {
$project = array(
"client_id" => $client,
"user_id" => $this->session->userdata('user_id'),
"name" => $projectName,
"price" => $price,
"deadline" => $deadline,
@seanmcn
seanmcn / contestantPercentage.php
Last active August 29, 2015 14:10
Returning a contestants percentage of votes
<?php
/* Gets the count of all votes for a specific poll */
public function totalVoteCount($pollId) {
$this->db->select("*");
$this->db->where("poll_id", $pollId);
$count = $this->db->count_all_results('votes');
return $count;
}
/* Returns the percentage of votes a contestant has in a specific poll */
public function getContestantPercentage($pollId, $contestantId) {
<?php
public function uploadImage() {
$this->load->library('upload');
$imageFolder = 'assets/images/features';
if (!file_exists($imageFolder)) {
mkdir($imageFolder, DIR_WRITE_MODE, true);
}
$this->upload_config = array(
'upload_path' => $imageFolder,
'allowed_types' => '*',
@seanmcn
seanmcn / eduSessions.php
Last active August 29, 2015 14:10
Edusessions wordpress pluigin
<?php
/*
Plugin Name: Education Session Plugin
Plugin URI: http://coder.ie/
Description: Custom Plugin for IFAN
Version: 1.0
Author: Sean McNamara
Author URI: http://seanmcn.com/
*/
register_activation_hook(__FILE__,'edusession_plugin_install');
@seanmcn
seanmcn / timeDifference.php
Created December 3, 2014 05:35
Some legacy code from OTS
<?php
/*
* Author: Sean McNamara
* Some legacy code from OTS
*/
$tr_date = strtotime($options['tr_date']);
$fest_date = strtotime($options['fest_date']);
$games_date = strtotime($options['games_date']);
$now = strtotime("now");
@seanmcn
seanmcn / customiser.js
Created December 3, 2014 05:40
Product Customiser for
/*
* Product Customiser for Celtic Commemorations
* @Documentation: http://lmgtfy.com/?q=jquery+documentationl=1
*/
var popupStatus = 0; //0 means disabled; 1 means enabled;
var page = 0;
var text = 0;
var textAreaStatus = 0;
var currentTextAreas = 0;
var maxTextAreas = 3;