Skip to content

Instantly share code, notes, and snippets.

View talhasch's full-sized avatar

Talha talhasch

View GitHub Profile
@sagiavinash
sagiavinash / ReactRouterV4FlowTypes.js
Created September 10, 2018 12:52
Flow Types for React Router V4
/*
* Types for React Router V4
* Example Usage:
* type PropsT = {
* myProp: string,
* } & ContextRouterT<{
* routeParam: string,
* anotherRouteParam: ?string,
* }>
*/
@ruanbekker
ruanbekker / elasticsearch-bootstrap-master-node.sh
Created August 11, 2017 13:55
Bootstrap Elasticsearch Master 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 nginx apache2-utils elasticsearch -y
@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
@oun
oun / formatMessage.js
Last active March 18, 2022 18:40
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',
@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',
@renchap
renchap / README.md
Last active October 12, 2022 17:14
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 {
@mbejda
mbejda / Top-1000-Celebrity-Twitter-Accounts.csv
Last active April 27, 2024 19:03
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
@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;
@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
@sirbrillig
sirbrillig / pgsql_backup.sh
Last active April 25, 2024 11:34 — 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