Skip to content

Instantly share code, notes, and snippets.

View rblakejohnson's full-sized avatar

Blake Johnson rblakejohnson

View GitHub Profile
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modal Sans-JS</title>
<style>
* { box-sizing: border-box }
body {
@rblakejohnson
rblakejohnson / new_gist_file.js
Created December 11, 2013 18:36
delay action on keypress to improve performance
var i = 0;
$('input').keypress(function() {
if (this.timeoutId) {
window.clearTimeout(this.timeoutId);
}
this.timeoutId = window.setTimeout(function () {
// do something
}, 200);
});
[
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["ctrl+s"], "command": "toggle_side_bar" },
{ "keys": ["super+shift+r"], "command": "reindent" }
]
@rblakejohnson
rblakejohnson / setEndOfContenteditable
Created January 10, 2018 21:45
Set cursor to the end of Contenteditable
function setEndOfContenteditable(contentEditableElement) {
var range = document.createRange();//Create a range (a range is a like the selection but invisible)
var selection = window.getSelection();//get the selection object (allows you to change selection)
range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
selection.removeAllRanges();//remove any selections already made
selection.addRange(range);//make the range you have just created the visible selection
}
// found here https://stackoverflow.com/posts/3866442/revisions
function fakeRequest(delay=1000, result='success') {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (result === 'success') {
resolve();
}
if (result === 'error') {
reject();
}
if (result === 'random') {

Keybase proof

I hereby claim:

  • I am rblakejohnson on github.
  • I am beedewok (https://keybase.io/beedewok) on keybase.
  • I have a public key ASDIFdqVU3kvAV17EJHHYaeFew7tkOeQTx1rPMkacfVYRAo

To claim this, I am signing this object: