Skip to content

Instantly share code, notes, and snippets.

View talhasch's full-sized avatar

Talha talhasch

View GitHub Profile
@dlemphers
dlemphers / es_pyes_daterange
Created January 3, 2012 05:06
Filtering on date range using pyes
conn.search(
query=FilteredQuery(
TermQuery(
'name',
'Dave'
),
ANDFilter([
TermFilter('memberStatus', 'valid'),
RangeFilter(ESRangeOp('startDate', 'lt', '2012-01-1')),
RangeFilter(ESRangeOp('endDate', 'gte', '2012-01-1')),
@HeartSaVioR
HeartSaVioR / test-bulk-insert-set-key.py
Created August 5, 2012 13:47
Redis bulk insert test - set
# -*- encoding: utf-8 -*-
import sys
#print sys.argv
if len(sys.argv) < 3:
print "usage: %s [start] [end]" % sys.argv[0]
sys.exit(1)
start = int(sys.argv[1])
@sirbrillig
sirbrillig / pgsql_backup.sh
Last active November 15, 2024 14:57 — forked from dangerousbeans/pgsql_backup.sh
Postgresql daily backup script.
#!/bin/bash
#
# Backup a Postgresql database into a daily file.
#
BACKUP_DIR=/pg_backup
DAYS_TO_KEEP=14
FILE_SUFFIX=_pg_backup.sql
DATABASE=
USER=postgres
@kwatch
kwatch / gist:4672421
Last active December 25, 2019 14:51
How to convert query object into non-prepared sql string in SQLAlchemy and psycopg2
def query2sql(query):
"""convert query object into non-prepared sql string in SQLAlchemy and psycopg2"""
compiler = query.statement.compile()
params = compiler.params
prepared_sql = compiler.string # or str(compiler)
psycopg2_cursor = query.session.connection().connection.cursor()
sql = psycopg2_cursor.mogrify(prepared_sql, params)
return sql
@tbarbugli
tbarbugli / reset.sql
Created May 1, 2013 13:10
reset all sequences on a postgres db
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;
@mbejda
mbejda / Top-1000-Celebrity-Twitter-Accounts.csv
Last active February 16, 2025 22:21
Top 1000 Celebrity Twitter Accounts (twitter,domain,name,type)
twitter domain name type
katyperry katyperry.com KATY PERRY celebrity
justinbieber smarturl.it Justin Bieber celebrity
taylorswift13 grmypro.co Taylor Swift celebrity
rihanna rihannanow.com Rihanna celebrity
ladygaga The Countess celebrity
jtimberlake justintimberlake.com Justin Timberlake celebrity
TheEllenShow ellentube.com Ellen DeGeneres celebrity
britneyspears britney.lk Britney Spears celebrity
Cristiano Cristiano Ronaldo celebrity
@renchap
renchap / README.md
Last active February 14, 2025 13:25
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@jh0ker
jh0ker / renew_certificates.py
Created December 18, 2016 07:18
Python 3.5 - Script to check letsencrypt certificates for all domains, renew them if required, concatenate them into bundles and restart haproxy
from os import listdir, system
from os.path import join
from subprocess import run, PIPE
import logging
import re
from datetime import datetime, timedelta
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
level=logging.INFO,
filename='/root/renew_certificates.log',
@oun
oun / formatMessage.js
Last active November 19, 2024 17:50
Use React-Intl API outside React component
import { IntlProvider } from 'react-intl';
const language = 'en';
// Usually messages is declared in another file.
const messages = {
greeting: 'Hello'
}
export const mesg = defineMessages({
greeting: {
id: 'greeting',
@ruanbekker
ruanbekker / elasticsearch-bootstrap-data-node.sh
Last active August 7, 2018 20:18
Bootstrap Elasticsearch Data Node on Ubuntu 16.04
#!/bin/bash
apt update && apt upgrade -y
apt install software-properties-common python-software-properties apt-transport-https -y
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
add-apt-repository ppa:webupd8team/java -y
apt update
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
apt install oracle-java8-installer -y
apt install elasticsearch -y