Skip to content

Instantly share code, notes, and snippets.

View alonisser's full-sized avatar

Alonisser alonisser

View GitHub Profile
@eezis
eezis / update postgres last value.py
Last active October 7, 2017 03:20
A code snippet to update the "last_value" of postgres's sequence generator when it is out of sync with the actual values in your tables.
"""
This utility addresses the InegrityError that occurs when you try to add a new record to
(probably a recently ported) postgres database while using Django, here's more . . .
duplicate key value violates unique constraint "<app>_<table>_pkey"
DETAIL: Key (id)=(2) already exists.
The problem here is that the Postgres sequence generators are out of sync with your data.
Here's a good overview: http://www.vlent.nl/weblog/2011/05/06/integrityerror-duplicate-key-value-violates-unique-constraint/
@Stanback
Stanback / nginx.conf
Last active February 4, 2022 18:05
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service (https://github.com/collectiveip/prerender).Instead of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
# Note (November 2016):
# This config is rather outdated and left here for historical reasons, please refer to prerender.io for the latest setup information
# Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
{
"directory": "components"
}
@bergantine
bergantine / gist:3870080
Last active February 18, 2016 12:57
post-merge Git hook to install requirements if changed, compile stylesheets, syncdb, run a south migration on the database, and rebuild the haystack index using the active virtual environment's python installation. #bash #git #hook #django #compass #sass #pip #south #haystack
#!/bin/sh
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'requirements/development.txt' -c) -ne 0 ]
then
sudo $VIRTUAL_ENV/bin/pip install -r /vagrant/myproject/requirements/development.txt
fi
compass compile /vagrant/myproject/myproject/static_media/stylesheets -e production --force
$VIRTUAL_ENV/bin/python /vagrant/myproject/manage.py syncdb
@chrislkeller
chrislkeller / README.md
Last active February 3, 2022 08:02
Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX.

Demo: ajax-handlebars

This repo's location has changed.

@sidharthkuruvila
sidharthkuruvila / gist:3154845
Created July 21, 2012 06:30
Utility to functions to convert between camel case and underscore separated names
/**
* Takes a camel cased identifier name and returns an underscore separated
* name
*
* Example:
* camelToUnderscores("thisIsA1Test") == "this_is_a_1_test"
*/
def camelToUnderscores(name: String) = "[A-Z\\d]".r.replaceAllIn(name, {m =>
"_" + m.group(0).toLowerCase()
})
@fancyremarker
fancyremarker / .bash_login.jenkins
Last active March 6, 2023 19:21
[A.] Scripts related to Jenkins client setup
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
@phred
phred / pedantically_commented_playbook.yml
Last active November 3, 2023 01:55
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@pcdinh
pcdinh / easy_install and MinGW
Created April 15, 2012 10:53 — forked from mmlin/easy_install and MinGW
Installing hg-git on Windows using MinGW
Here's how I installed hg-git on Windows using the MinGW compiler.
PREPARE
-------
- Install Python (http://www.activestate.com/activepython/downloads)
- Install the Python package manager, setuptools (http://pypi.python.org/pypi/setuptools)
- Install the MinGW installer (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/)
- Install the C compiler, MinGW gcc, and a utility, pexports, to help create the import library