Matching email addresses in Javascript
Matching email addresses in Javascript
regex = /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/img
"hello sean@example.com how are you? do you know bob@example.com?".match(regex)
// => ["sean@example.com", "bob@example.com"]
Written by Sean Behan on 03/24/2017
How to Make Cross Database Queries with Postgres and DBLink Extension
Here are a few snippets for cross database queries. It's important to note that you must be explicit in enumerating the columns and types you are querying. Otherwise, things will probably not work as expected.
-- enable extension
create extension db...
Written by Sean Behan on 03/18/2017
How to send email with Python, smtplib and Postmark
Here is a quick code snippet showing how to send email via SMTP with Postmark without any dependencies. It assumes you are using Heroku and have added the addon. But if not just make sure your api keys are set as environment vars.
from os import envir...
Written by Sean Behan on 03/12/2017
Using Selenium to Drive Firefox Browser for Web Automation
There are a lot of practical uses for automating user behavior in a browser. Everything from testing your web application to logging into Twitter and auto following people.
But first you have to install the tools. Here is everything you need to run yo...
Written by Sean Behan on 03/09/2017
How to Import/Export a Database from One Heroku App to Another Heroku App
Heroku is awesome! Let's say we want to copy a production database to a staging database.
We can use the `pg:backups:restore` command to accomplish this. Here is an example. For the source database we are using the `production-app-name` and for stagi...
Written by Sean Behan on 03/07/2017
Linux Disk Usage Command Recursive
It's short and sweet!
du -hs *
If you run this command it will tell you the sizes of all the files and folder in the current directory.
The `-h` flag is for human readable format and the `-s` will give you the size for each file or directory.
...
Written by Sean Behan on 03/07/2017
Reshape an Array of Form Inputs for Flask with getlist()
This is how to reshape an array using Python without Numpy.
This is a fairly simple task but it can be a little confusing to wrap your head around. I ran into this problem while working with Flask, working with array from form fields.
I wanted to us...
Written by Sean Behan on 03/07/2017
Trigrams, Bigrams and Ngrams in Python for Text Analysis
Creating trigrams in Python is very simple
trigrams = lambda a: zip(a, a[1:], a[2:])
trigrams(('a', 'b', 'c', 'd', 'e', 'f'))
# => [('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f')]
You can generalize this a little bit more
...
Written by Sean Behan on 03/06/2017
How To Create a Dump File in Postgres Compatible with Heroku
When Heroku creates a dump file of your Postgres database it uses the `-Fc` option
It is equivalent to running
pg_dump -Fc -d name_of_db > name_of_db.dump
This command will let you import your database with the `pg_restore` command
pg_rest...
Written by Sean Behan on 03/06/2017
How to Fix xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
I just got a new machine and downloaded XCode. I used git to clone my ReactNative project from Github. I have everything ready to go. But when I run `react-native run-ios` I see
xcrun: error: unable to find utility "instruments", not a developer tool ...
Written by Sean Behan on 03/05/2017