Skip to content

Instantly share code, notes, and snippets.

View edbentinck's full-sized avatar

Ed Bentinck edbentinck

View GitHub Profile
@edbentinck
edbentinck / change_instance.sh
Created October 16, 2021 12:57 — forked from nicosnyman/change_instance.sh
Easily change instance types on AWS EC2 with a bash script
#!/bin/bash
# Nico Snyman, nico@gammafly.com, 14/05/2015
# Change an instance type, while keeping snapshots
# This script will stop an instance identified by instance ID,
# take snapshots of all atached volumes, and restart it
# Use:
# -i instance ID - REQUIRED - stored in instance_id
# -t instance new instance type - REQUIRED - stored in instance_type
# -s if set to 0, no snapshot will be taken, dafault is 1
# (take snapshot of attached volumes) - stored in snapshot
@edbentinck
edbentinck / color_luminance.php
Created January 13, 2017 12:12 — forked from stephenharris/color_luminance.php
Lighten or darken a given colour
<?php
/**
* Lightens/darkens a given colour (hex format), returning the altered colour in hex format.7
* @param str $hex Colour as hexadecimal (with or without hash);
* @percent float $percent Decimal ( 0.2 = lighten by 20%(), -0.4 = darken by 40%() )
* @return str Lightened/Darkend colour as hexadecimal (with hash);
*/
function color_luminance( $hex, $percent ) {
// validate hex string
@edbentinck
edbentinck / saveBeforeExitDirective.js
Created November 13, 2015 19:49
AngularJS save form before exit (both changing url or closing the window/tab)
angular.module('saveBeforeExitExample', [])
.directive("saveBeforeExit", ["notificationService", function(notificationService) {
"use strict";
return {
link: function(scope, element, attrs) {
window.onbeforeunload = function(){
if (element.hasClass("ng-dirty")) {
element.submit();
}
@edbentinck
edbentinck / countries.php
Created November 12, 2015 16:22 — forked from JeffreyWay/countries.php
Country Names + Codes
[
"United States" => "us",
"Afghanistan" => "af",
"Albania" => "al",
"Algeria" => "dz",
"American Samoa" => "as",
"Andorra" => "ad",
"Angola" => "ad",
"Anguilla" => "ai",
"Antarctica" => "aq",
@edbentinck
edbentinck / Ignore .DS_Store forever
Created November 7, 2015 11:59 — forked from linuslundahl/Ignore .DS_Store forever
Make git always ignore .DS_Store
$ git config --global core.excludesfile ~/.gitignore
$ echo .DS_Store >> ~/.gitignore
@edbentinck
edbentinck / gist:939e5c06e71e0ef16b7c
Last active September 18, 2015 06:02 — forked from thomseddon/gist:4703968
Auto Expanding/Grow textarea directive for AngularJS
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 Thom Seddon
* Copyright (c) 2010 Google
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@edbentinck
edbentinck / jquery.draghover.js
Last active September 10, 2015 05:40 — forked from meleyal/jquery.draghover.js
jquery.draghover.js
/*
jquery.draghover.js
Emulates draghover event by tracking
dragenter / dragleave events of element + children.
https://gist.github.com/gists/3794126
http://stackoverflow.com/a/10310815/4196

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

/**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
@edbentinck
edbentinck / wordpress_dropdown_menu
Last active August 29, 2015 14:01 — forked from hitautodestruct/readme.md
Create custom WordPress menu navigation, including sub-menus
<?php
$menu_name = 'primary';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<nav>
<ul class="nav site-nav l-container l--fullwidth">
<?php