Skip to content

Instantly share code, notes, and snippets.

View rtu-dataframe's full-sized avatar

Simone rtu-dataframe

View GitHub Profile
@fnando
fnando / dev.conf
Created July 23, 2011 09:00
Nginx configuration for SSH tunnel
upstream tunnel {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name dev.codeplane.com br.dev.codeplane.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
@davidkrisch
davidkrisch / accept-xml.js
Created March 26, 2012 23:13
Express-Node: Accepting POST with Content-Type: application/xml
// This script requires Express 2.4.2
// It echoes the xml body in the request to the response
//
// Run this script like so:
// curl -v -X POST -H 'Content-Type: application/xml' -d '<hello>world</hello>' http://localhost:3000
var express = require('express'),
app = express.createServer();
express.bodyParser.parse['application/xml'] = function(data) {
return data;
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 14, 2024 09:13
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@willcalderbank
willcalderbank / retry.py
Last active July 15, 2022 11:58
Python retry decorator
def retry(times, exceptions):
"""
Retry Decorator
Retries the wrapped function/method `times` times if the exceptions listed
in ``exceptions`` are thrown
:param times: The number of times to repeat the wrapped function/method
:type times: Int
:param Exceptions: Lists of exceptions that trigger a retry attempt
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@ochinchina
ochinchina / install_boot2docker_2_hadrdisk.txt
Created September 26, 2014 01:57
install boot2docker to harddisk in the virtualbox
1, create a virtual machine from the virtualbox with VDI harddisk
2, add a virtual CDROM to the virtual machine and select boot2docker.iso ( the boot2docker.iso should be downloaded before)
3, start the virtual machine
4, write the boot2docker.iso image to the virtual harddisk using dd command
# dd if=/dev/cdrom of=/dev/sda
@un1t
un1t / django-script.py
Created February 21, 2015 21:48
How to run scripts outside django
# coding: utf-8
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
django.setup()
# write your code here
@mhubig
mhubig / Dockerfile
Last active October 31, 2024 16:30
Alpine Linux based cronjob runner
FROM alpine:latest
RUN apk add --update php python py-pip mysql-client \
&& pip install awscli \
&& rm -rf /var/cache/apk/*
RUN touch crontab.tmp \
&& echo '* */6 * * * /usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run' > crontab.tmp \
&& echo '0 2 * * * /usr/bin/sql_backup' >> crontab.tmp \
&& crontab crontab.tmp \
@OdinsPlasmaRifle
OdinsPlasmaRifle / managers.py
Last active February 5, 2024 16:56
Haversine formula in Django using Postgres SQL
from django.db import models, connection
"""
Haversine formula in Django using Postgres SQL
Queries a model for all rows that are within a certain radius (given in meters) of a central point.
The 'location_model' placeholder should be raplaced with the name of the table (full name) that includes a latitude and longitude column.
The latitude and longitude columns should be decimal fields.
@kylefox
kylefox / __init__.py
Last active July 1, 2021 12:12
Connecting Django Signals using the AppConfig ready handler: https://docs.djangoproject.com/en/1.10/ref/applications/#django.apps.AppConfig.ready
default_app_config = 'cn.apps.users.config.UsersAppConfig'