Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / indexOfType.js
Created July 11, 2013 15:19
Snippet will return a 1-based-index of an element in relation to like tags at same level.
// Return 1-based-index of an element in relation to like tags
function indexOfType(element) {
var prev = element.prevAll(element[0].tagName);
if ( empty(prev) ){
return 1; // For 1 indexing
}
else return 1 + prev.length;
}
@ebinnion
ebinnion / interaction.js
Last active May 28, 2021 12:47
Will generate xpaths when elements clicked
/*!
* jQuery Cookie Plugin v1.3.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
@ebinnion
ebinnion / config.php
Created May 31, 2013 14:01
Dynamically set CodeIgniter Base URL
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";
@ebinnion
ebinnion / gist:5593813
Last active December 17, 2015 10:19
Followerwonk Social Authority API Code Example
<?php
// Not currently working.
// Example Output
/*
https://api.followerwonk.com/social-authority?screen_name=randfish;AccessID=member-NTFhMjQxOTQtYTcwNi01YzI4LTk0OTYtZDZlY mRlYzJiMjVk;Timestamp=1368728186;Signature=S97mqDTS0qngjKR41hPhdO4BHpE%3D
"401 Unauthorized"
*/
@ebinnion
ebinnion / gist:5095189
Last active June 14, 2017 15:44
Facebook centered pop up share
<script type="text/javascript">
function fbs_click(width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
@ebinnion
ebinnion / gist:5045658
Created February 27, 2013 06:24
Random String Javascript
var numRand = String((new Date()).getTime()).replace(/\D/gi,'')
@ebinnion
ebinnion / gist:5045409
Created February 27, 2013 05:36
Youtube Popup on Subscriber page
<!-- This link will take someone to your youtube channel then present them with a subscribe popup-->
<a href="http://www.youtube.com/subscription_center?add_user=artofblog">Text</a>
@ebinnion
ebinnion / gist:5027845
Created February 25, 2013 04:58
Download and Redirect in jQuery
$(".downloadLink").click(
function(e) {
e.preventDefault();
//open download link in new page
window.open( $(this).attr("href") );
//redirect current page to success page
window.location="www.example.com/success.html";
window.focus();
@ebinnion
ebinnion / Git Cheat Sheet
Last active December 13, 2015 23:19
A short list I'll manage of my most used git commands
git init - "Self explanatory"
git remote add origin [git_url] - "Adds a remote repository named origin"
git add . - "Add files you want to commit"
git add -u - "Will remove deleted files from git"
git commit -m 'your message' - "Commit with a message"
git push origin master - "Push repository to Github"
git update-index --assume-unchanged [[path]] - Will ignore file from git unless explicitly added
git reset --soft HEAD^ - Deletes last commit and keeps any code changes
git commit --amend --reuse-message HEAD
@ebinnion
ebinnion / terminal.txt
Last active December 12, 2015 07:58
Ubuntu Rsync Command. This command was used to backup computers in the MSU CS server room. Command will login to remote server, create a tar of the directory, then put the tar in the specified backup director (/backup in this case).
sudo rsync -arv -e "ssh" --rsync-path="sudo rsync" user@host:/home /backup