Skip to content

Instantly share code, notes, and snippets.

@NdYAG
NdYAG / getCaretText.js
Created August 3, 2013 06:49
Get the character user input in input[type="text"] bypassing IME
function getCaretPos(input_node) {
return 'selectionStart' in input_node? input_node.selectionStart: Math.abs(document.selection.createRange().moveStart('character', -input_node.value.length))
}
function getCaretText(input_node) {
var pos = getCaretPos(input_node)
if(!pos) return
return input_node.value.substring(pos - 1, pos)
}
$input_node.on('keyup', function() {
dosomething(getCaretText($input_node[0]))
@NdYAG
NdYAG / Transparent Bubble.markdown
Last active January 3, 2016 16:09
A Pen by Captain Anonymous.

Z-index and Background

When use negative z-index, care about background of the z-index stack's tag, and html, body tags' background

A Pen by Simon on CodePen.

License.

@NdYAG
NdYAG / MakoSample.md
Last active December 27, 2023 06:24
Mako Template Sample

Mako Template Syntax Sample

variable, expression

${x}

${len(list_name)}

${pow(x,2) + pow(y,2)}
@NdYAG
NdYAG / A-Pen-by-Simon.markdown
Created February 20, 2014 06:25
A Pen by Simon.
@NdYAG
NdYAG / SassMeister-input.scss
Created February 20, 2014 09:44
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.4)
// Compass (v1.0.0.alpha.18)
// ----
%h1 {
font-size: 2em;
}
%h2 {
font-size: 1.8em;
@NdYAG
NdYAG / Book.markdown
Created February 20, 2014 16:34
A Pen by Simon.
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<ul class="items">
<li class="item" data-status='{"liked": false}'>
<div class="item-status">
@NdYAG
NdYAG / 0_reuse_code.js
Created June 29, 2014 15:24
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