Skip to content

Instantly share code, notes, and snippets.

View sany2k8's full-sized avatar
:octocat:
Focusing

Md. Sany Ahmed sany2k8

:octocat:
Focusing
  • Khulna, Bangladesh
View GitHub Profile
@sany2k8
sany2k8 / gist:bad3927a7c37c51d518903719190e9d2
Created February 12, 2019 02:14 — forked from drorata/gist:146ce50807d16fd4a6aa
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
@sany2k8
sany2k8 / csv_to_elastic_search_bulk_insert.py
Created January 31, 2019 17:14 — forked from clemsos/csv_to_elastic_search_bulk_insert.py
Elastic Search : index large csv files with Python Pandas
from pyelasticsearch import ElasticSearch
import pandas as pd
from time import time
root_path="/home/clemsos/Dev/mitras/"
raw_data_path=root_path+"data/"
csv_filename="week10.csv"
t0=time()
@sany2k8
sany2k8 / import_csv_to_db.py
Created December 30, 2018 14:56 — forked from weaming/import_csv_to_db.py
import_csv_to_db
# coding: utf8
"""
Goal: import csv to database.
pip install pandas, numpy
"""
import pandas
import numpy as np
@sany2k8
sany2k8 / useful_pandas_snippets.py
Last active December 29, 2018 16:32 — forked from fomightez/useful_pandas_snippets.py
Useful Pandas Snippets
# -*- coding: utf-8 -*-
# import pandas and numpy package
import numpy as np
import pandas as pd
# List unique values in a DataFrame column
df['Column Name'].unique()
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
@sany2k8
sany2k8 / csv-to-pandas.py
Created December 29, 2018 16:00 — forked from jepma/csv-to-pandas.py
Pandas
import pandas as pd
# Read file
results = pd.read_csv("/tmp/data.csv", encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL)
# Print rows
for row in results:
print(row)
# Iterate over rows
@sany2k8
sany2k8 / useful_pandas_snippets.md
Created December 29, 2018 15:48 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@sany2k8
sany2k8 / redis_cheatsheet.bash
Created October 7, 2018 15:14 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
<?php
function array_keys_multi(array $array)
{
$keys = array();
foreach ($array as $key => $value) {
$keys[] = $key;
if (is_array($array[$key])) {
$keys = array_merge($keys, array_keys_multi($array[$key]));
@sany2k8
sany2k8 / s3cmd_install.md
Created August 31, 2018 06:20 — forked from dominicsayers/s3cmd_install.md
Installing s3cmd on Ubuntu Server
  1. sudo apt-get install python-setuptools
  2. wget http://downloads.sourceforge.net/project/s3tools/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gz
  3. tar xvfz s3cmd-1.5.0-alpha1.tar.gz
  4. cd s3cmd-1.5.0-alpha1
  5. python setup.py install
  6. s3cmd --configure
@sany2k8
sany2k8 / nginxproxy.md
Created August 3, 2018 05:47 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers