Skip to content

Instantly share code, notes, and snippets.

View MikeRogers0's full-sized avatar
๐Ÿš‚

Mike Rogers MikeRogers0

๐Ÿš‚
View GitHub Profile
@MikeRogers0
MikeRogers0 / apache-benchmark.sh
Created August 24, 2013 12:24
An example of how to use apache benchmark
ab -n 25 -c 5 http://mikerogers.io
@MikeRogers0
MikeRogers0 / resize-image.js
Last active February 18, 2025 14:08
An example of how to resize an image on the fly with javascript.
// The function that scales an images with canvas then runs a callback.
function scaleImage(url, width, height, liElm, callback){
var img = new Image(),
width = width,
height = height,
callback;
// When the images is loaded, resize it in canvas.
img.onload = function(){
var canvas = document.createElement("canvas"),
$('form.fileEdit input[type="submit"]').on('click', function(e) {
e.preventDefault();
var _$thisElem = $(this);
$.getJSON(ADMIN_URL+'filemanager/editfile',
_$thisElem.parent('form').serialize(),
function(data) {
alert(data);
getFiles({clearout:true});
}
);
@MikeRogers0
MikeRogers0 / wp-loop.php
Last active December 20, 2015 23:49
Question: Instead of each post going into it's own <li>, what if I wanted three posts per <li> element? Answer: loop
<ul class="slides">
<li>
<?php
$count = 0;
query_posts('post_type=testimonials&posts_per_page=-1'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h3>
<?php the_post_thumbnail(); ?>
<?php the_title();?>
<span><?php the_field('job_position'); ?></span>
</h3>
@MikeRogers0
MikeRogers0 / backup-to-s3.sh
Last active May 19, 2020 15:33
A method of backing up your website to Amazon S3.
#!/bin/bash
## Email Variables
EMAILDATE=`date --date="today" +%y-%m-%d`
EMAIL="[email protected]"
SUBJECT="[servername] Backup Script Started! - "$EMAILDATE
EMAILMESSAGE="/tmp/emailmessage1.txt"
echo "Just to let you know that the backup script has started."> $EMAILMESSAGE
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
@MikeRogers0
MikeRogers0 / twitter-proxy.php
Last active June 3, 2019 12:56
This is a neat little script you can use to quickly make OAuth requests to the twitter rest API v1.1.
<?php
/**
* Usage:
* Send the url you want to access url encoded in the url paramater, for example (This is with JS):
* /twitter-proxy.php?url='+encodeURIComponent('statuses/user_timeline.json?screen_name=MikeRogers0&count=2')
*/
// The tokens, keys and secrets from the app you created at https://dev.twitter.com/apps
$config = array(
@MikeRogers0
MikeRogers0 / js.js
Created February 9, 2013 20:35
UoP Computing Guy
document.getElementById('itemName').innerHTML = '<font size="8">' + response + '</font> <button onclick="itemNameAllowEdit("' + response + '");">Edit</button>';
$query = '
CREATE TABLE products (
product_id int not null auto_increment PRIMARY KEY,
product_name varchar(100),
description varchar(200),
photo_url varchar(100),
price decimal(4,2),
stock_level decimal(3,0)
);
';
@MikeRogers0
MikeRogers0 / ajax.js
Created December 10, 2012 15:52
Returns value from test.php file
function doSomething(xhr) {
var test = xhr.responseText + 'was found';
alert(test);
}
function ajaxReturn (file,func,data) {
var xhr = new XMLHttpRequest();
xhr.open("POST",file, false); // Adding in the false, means send will wait for a reply until continuing with the code.
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
@MikeRogers0
MikeRogers0 / hosts
Created November 24, 2012 23:11
Example virtual host configuration
127.0.0.1 localhost site-name.local