Skip to content

Instantly share code, notes, and snippets.

View habedi's full-sized avatar
🚀

Hassan Abedi habedi

🚀
View GitHub Profile
@habedi
habedi / test_whoosh.py
Created December 6, 2019 13:27 — forked from turicas/test_whoosh.py
Some tests with whoosh (full-text search library written entirely in Python)
#!/usr/bin/env python
# coding: utf-8
# To bootstrap the environment:
# mkvirtualenv whoosh
# pip install whoosh
import os
from whoosh.index import create_in, open_dir
@habedi
habedi / gzip.h
Created August 25, 2019 18:02
c++ gzip compress/decompress string with boost
#ifndef __GZIP_H__
#define __GZIP_H__
#include <sstream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
class Gzip {
public:
@habedi
habedi / lmdb.tcl
Created July 31, 2019 14:01 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@habedi
habedi / twitter_sentiment_analysis_convnet.py
Created June 6, 2019 18:39 — forked from giuseppebonaccorso/twitter_sentiment_analysis_convnet.py
Twitter Sentiment Analysis with Gensim Word2Vec and Keras Convolutional Networks
import keras.backend as K
import multiprocessing
import tensorflow as tf
from gensim.models.word2vec import Word2Vec
from keras.callbacks import EarlyStopping
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Flatten
from keras.layers.convolutional import Conv1D
@habedi
habedi / search.py
Created December 13, 2018 15:29 — forked from pavelk2/search.py
graph = {
1: {2:1,5:1},
2: {1:1,3:1,5:1},
3: {2:1,4:1},
4: {3:1,5:1,6:1},
5: {1:1,2:1,4:1},
6: {4:1}
}
time = 0
@habedi
habedi / autolog.py
Created December 5, 2018 13:00 — forked from brendano/autolog.py
python decorators to log all method calls, show call graphs in realtime too
# Written by Brendan O'Connor, brenocon@gmail.com, www.anyall.org
# * Originally written Aug. 2005
# * Posted to gist.github.com/16173 on Oct. 2008
# Copyright (c) 2003-2006 Open Source Applications Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@habedi
habedi / Makefile
Created August 22, 2018 16:03 — forked from Nemo157/Makefile
A simple Makefile for LaTeX projects.
# Author:
# Wim Looman
# Copyright:
# Copyright (c) 2010 Wim Looman
# License:
# GNU General Public License (see http://www.gnu.org/licenses/gpl-3.0.txt)
## User interface, just set the main filename and it will do everything for you
# If you have any extra code or images included list them in EXTRA_FILES
# This should work as long as you have all the .tex, .sty and .bib files in
@habedi
habedi / README.md
Created August 19, 2018 11:02 — forked from mayorova/README.md
Mutual SSL in NGINX

Securing traffic to upstream servers with client certificates

Info: https://www.nginx.com/resources/admin-guide/nginx-https-upstreams/

Creating and Signing Your Certs

Source: http://nategood.com/client-side-certificate-authentication-in-ngi

This is SSL, so you'll need an cert-key pair for you/the server, the api users/the client and a CA pair. You will be the CA in this case (usually a role played by VeriSign, thawte, GoDaddy, etc.), signing your client's certs. There are plenty of tutorials out there on creating and signing certificates, so I'll leave the details on this to someone else and just quickly show a sample here to give a complete tutorial. NOTE: This is just a quick sample of creating certs and not intended for production.

@habedi
habedi / nginx.conf
Created August 19, 2018 10:23 — forked from steve-ng/nginx.conf
Nginx reverse proxy wss with ssl
server {
listen 443 ssl;
server_name xxx.xx.io
ssl on;
ssl_certificate /etc/asterisk/certs/xxx.io.pem;
ssl_certificate_key /etc/asterisk/certs/xxx.io.key;
ssl_session_timeout 5m;
@habedi
habedi / README.md
Created August 9, 2018 10:48 — forked from andris9/README.md
Extremely simple HTTP proxy for changing Host: header Useful when proxying requests to virtual hosts that require Host: header to be set.

Setup reverse tunnel

Run the following in your client machine

ssh -R EXPOSED_PORT:localhost:SERVICE_PORT USER@HOST

Where

  • EXPOSED_PORT is the port exposed to the internet in the proxy server
  • SERVICE_PORT is the port your application is listening in your machine