Skip to content

Instantly share code, notes, and snippets.

View geekforbrains's full-sized avatar
🥸

Gavin Vickery geekforbrains

🥸
View GitHub Profile
@geekforbrains
geekforbrains / heroku_db_restore.sh
Last active August 9, 2021 15:59
Restore Heroku database from dump file
$ heroku pg:backups:capture -a APP_NAME
$ heroku pg:backups:download -a APP_NAME
$ heroku pg:credentials:url DATABASE_NAME -a APP_NAME
$ pg_restore --verbose --clean --no-acl --no-owner -h HOSTNAME -U USER -d DATABASE -p PORT latest.dump --password
@geekforbrains
geekforbrains / nginx_reverse_proxy.conf
Last active November 5, 2020 04:37
Nginx reverse proxy for Heroku
upstream heroku {
server myapp.herokuapp.com;
}
server {
server_name ~^(www\.)(?<domain>.+)$;
return 301 $scheme://$domain$request_uri;
}
server {
@geekforbrains
geekforbrains / rollback.sh
Created December 20, 2016 17:01
How to properly rollback a commit in Git
git revert --no-commit <sha>..HEAD
git commit
@geekforbrains
geekforbrains / shell.sh
Created November 15, 2016 21:01
Installing psycopg2 in virtualenv on macOS Sierra
$ xcode-select --install
$ brew install openssl
$ virtualenv env
$ . env/bin/activate
$(env) env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2
@geekforbrains
geekforbrains / multiple_responses.json
Created September 8, 2016 19:31
Watson Converstation API - Multiple Responses
{
"output": {
"text": {
"values": [
"My name is Alexander.",
"You can call me Alexander",
"Friends call me Alex"
],
"selection_policy": "random",
"append": false
@geekforbrains
geekforbrains / django_disco.sh
Last active March 10, 2016 23:15
A simple tool for clearing and rebuilding database and migrations in Django during dev
#!/usr/bin/env bash
echo "Database name:"
read db_name
# Delete migration folders
find apps -iname 'migrations*' -exec rm -rf {} \; > /dev/null 2>&1
# Re-create empty migration folder with __init__ file
for d in apps/*; do
@geekforbrains
geekforbrains / validate.js
Created December 7, 2015 05:51
PDF Validation
function validateForm() {
var fields = [
'date_Inspection Date',
'txt_Serial Number',
// Add more fields here
];
for(var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = this.getField(field).value.trim();
if(value == '') {
@geekforbrains
geekforbrains / source.html
Created October 7, 2015 21:05
3, 2, 1 Go!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>3, 2, 1 - Go!</title>
<style>
#countdown {
position: absolute;
left: 50%;
top: 50%;
@geekforbrains
geekforbrains / countdown.css
Created October 5, 2015 16:32
Javascript countdown
#countdown {
position: absolute;
left: 50%;
top: 50%;
width: 100px;
height: 100px;
display: none;
margin: -50px 0 0 -50px;
border: 2px solid #cecece;
background-color: #fefefe;
@geekforbrains
geekforbrains / nsscreencast_curl.sh
Created September 25, 2015 15:48
cURL request to NSScreencast login
curl -v https://www.nsscreencast.com/login
* Trying 162.243.42.159...
* Connected to www.nsscreencast.com (162.243.42.159) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: www.nsscreencast.com
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET /login HTTP/1.1
> Host: www.nsscreencast.com