Skip to content

Instantly share code, notes, and snippets.

package main
import (
"crypto/rand"
"errors"
"flag"
"fmt"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip"
package main
import (
"crypto/rand"
"errors"
"flag"
"fmt"
"gopkg.in/goose.v1/client"
"gopkg.in/goose.v1/glance"
"gopkg.in/goose.v1/identity"
>>> pattern = re.compile(r'\w+')
>>> pattern.findall('This is a test')
['This', 'is', 'a', 'test']
>>> pattern = re.compile(r'(\w+)')
>>> pattern.findall('This is a test')
['This', 'is', 'a', 'test']
>>> pattern = re.compile(r'\W+')
>>> pattern.split("This is a test")
# As perl one liners:
$ cat data | perl -w -e '$/=""; while(<>) { m!^This.+file$!m and print }'
This is a test file
Will it work
lets see
# DEFAULT BEHAVIOUR
$ cat data | perl -w -e '$/=""; while(<>) { m!(^This.+file)! and print "$1\n" or print "NOMATCH\n" }'
#! /usr/bin/perl
$str = "This is a test
Will it work
lets see
";
if ($str =~ m!^This.+test$!)
{
print "matched\n"
}
@spareslant
spareslant / find_repeated_patterns_in_file.go
Last active March 9, 2016 20:24
Grep like utility that prints delimiter after a successful group match
package main
// This program will act like egrep -f patternfile textfile. But it will also print a delimeter ======= after each section of successfull match
import (
"bufio"
"fmt"
"io"
"log"
"os"
#! /bin/bash
HOST_SCREEN_RC_FILES_DIR="SCREEN_RC_FILES"
MAIN_RC_FILE="mainscreenrc"
LOG_DIR="LOGS"
TOOL_HOMEDIR=$(pwd)
TASKS_DIR="REMOTE_TASKS"
USAGE="usage is: $(basename $0) <Task DIRECTORY>\ne.g. $(basename $0) INSTALL_APPS
or