Skip to content

Instantly share code, notes, and snippets.

//https://pegjs.org/online
start = table / trx
table = "table" space s:schema "." t:tablename ":" space a:action ":" d:data {return {schema:s, table:t, action:a, data:d};}
trx = trx_begin / trx_commit
trx_begin = "BEGIN" id:trx_id? {return {trx:"BEGIN", xid:id};}
trx_commit = "COMMIT" id:trx_id? tm:trx_tm {return {trx:"COMMIT", xid:id, time:tm};}
@afucher
afucher / iniFileParser.js
Created February 4, 2016 00:25
Grammar from PEGjs for ini file
IniFile
= first: Section (BlankLine* others: Section*) {others.unshift(first); return others; }
Section
= section: SectionHeader "\n" values: KeyValues* {return {section:values}}
SectionHeader
= "[" section_name: word "]" {return section_name}
KeyValues
= a: word "=" value: word "\n"? {var o = {}; o[a]=value; return o;}
@mytharcher
mytharcher / README.md
Last active April 26, 2024 08:04
Grammar Descriptions in PEG.js

Elimination of left recursion

C -> D o D
D -> C
D -> t

D -> D o D
D -> t
@netgusto
netgusto / pegjs-htmlish.peg
Last active April 26, 2024 08:04
PEG.js grammar for parsing simple HTML-ish balanced markup language - use it on http://pegjs.majda.cz/online
Content = (DocType / Comment / BalancedTag / SelfClosingTag / Text)*
DocType = "<!doctype " doctype:[^>]* ">" {
return {
type: 'DocType',
content: doctype.join('')
};
}
Comment = "<!--" c:(!"-->" c:. {return c})* "-->" {
@axelbdt
axelbdt / django-postgresql-15.md
Last active April 26, 2024 08:03
# Django and PostgreSQL 15, the rules have changed

Django and PostgreSQL 15, the rules have changed

Postgres 15 is just out, and while there is a lot to love about this new release, you're in for a surprise if you try to set it up with Django following tutorials like this one.

The reason is stated in the release announcement:

Remove PUBLIC creation permission on the public schema (Noah Misch) The new default is one of the secure schema usage patterns that Section 5.9.6 has recommended...

Provided your web app doesn't access your database as a superuser (it shouldn't) and uses a dedicated user, it is not allowed to use the public schema anymore. You have to create one for this specific user, and the next section will

/*
GITHUB MARKDOWN EXTRACTOR RULES
https://guides.github.com/features/mastering-markdown/
http://www.table-ascii.com/
http://www.loc.gov/marc/specifications/specchartables.html
http://www.utf8-chartable.de/unicode-utf8-table.pl
This happens on IE for both students and teachers.
This is logged in the browser console in ie9:
SCRIPT5022: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function $locationWatch() {\n var oldUrl = $browser.url();\n var currentReplace = $location.$$replace;\n\n if (!changeCounter || oldUrl != $location.absUrl()) {\n changeCounter++;\n $rootScope.$evalAsync(function() {\n if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).\n defaultPrevented) {\n $location.$$parse(oldUrl);\n } else {\n $browser.url($location.absUrl(), currentReplace);\n afterLocationChange(oldUrl);\n }\n });\n }\n $location.$$replace = false;\n\n return changeCounter;\n }; newVal: 10; oldVal: 9","fn: function(context) {\n try {\n for(var i = 0, ii = length, part; i<ii; i++) {\n if (typeof (part = parts[i]) == 'function') {\n part = part(context);\n if (trustedContext) {\n part = $sce.getTrusted(trustedContext, part);\n } else {\n part = $sce.valueOf(par
// Generated automatically by nearley, version 2.15.1
// http://github.com/Hardmath123/nearley
(function () {
function id(x) { return x[0]; }
var grammar = {
Lexer: undefined,
ParserRules: [
{"name": "Main", "symbols": ["ifStatement"], "postprocess": id},
{"name": "ifStatement$string$1", "symbols": [{"literal":"i"}, {"literal":"f"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "ifStatement", "symbols": ["ifStatement$string$1", "_", {"literal":"("}, "_", "expression", "_", {"literal":")"}, "_", "Statement", "_"], "postprocess": arr => arr[4] && arr[8]},
@Mahedi-61
Mahedi-61 / cuda_11.8_installation_on_Ubuntu_22.04
Last active April 26, 2024 08:00
Instructions for CUDA v11.8 and cuDNN 8.9.7 installation on Ubuntu 22.04 for PyTorch 2.1.2
#!/bin/bash
### steps ####
# Verify the system has a cuda-capable gpu
# Download and install the nvidia cuda toolkit and cudnn
# Setup environmental variables
# Verify the installation
###
### to verify your gpu is cuda enable check
@moelody
moelody / feedbro-locale-zh_CN.json
Last active April 26, 2024 07:56
feedbro中文翻译
{
"meta": {
"manifest_version": 3,
"locale_version": "1.3",
"locale_name": "简体中文",
"locale_type": "zh_CN",
"locale_last_updated": "2020-08-07 18:00:00 UTC",
"locale_author_name": "moelody",
"locale_author_email": "yfsmallmoon@gmail.com",
"locale_source_url": "https://gist.github.com/moelody/3159316ce726fc629fae15278bbce429"