Skip to content

Instantly share code, notes, and snippets.

// One of your rules sends the highlighter to the embedded rule
// For examples, in your $rules
{
token: 'text',
regex: /^```json$/,
next: 'json-start', // this is the important bit
},
// ...
@JackuB
JackuB / headers.js
Last active January 16, 2018 15:48
apiHeaders: [
{
token: 'empty_line',
regex: /^\s*$/,
next: 'start',
},
// We can validate the headers with regex
{
token: ['text', 'keyword.control', 'comment', 'text'],
regex: /(\s*)([\w-]+)(: )(.*)/,
const $rules = {
start: [
{
regex: /KEYWORD/,
token: 'keyword',
next: 'otherRulesBlock',
},
{ defaultToken: 'text' },
],
otherRulesBlock: [
// This only defines high-level behaviour of the Mode like folding etc.
ace.define('ace/mode/custom', ['require', 'exports', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/custom_highlight_rules'], (acequire, exports) => {
const oop = acequire('ace/lib/oop');
const TextMode = acequire('ace/mode/text').Mode;
const CustomHighlightRules = acequire('ace/mode/custom_highlight_rules').CustomHighlightRules;
oop.inherits(Mode, TextMode); // ACE's way of doing inheritance
exports.Mode = Mode; // eslint-disable-line no-param-reassign
});
@JackuB
JackuB / anvm.sh
Created November 16, 2015 09:48
anvm
#!/usr/bin/env bash
anvm () {
if [[ ! -f package.json ]] ; then
echo "No package.json found in current directory"
return 1
fi
local NVM_VERSION_DIR
local NODE_VERSION=$(cat package.json | jq '.engines.node' | tr -d '"')
@JackuB
JackuB / keybase.md
Created September 1, 2015 11:29
keybase.md

Keybase proof

I hereby claim:

  • I am jackub on github.
  • I am jakub (https://keybase.io/jakub) on keybase.
  • I have a public key whose fingerprint is 581E C602 345D 1B28 6703 D625 8D51 ABF8 EC29 C239

To claim this, I am signing this object:

@JackuB
JackuB / keybase.md
Created February 27, 2015 15:08
keybase.md

Keybase proof

I hereby claim:

  • I am jackub on github.
  • I am jakub (https://keybase.io/jakub) on keybase.
  • I have a public key whose fingerprint is 36C9 E4B3 BB33 C4BE 00E7 C432 29EC B5EC 0E4E FFF9

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am jackub on github.
* I am jakub (https://keybase.io/jakub) on keybase.
* I have a public key whose fingerprint is D597 FB29 E275 6723 9842 A5E4 6D37 8129 AF31 AE0C
To claim this, I am signing this object:
@JackuB
JackuB / FBcanvasSmoothScroll.js
Created April 9, 2014 09:20
FB.canvas.scrollTo + jQ animate()
function canvasSmoothScroll(y, d){
var duration = d || 800;
FB.Canvas.getPageInfo(function(pageInfo){
$({y: pageInfo.scrollTop}).animate(
{y: y},
{duration: duration, step: function(offset){
FB.Canvas.scrollTo(0, offset);
}
});
});
@JackuB
JackuB / gaben.js
Created January 2, 2014 15:25
Pokud tento skript spustíte v konzoli (F12 v Chrome) na této adrese: https://store.steampowered.com/account/ zjistíte, jak moc vás má Gaben rád...
var radky = jQuery(".transactionRowPrice");
var pole = [];
jQuery.each(radky, function(i) {
if (radky.eq(i).text() != "Zdarma" && radky.eq(i).text() != "Není k dispozici" && radky.eq(i).text() != "Celkem") {
var cislo = radky.eq(i).text().replace(",", ".").replace("€", "").replace("--", "00");
if (!isNaN(cislo)) {
pole.push(parseInt(cislo, 10));
}
}
});