Skip to content

Instantly share code, notes, and snippets.

View Ultrabenosaurus's full-sized avatar

Dan Bennett Ultrabenosaurus

  • UK
View GitHub Profile
@Ultrabenosaurus
Ultrabenosaurus / overlay.html
Last active December 14, 2015 09:18
A super-simple overlay system with a message box.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Simple Overlay</title>
<style>
#overlay{
position:fixed;
top: 0px;
bottom: 0px;
@Ultrabenosaurus
Ultrabenosaurus / social-stats.php
Created June 24, 2013 06:57
Get the count of tweets, likes and +1's for a URL. Saved from this repo - https://github.com/whyisjake/Social-Stats - but I didn't feel it deserved an actual repo so I saved it as a gist, and also added a function that returns all three stats for you. Currently relies on some WordPress functions, will need to alter that at some point.
<?php
function make_get_tweets( $url ) {
$json_string = wpcom_vip_file_get_contents( 'http://urls.api.twitter.com/1/urls/count.json?url=' . $url );
$json = json_decode($json_string, true);
return intval( $json['count'] );
}
function make_get_likes( $url ) {
$json_string = wpcom_vip_file_get_contents('http://graph.facebook.com/?ids=' . $url);
@Ultrabenosaurus
Ultrabenosaurus / one-page.md
Last active December 18, 2015 21:38
why I will never agree with one-page, scroll-to-your-content sites

Take a simple 5-page site that just covers who you are, what you do, some example projects and contact info or something. I bookmark one of those pages so I can read it later when I have more time. I get home, open the bookmark and the page loads with only the relevant HTML, CSS and JS. Done.

Say that site is converted into a single-page, super-scroll site and the content equivalent to the page I bookmarked happens to have been placed at the bottom of this page. Now, when I open the bookmark (assuming there is a 301 set up correctly) I have to wait for the content from all the other pages to load as well before the page is ready. While this is happening I might start reading my content only to have the page grow as images load in, pushing my content down and making me lose my place. There might be a larger amount of CSS and JS as well because previously page-specific code will now need to be loaded every time, regardless of if it is needed for the content the user wants, which could hurt functionality.

It i

@Ultrabenosaurus
Ultrabenosaurus / git-lg
Last active August 29, 2015 14:04
Visual Git Commit History
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
@Ultrabenosaurus
Ultrabenosaurus / clog-php.sublime-snippet
Created September 18, 2014 09:07
basic logging of PHP values in Dev Tools console
<snippet>
<content><![CDATA[
echo "<script type='text/javascript'>if( window.console && console.log ){ var thing = " . json_encode( ${1:thing} ) . "; try{ console.log( JSON.parse(thing) ); }catch(e){ console.log( thing ); } }</script>";
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>clog</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
<!--
@Ultrabenosaurus
Ultrabenosaurus / ytsearch.sh
Last active December 20, 2020 23:33
ytsearch - search and launch YouTube videos from bash!
#!/bin/bash
# ytsearch
# original: https://coderwall.com/p/jvuzdg
# created by: Balazs Nadasdi <http://about.me/yitsushi>
# this version: https://gist.github.com/Ultrabenosaurus/8974206b2cba0f1c615a
# edited by: Dan Bennett <http://about.me/d.bennett>
# license: BSD 3-Clause <http://opensource.org/licenses/BSD-3-Clause>
#
# converted to a script for easier redistribution and development
@Ultrabenosaurus
Ultrabenosaurus / VagrantMySQL.rb
Last active August 29, 2015 14:06
VagrantMySQL - transfer and run SQL files in a single line, make a queue of SQL files/commands to process at once and in multiple boxes!
#
# VagrantMySQL
#
# A helper for interfacing with MySQL from your Vagrantfile
#
# @author Dan Bennett <http://about.me/d.bennett>
# @package Vagrant\Helpers
# @version 1.0.0
# @license BSD 3-Clause <http://opensource.org/licenses/BSD-3-Clause>
# @todo function DocBlocks!!!!
@Ultrabenosaurus
Ultrabenosaurus / README.md
Last active September 14, 2017 21:50
githash - get the short or full SHA for any commit in your current branch's history

githash

Easily get the short or full SHA for any commit in your current branch's history, useful for reverting and sharing specific code states with others.

Why?

Because typing out git rev-list --max-count=1 --abbrev-commit --skip=# HEAD takes far too much effort.

Installation

@Ultrabenosaurus
Ultrabenosaurus / sif.sublime-snippet
Created October 6, 2014 13:08
quick Sublime snippet for shorthand if statements in PHP and JS
<snippet>
<content><![CDATA[
( ( ${1:if} ) ? ${2:then} : ${3:else} )${4:;}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sif</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php,source.js</scope>
</snippet>
@Ultrabenosaurus
Ultrabenosaurus / gitprune.sh
Last active August 29, 2015 14:08
gitprune - delete local branches that aren't on origin
#! /bin/bash
#
# gitprune
#
# @author trustin <https://stackoverflow.com/users/55808/trustin>
# @source http://stackoverflow.com/a/22687460/1734964
# @license unknown, but original code was posted publicly with the intention of being used by others
# @modified Dan Bennett <http://ultrabenosaurus.ninja>
#