Skip to content

Instantly share code, notes, and snippets.

View afryer's full-sized avatar

Anthony afryer

  • Between a rock and a hard place
View GitHub Profile
@afryer
afryer / 0_reuse_code.js
Created August 9, 2017 16:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@afryer
afryer / gist:063cbdb3a68f39ae86df
Created February 10, 2016 11:31
preferences.sublime
{
"tab_size": 2,
"translate_tabs_to_spaces": false,
"trim_trailing_white_space_on_save": true,
}
@afryer
afryer / gist:9110628
Last active August 29, 2015 13:56
start of image to indexDB
function getBase64Image(img) {
// Create an empty canvas element
var canvas = document.createElement("canvas");
var canvasImg = new Image();
$(canvasImg).attr('src',img.src);
console.log(img);
console.log(canvasImg);
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
// private method
// Wraps the HTML in a TAG, Tag is optional
// If the html starts with a Tag, it will wrap the context in that tag.
// doesn't ACTUALLY work
function wrap(xhtml, tag) {
// new approach
// createDocumentFragment
var docFrag = document.createDocumentFragment(),
dummy,
wrapTag;
@afryer
afryer / gist:5815468
Created June 19, 2013 15:57
tiny custom selects
<script type="text/javascript">
$('select').each(function () {
var title = this.options[this.selectedIndex].text;
$(this).css({ opacity: '0', zIndex: '9999' });
$(this).after('<span class="select">' + title + '</span>');
});
$('select').change(function () {
var getvalue = this.value;
var title = this.options[this.selectedIndex].text;
@afryer
afryer / gist:5806844
Created June 18, 2013 16:22
jquery v1.10.1
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
@afryer
afryer / _pems.scss
Created May 31, 2013 20:38 — forked from mrdanadams/_pems.scss
Px to ems
/* See http://mrdanadams.com/2012/pixel-ems-css-conversion-sass-mixin/ */
/* Default font size in pixels if not overridden. */
$baseFontSize: 16;
/* Convert PX units to EMs.
Ex: margin-right: pem(16);
*/
@function pem($pxval, $base: $baseFontSize) {
@return #{$pxval / $base}em;
@afryer
afryer / Default (Windows).sublime-keymap
Created May 28, 2013 08:27
user added shortcuts sublime text 2
[
{ "keys": ["ctrl+shift+b"], "command": "insert_snippet", "args": {"contents": "${TM_COMMENT_START/s*$//} ==${1/./=/g}==${TM_COMMENT_END/^s*(.+)/ $1/}\n${TM_COMMENT_START/s*$//} = ${1:Banner} =${TM_COMMENT_END/^s*(.+)/ $1/}\n${TM_COMMENT_START/s*$//} ==${1/./=/g}==${TM_COMMENT_END/^s*(.+)/ $1/}"}},
{ "keys": ["super+shift+l"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}, "context":
[
@afryer
afryer / gist:5643974
Created May 24, 2013 14:37
Sublime Text keyword bindings
[
{ "keys": ["ctrl+shift+b"], "command": "insert_snippet", "args": {"contents": "${TM_COMMENT_START/s*$//} ==${1/./=/g}==${TM_COMMENT_END/^s*(.+)/ $1/}\n${TM_COMMENT_START/s*$//} = ${1:Banner} =${TM_COMMENT_END/^s*(.+)/ $1/}\n${TM_COMMENT_START/s*$//} ==${1/./=/g}==${TM_COMMENT_END/^s*(.+)/ $1/}"}},
{ "keys": ["super+shift+l"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}, "context":
[