Skip to content

Instantly share code, notes, and snippets.

View zbee's full-sized avatar
👾

Ethan Henderson zbee

👾
View GitHub Profile
@zbee
zbee / Minecraft-API Example Fixes
Last active August 29, 2015 13:56
The Minecraft-API examples are rather derpy and not really working. I present you working ones.
CURRENT (BROKEN - It cannot possibly return a number of players from the API method that returns only true or false based on whether the server is up. The status method doesn't even return data.players)
var ip = "player.server.com";
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://minecraft-api.com/v1/status/?server=" + ip, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
data = JSON.parse(xhr.responseText);
if (data.status) {
@zbee
zbee / _claps
Last active August 29, 2015 14:01
claps.js
At some point in my life I needed to use JQuery's toggle(), show(), and hide() functions but could not use JQuery, so I made claps.js.
I have no idea why anyone else would need this -heck, I can't remember why I needed it-, but here it is anyways.
Enjoy.
@zbee
zbee / bootswatchList-postJS.html
Last active August 29, 2015 14:02
Use the bootswatch API to shift through and list all of their themes (With thumbnail and name
<!DOCTYPE html>
<html>
<body>
<div id="select">
<div class="Cerulean"><img src="http://bootswatch.com/cerulean/thumbnail.png" width="250px"><br>Cerulean<hr></div>
<div class="Cosmo"><img src="http://bootswatch.com/cosmo/thumbnail.png" width="250px"><br>Cosmo<hr></div>
<div class="Cyborg"><img src="http://bootswatch.com/cyborg/thumbnail.png" width="250px"><br>Cyborg<hr></div>
<div class="Darkly"><img src="http://bootswatch.com/darkly/thumbnail.png" width="250px"><br>Darkly<hr></div>
<div class="Flatly"><img src="http://bootswatch.com/flatly/thumbnail.png" width="250px"><br>Flatly<hr></div>
@zbee
zbee / unJQSerialize
Last active August 29, 2015 14:03
Format jQuery's serialize() in PHP as actual array
Ok, so when you serialize a form in JQuery - $('#my-form').serialize() - you get something like
title=cake&date=2014-07-10 2:56PM&content=cake cake cake&tags=cake&new=post
Obviously, that isn't super useful to PHP and unserialize() does nothing for it.
So, I made unJQSerialize(); which is a little function to go through the serialized form and break it down into an actual PHP array.
When unJQSerialize() is used, you'll get something like
[title] => cake [date] => 2014-07-10 2:56PM [content] => cake cake cake [tags] => cake [new] => post
@zbee
zbee / _wowCur.md
Last active May 16, 2024 03:34
World of Warcraft simple currency formatter

WoW Currency Formatter

When using the battle.net API amounts of currency (like how much money you have, or how much a buyout for an auction item is) are displayed as a simple amount of copper (example: 174056); And that's not human readable.

So, I made a little baby function to format into either g s c or the padded version (adds a 0 in front of silver and copper if it's a single digit).

Hope someone needs this eventually :)


Examples:

@zbee
zbee / strReplaceArr.js
Last active March 1, 2016 15:26
Replace one character in a string with a correlating item in an array of replacements
//Before now or writing your own function you could only do String.prototype.replacewith a search and a replacement,
//or an array of searches to be repalced with their matching item in an array of replacements.
//Meaning you couldn't do something like replace all question marks in `cake ? pie ? noodles` with a matching
//item in an array of replacements, like this: `thatString.replace("?", ["meat","veggies"])` and get something like
//`cake meat pie veggies noodles`, but now you can! :D (note: number of occurences of search must match count() of $replace)
//"?no?".replaceArray("?", ["s","w"]) //returns `snow`
if (!String.prototype.replaceArray) {
String.prototype.replaceArray = function(find, replace) {
var x = 0
@zbee
zbee / fileNav.php
Last active August 29, 2015 14:11
A simple little file to be set at the root of a directory with many images and subdirectories when enables easy viewing of images and navigation of directories.
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<Br>
<?php
function check($array, $input) {
foreach($array as $value) {
if(strpos($input, $value) !== false) {
return true;
return false;
}
@zbee
zbee / sexyTime.js
Last active August 29, 2015 14:13
sexyTime is a small jQuery plugin for short countdown timers.
(function ($) {
$.fn.sexyTime = function (options) {
var opts = $.extend({}, $.fn.sexyTime.defaults, options);
var time = opts.time;
return this.each(function() {
var position = $(this).position();
$(this).css("z-index", "100");
$(this).css("position", "relative");
$(this).css("text-align", "center");
@zbee
zbee / _iso8601.md
Last active March 13, 2016 16:32
How to do ISO 8601 in various languages (2015-01-14T20:55).
@zbee
zbee / ubuntuToWebsite.sh
Last active August 29, 2015 14:14
Get Ubuntu 14.04 running your php website
#Get ready
sudo apt-get update
sudo apt-get upgrade
#Install apache
sudo apt-get install apache2
#Install mysql
sudo apt-get install mysql-server php5-mysql
#Set up mysql
sudo mysql_install_db
sudo mysql_secure_installation