Skip to content

Instantly share code, notes, and snippets.

View seanmcn's full-sized avatar
🐝

Seán McNamara seanmcn

🐝
View GitHub Profile
@seanmcn
seanmcn / dspace_file_whereami.sql
Last active March 30, 2017 08:22
[Dspace] Get assetstore file path of bitstream using database
/*
Replace :asset_store_path, :handle and :sequence_id
*/
select
':asset_store_path' ||
substring(bit.internal_id, 1, 2) || '/' ||
substring(bit.internal_id, 3, 2) || '/' ||
substring(bit.internal_id, 5, 2) || '/' ||
bit.internal_id
from bitstream bit
@seanmcn
seanmcn / citeprocjs.js
Created March 12, 2015 05:29
CitationsJS
define(['jquery','citeproc'],function(require){
var cite = {};
var citations = {};
cite.renderCitations = function(){
var cslScheme = $("#id-from-csl-scheme-dropdown").val();
renderBib(cslScheme);
}
// Get the citations that we are supposed to render, in the CSL-json format, I switched async to false here for my setup, btu true is probably fine
@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active February 21, 2024 11:57
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
(function(global) {
var silpUrl = '//s3-eu-west-1.amazonaws.com/silp.shootitlive.com/js/silp.min.js';
// Globals
if(!global.Silp) { global.Silp = {}; };
var Silp = global.Silp;
// To keep track of which embeds we have already processed
if(!Silp.foundEls) Silp.foundEls = [];

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@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;
@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 / 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');
<?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 / 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) {