Skip to content

Instantly share code, notes, and snippets.

View ingydotnet's full-sized avatar

Ingy döt Net ingydotnet

View GitHub Profile
@ingydotnet
ingydotnet / .txt
Created January 13, 2016 17:01
Bash bug wrt `[[` and quoting?
$ x='a\b'
$ echo $x
a\b
$ echo "$x"
a\b
$ echo $x | hexdump -C
00000000 61 5c 62 0a |a\b.|
00000004
$ [ $x == $x ] || echo hmmm
$ [ "$x" == "$x" ] || echo hmmm
@ingydotnet
ingydotnet / word-parse.pl
Last active November 26, 2015 04:57
Parse words from a string of smushed together words with a single regexp
#!/usr/bin/env perl
use strict;
# Get all the letters from stdin:
my $input = do {local $/; <>};
$input =~ s/[^a-zA-Z]//g;
# All 3+ letter English words, longest to shortest:
my @long = grep {length > 2}
sort {length $b <=> length $a}
  1. Foo

  2. Bar

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 1:

=over without closing =back

$ for u in `cat github-leaders`; do printf "%-20s%s\n" $u `git hub user-get $u followers`; done
kevinsawicki 1028
taylorotwell 1977
qiangxue 654
michaelklishin 458
brianchandotcom 381
mitchellh 1614
fabpot 3966
ornicar 493
jdalton 732
@ingydotnet
ingydotnet / foo
Created July 27, 2014 01:18
Inline YAML Meta Info
--- !!yaml
version: 2.0
schema:
type: YeS
file: ./foo.yes
tag:
- !ingy: ingy.net,2001
- !obk: ben-kiki.net,2000
--- !ingy!hacker
name: Ingy
@ingydotnet
ingydotnet / gist:04d66766fab11cb013a4
Created July 26, 2014 17:48
ETag caching fails on hooks endpoint
$ curl --request POST https://api.github.com/repos/ingydotnet/zilla-dist-pm/hooks -d '{"name":"travis","active":true,"events":[ "push" ],"config":{"user":"ingydotnet","token":"********"}}' --header 'Authorization: token ********' --header 'If-None-Match: "45cc5f3c5c128e6a79b9a4d46e8b6c0f"' --user-agent git-hub-0.0.3 --silent --show-error --dump-header -
HTTP/1.1 412 Precondition Failed
Server: GitHub.com
Date: Sat, 26 Jul 2014 17:43:30 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Status: 412 Precondition Failed
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4980
X-RateLimit-Reset: 1406399175
Code: sub foo { ... } xyz
@ingydotnet
ingydotnet / test.bash
Last active August 29, 2015 14:02 — forked from AndrewSmart/gist:1796bc4fffc4e46e8150
Refactored to this script
#!/usr/bin/env bash
set -ex
rm -fr p1 p2 lib lib.git
(
mkdir lib p1 p2
git init --bare lib
git init p1
git init p2
reviewed:
- dan:
review_title:
review_description:
review_count:
reviewer_name:
reviewr_city:
- mark:
review_title:
review_description:
value and comment: hello # comment here
single line string: 'ok # not a comment' # this is a comment
double quoted: "this line has a newline at end\n"
literal: |
indented text
is 4 lines and
has leading spaces removed
all content # including the is part of the literal
number: 42