Skip to content

Instantly share code, notes, and snippets.

View anthonyec's full-sized avatar
🐢
eat the food and live

Anthony Cossins anthonyec

🐢
eat the food and live
View GitHub Profile
<snippet>
<content><![CDATA[<% console.log(${1:}) %>]]></content>
<tabTrigger>%cl</tabTrigger>
<scope>text.html</scope>
<description>Underscore template console log</description>
</snippet>
@anthonyec
anthonyec / DominantColors.cs
Created May 19, 2016 12:26 — forked from JimBobSquarePants/DominantColors.cs
An ImageProcessor Core equivalent to the output described at https://manu.ninja/dominant-colors-for-lazy-loading-images
/// <summary>
/// Returns a 1x1 pixel Base64 encoded gif from the given image containing a single dominant color.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="string"/></returns>
public static string ToBase64GifPixelString(this Image source)
{
// Leave the original image intact
using (Image temp = new Image(source))
{
@anthonyec
anthonyec / bitbucket_nested_coments.css
Last active October 2, 2016 22:06
Remove margin on nested comments
.child-comments {
margin-left: 0px;
}
@anthonyec
anthonyec / google_red_background.css
Created October 2, 2016 22:05
Make the background color red
body {
background: red;
}
@anthonyec
anthonyec / google_blue_background.css
Last active July 31, 2017 12:38
General Google homepage improvments
body {
background: silver;
}
@anthonyec
anthonyec / patch.json
Last active October 3, 2016 14:29
Patch: change google background color to red
{
"summary": "Wow",
"urls": [
"*.google.com/*"
],
"permissions": [
"css"
]
}
@anthonyec
anthonyec / bookmarklet.js
Last active September 4, 2018 08:30
GWT Template Bookmarklet for JIRA
(function(){
console.log('Bookmarklet loaded');
var template = '*Outcome*\nGiven \nWhen \nThen \n\n*Todo*\n* \n\n*Dev notes*\n* ';
var $tab = document.querySelector('.menu-item[data-mode="source"]');
var $text = document.querySelector('#description-wiki-edit .textarea');
// There are 2 tabs, "Visual" and "Text". Click "Text" if it exists.
if ($tab && !$tab.classList.contains('active-tab')) {
$tab.querySelector('a').click();
@anthonyec
anthonyec / bookmarklet.js
Last active September 5, 2018 08:12
WWW to Sandbox
(function() {
var currentLocation = location.href;
var currentLocationHasWww = currentLocation.indexOf('www.') !== -1;
var searchValue = currentLocationHasWww ? 'www.' : 'sandbox.';
var replacement = currentLocationHasWww ? 'sandbox.' : 'www.';
window.location = location.href.replace(searchValue, replacement);
})();
@anthonyec
anthonyec / getPlayerServing.js
Last active January 7, 2019 13:42
Ping Pong who is serving
function getPlayerServing(totalScore = 0, numberOfServesEach = 2, numberOfPlayers = 2) {
return Math.floor((totalScore / numberOfServesEach)) % numberOfPlayers;
}
// Singles
// Player 1 = 0, Player 2 = 1
getPlayerServing(11);
// Doubles
// Player 1 = 0, Player 2 = 1, Player 3 = 2, Player 4 = 3
handleDrop(evt, props) {
const itemToChange = this.state.find(id === props.id)
this.setState({
items: itemTOChange
});
}
<DragTarget onDrop={this.handleDrop}>