Skip to content

Instantly share code, notes, and snippets.

View samsargent's full-sized avatar

Sam Sargent samsargent

View GitHub Profile
@samsargent
samsargent / download-wordpress.sh
Created July 30, 2015 05:11
Download Latest Wordpress
wget http://wordpress.org/latest.tar.gz && tar xfz latest.tar.gz && rm -rf wordpress/wp-content/ && mv wordpress/* ./ && rm -rf wordpress/ && rm -rf latest.tar.gz
@samsargent
samsargent / Find & Replace Data in MySQL
Created June 21, 2012 11:26
Find & Replace Data in MySQL
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
@samsargent
samsargent / lazyload3rdpartyscripts.js
Created September 3, 2012 04:41
Lazy Loading those 3rd Party Social Widgets slowing down your site (from html5rocks.com)
window.thirdParty = {
init: function() {
$('.share').before('<div class="share preview" onmouseover="thirdParty.load(this);"><img src="/static/images/share.png"></div>');
},
load: function(el) {
$(el).remove();
thirdParty.plus1();
thirdParty.twitter();
@samsargent
samsargent / gist:4069978
Created November 14, 2012 02:45
Social Share Count using the JSON API's
$.getJSON("http://urls.api.twitter.com/1/urls/count.json?url=%%URL%%&callback=?", function(data) {
if ((data.count != 0) && (data.count != undefined) && (data.count != null)) {
$("#twbutton").addClass('hascount');
$("#twbutton").after('<a class="button count"><span>'+data.count+'</span></a>');
}
});
$.getJSON("https://graph.facebook.com/%%URL%%&callback=?", function(data) {
if ((data.shares != 0) && (data.shares != undefined) && (data.shares != null)) {
$("#fbbutton").addClass('hascount');
@samsargent
samsargent / gist:4248667
Created December 10, 2012 05:48
Loading Users Youtube Videos
$.getJSON("http://gdata.youtube.com/feeds/api/users/{{username}}/uploads?v=2&alt=jsonc&max-results=30", function (data) {
//profit??
});
@samsargent
samsargent / gist:4248885
Created December 10, 2012 06:47
Dev to production domains in Wordpress
update `wp_options` set `option_value` = replace(`option_value`,'website.dev','beta.example.com');
update `wp_posts` set `guid` = replace(`guid`,'website.dev','beta.example.com');
update `wp_posts` set `post_content` = replace(`post_content`,'website.dev','beta.example.com');
update `wp_postmeta` set `meta_value` = replace(`meta_value`,'website.dev','beta.example.com');
/*
Going from a development domain to a beta or production url - updating your wordpress database in a few queries. There may or may not be other tables/settings that should be update. I've found the above to work for me.
@samsargent
samsargent / snippets.sh
Created October 27, 2015 00:13
SSH Snippets
# for the things I rarely do but often forget
# copy files via ssh
scp foobar.txt your_username@remotehost.com:/some/remote/directory
@samsargent
samsargent / gist:5087587
Created March 5, 2013 02:44
Adding SSH Keys to Authorized_Keys
cat ~/.ssh/id_rsa.pub | ssh USER@HOST "cat >> ~/.ssh/authorized_keys"
@samsargent
samsargent / latest-tweets.js
Created April 15, 2013 06:34
Grab latest tweets from Twitter API
/*
Latest Tweets Plugin
Markup required:
<div class="latestTweets" data-user="unitseven" data-count="3"></div>
*/
(function( $ ) {
"use strict";
function relative_time(time_value) {