This is a very simple lightweight plugin to allow you to move the caret (or cursor) position in an <input /> or <textarea> element.
By exposing three jQuery.fn methods you can easily move a a caret to any position you like:
// In this example we detect if a user clicks a link to travel elsewhere | |
// but has made changes to a form. If they have changed the form it prompts | |
// them to confirm before continuing. | |
jQuery(function ($) { | |
var $form = $('form').watchChanges(); | |
$('a').click(function (e) { | |
if ($form.hasChanged() and ! confirm('Continue without saving changes?')) { | |
e.preventDefault(); | |
} |
<?php | |
/** | |
* Static singleton class for handling Assets | |
* | |
* @usage | |
* Asset::css('myscript.css'); | |
* | |
* Asset::css(array( | |
* 'my-script.css', | |
* 'another.css', |
Open your console. | |
<script src="event-source.js"></script> |
CodeMirror.defineMode("mustache", function (config, parserConfig) { | |
var mustacheOverlay = { | |
token: function (stream, state) { | |
if (stream.match("{{")) { | |
while ((ch = stream.next()) != null) | |
if (ch == "}" && stream.next() == "}") break; | |
return "mustache"; | |
} | |
while (stream.next() != null && !stream.match("{{", false)) {} | |
return null; |
#!/bin/sh | |
echo "Installing brew..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |
echo "Installing desktop apps..." | |
brew cask install google-chrome | |
brew cask install slack | |
brew cask install atom | |
brew cask install rowanj-gitx |
function g; git $argv; end | |
function ll; ls -laH $argv; end | |
function _git_branch_name | |
set -l branch (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') | |
if test -n "$branch" | |
echo $branch | |
else | |
set -l commit (command git rev-parse --short HEAD ^/dev/null) |
[alias] | |
st = status -sb | |
co = checkout | |
cp = cherry-pick | |
ci = commit | |
br = branch | |
sub = submodule | |
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate | |
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat | |
undo = reset HEAD^ |
# Example One: spec/unit/lib/space/flight/ship_gateway_spec.rb | |
RSpec.describe Space::Flight::ShipGateway do | |
let(:ship) { FactoryBot.create(:ship) } | |
let(:gateway) { described_class.new(ship_repository: Ship) } | |
context 'when finding a ship by id' do | |
subject { gateway.find_by_id(ship.id) } | |
it 'returns ship with correct id' do |