Skip to content

Instantly share code, notes, and snippets.

View Sitebase's full-sized avatar
🤘

Wim Mostmans Sitebase

🤘
View GitHub Profile
@Sitebase
Sitebase / gravatar.js
Created November 13, 2014 12:03
Little trick to check if a gravatar is available or not for a certain email address.
var http = require('http'),
md5 = require('MD5');
var options = {
method: 'HEAD',
host: 'www.gravatar.com',
port: 80,
path: '/avatar/' + md5('info@blabla.be') + '?d=http://bla.com'
};
var req = http.request(options, function(res) {
@Sitebase
Sitebase / code.php
Created December 2, 2014 11:18
Example of a very basic unit test in PHP
<?php
function sum( $number1, $number2 )
{
if( ! is_int( $number1 ) || ! is_int( $number2 ) )
throw new Exception( 'Both arguments should be numeric' );
return $number1 + $number2;
}
@Sitebase
Sitebase / gist:e68497ef7c4bad436385
Created December 9, 2014 09:25
Snippet for implementing video attach to a form with BuboBox
<div class="bbbx-widget" data-widget="11"></div>
<script type="text/javascript">
var bbbx_widget_id = 11;
var bbbx_visual = false;
var bbbx_share_enabled = false;
function bbbx_config() {
this.subscribe('published', function(e) {
BBBX.$('.bubobox_result').html('<a href="javascript:mybb.openPlayer(\'' + e.entryId + '\')">Video bekijken</a> | <a href="javascript:mybb.openRecorder()">Video opnieuw opnemen</a>');
BBBX.$('#video_id').val(e.entryId);
@Sitebase
Sitebase / deltag.sh
Created January 9, 2015 08:35
Batch git tag delete locally and remote
# replace "release-" on the following line with the string you want to search for
# or remove the "| grep release-" part to remove all local and remote tags
for t in `git tag | grep release-`
do
echo "delete $t"
git push origin :$t # Delete remote
git tag -d $t # Delete local
done
@Sitebase
Sitebase / bbbx-reorder-stack-script.js
Created January 12, 2015 14:42
Reorder BuboBox stack items
var bbbx_stack_presets = {
'overlay' : {
modules: [
'pre',
'terms.pre',
'terms',
'terms.post',
'overlay.pre',
'overlay',
'overlay.post',
@Sitebase
Sitebase / gist:355fc595129862cb245f
Created February 3, 2015 13:00
Example ambassador tracking script
<script>
(function(i,s,o,g,r,a,m){i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};
a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=a.defer=1;a.src=g;
m.parentNode.insertBefore(a,m)})(window,document,'script','//api.bubobox.com/tracker.js','_bbq');
_bbq('init', { user_id: 1, segment: 'website' });
</script>
@Sitebase
Sitebase / server.js
Created February 4, 2015 08:51
Force https in express
var app = express();
...
app.use(function(req, res, next) {
if (req.headers['x-forwarded-proto'] === 'https') {
next(); // already on https so just continue
else
res.redirect('https://' + req.headers.host + req.url); // redirect to https
});
@Sitebase
Sitebase / gist:8da8495981672a23daa3
Created February 19, 2015 10:00
I think we all can agree that the focus outlines are ugly and in most cases destroy the visual aspect of elements. With this snippet you can set the outline to none and still give the user some feedback about where on the page the focus is. For an example of this take a look at the first button in this screenshot https://www.dropbox.com/s/bl3x74…
*:focus:before {
content: "⇥";
position: absolute;
font-size: 0.8em;
left: 5px;
top: -30%;
}
@Sitebase
Sitebase / template.html
Created March 19, 2015 15:18
Twitter tegel template
<link href='http://fonts.googleapis.com/css?family=Coming+Soon' rel='stylesheet' type='text/css'>
<style>
* {
box-sizing: border-box;
}
body{
/* defaults, use for testing the template without PhantomJS */
width: 400px;
height: 400px;
font-size: 400px;
@Sitebase
Sitebase / template.html
Created March 19, 2015 15:19
Quote template
<link href='http://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
<style>
body{
/* defaults, use for testing the template without PhantomJS */
width: 400px;
height: 400px;
background-color: #2e3192;
font-size: 400px;