Skip to content

Instantly share code, notes, and snippets.

View ceving's full-sized avatar
💭
Ejaculating

ceving

💭
Ejaculating
View GitHub Profile
@ceving
ceving / ddl.marpa
Created November 27, 2015 12:52
Conversion of SQL to JSON using Marpa
:default ::= action => dump_and_exit
lexeme default = latm => 1
ddl ::=
<create table>+ action => ddl
<create table> ::=
(CREATE TABLE) identifier ('(') <table element list> (')' ';')
action => create_table
@ceving
ceving / prepare.js
Created December 17, 2015 10:46
Poor man's prepare for querySelector
//
// Poor man's prepare for querySelector.
//
// Example:
// var query = prepare ('#modeler table[data-id=?] tr[data-id=?]');
// query[0] = entity;
// query[1] = attribute;
// var enity_attribute_row = document.querySelector(query);
//
var prepare;
@ceving
ceving / narrow-html-elements.el
Last active December 12, 2016 10:12
Narrow to CSS and JavaScript parts while editing a HTML file with embedded STYLE and SCRIPT tags using Emacs.
(defun narrow-to-html-style ()
"Narrow a HTML buffer to the style part and switch to css-mode."
(interactive)
(widen)
(goto-char (point-min))
(re-search-forward "<style")
(forward-line 1)
(beginning-of-line)
(let ((b (point)))
(re-search-forward "</style>")
@ceving
ceving / fossil-diff
Created January 14, 2016 16:01
Colorize Fossil's diff like Git
export bold=$(echo -e "\e[1m")
export black=$(echo -e "\e[30m")
export red=$(echo -e "\e[31m")
export green=$(echo -e "\e[32m")
export yellow=$(echo -e "\e[33m")
export blue=$(echo -e "\e[34m")
export magenta=$(echo -e "\e[35m")
export cyan=$(echo -e "\e[36m")
export reset=$(echo -e "\e[m")
@ceving
ceving / sunpkg-mkdir.el
Created January 21, 2016 13:59
Define all parent directories of a path in a prototype file for Sun's pkgmk tool creating Solaris packages.
(defun sunpkg-mkdir ()
"Define all parent directories of a path in a prototype file
for Sun's pkgmk tool creating Solaris packages. When the cursor
is in a line containing the following crontab definition
e cron var/spool/cron/crontabs/root=src/crontab ? ? ?
the function will insert the following directories in front of if
d cron var ? ? ?
@ceving
ceving / ipv4.sh
Created January 26, 2016 11:22
Bash functions for IPv4 network calculations
ip2int()
{
local a b c d
{ IFS=. read a b c d; } <<< $1
echo $(((((((a << 8) | b) << 8) | c) << 8) | d))
}
int2ip()
{
local ui32=$1; shift
@ceving
ceving / pstree
Last active January 27, 2016 14:11
Print a process tree on Solaris
#! /usr/bin/perl
##
## Print a process tree on Solaris
##
use strict;
use warnings;
my $l; # process list
my $r; # process relations
@ceving
ceving / rlogger
Created January 28, 2016 15:45
Send message to a remote Syslog server
#! /bin/bash
##
## Send message to a remote Syslog server.
##
## Time-stamp: <2016-01-28 16:45:02 ziemann.sascha>
##
## The program acts similar to the standard logger command, but sends
## message only a remote Syslog server. The generated messages
## conform to RFC 3164.
##
@ceving
ceving / backward-delete-sentence.el
Created February 5, 2016 15:22
Delete backward without adding the text into the kill ring.
(defun backward-delete-sentence (&optional arg)
"Delete back from point to start of sentence.
With arg, repeat, or kill forward to Nth end of sentence if negative arg -N."
(interactive "p")
(delete-region (point) (progn (backward-sentence arg) (point))))
(global-set-key (kbd "M-<backspace>") 'backward-delete-sentence)
@ceving
ceving / is-ip
Created September 7, 2016 14:09
Check if the arguments are IPv4 addresses.
#! /bin/bash
set -eu
#set -x
# Check if the arguments are IPv4 addresses.
is-ip ()
{
local -a ip # Array for IP address
local x # Octet input. No -i, because read converts non