Skip to content

Instantly share code, notes, and snippets.

View aliostad's full-sized avatar
🐒
I may be slow to respond.

Ali Kheyrollahi aliostad

🐒
I may be slow to respond.
View GitHub Profile
@aliostad
aliostad / upgrade_es_kib.sh
Created August 25, 2017 09:15
Rolling upgrade for Elasticsearch and Kibana
esversion="5.5.2"
kibversion="5.5.2"
username=<specify>
password=<specify>
nodecount=4 #change
oldesv=$(dpkg -s elasticsearch 2>/dev/null | grep Version | cut -f2 -d' ')
oldkibv=$(dpkg -s kibana 2>/dev/null | grep Version | cut -f2 -d' ')
@aliostad
aliostad / amazon_rotten_tomatoes_score.py
Created June 13, 2017 08:14
A simple script to find Amazon prime (UK) films and their rotten tomato score
from bs4 import BeautifulSoup
import codecs
import requests
def get_film_names(doc):
res = []
bs = BeautifulSoup(doc, 'html.parser')
for a in bs.select('ul li .s-item-container h2'):
name = a.text.replace('\t', ' ')
yearTags = a.parent.parent.select('> span.a-color-secondary')
@aliostad
aliostad / get-cluster-spark-external-ip.scala
Created June 10, 2017 11:28
How to get Spark Cluster's external IP for IP whitelisting
val client = new org.apache.http.impl.client.DefaultHttpClient()
val request = new org.apache.http.client.methods.HttpGet("http://ipinfo.io")
request.addHeader("accept", "application/json")
val response = client.execute(request)
val handler = new org.apache.http.impl.client.BasicResponseHandler()
println(handler.handleResponse(response).trim.toString)
@aliostad
aliostad / benchmark.cs
Created December 8, 2016 11:36
Linq OrderBy vs Array.Sort
class Program
{
static void Main(string[] args)
{
LinqVsArraySort();
}
static void LinqVsArraySort()
{
@aliostad
aliostad / ftpakamai.py
Last active August 22, 2016 11:09
A python script to download Akamai log files from FTP drop folder to an Azure blob storage
from ftplib import FTP
import sys
import os
from azure.storage.blob import BlobService
import time
_tmp_list = []
def _accept_file(x):
_tmp_list.append(x.split(' ')[-1])
sudo apt-get -y install software-properties-common python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
echo debconf shared/accepted-oracle-license-v1-1 select true | \
sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | \
sudo debconf-set-selections
sudo apt-get -y install oracle-java8-installer
sudo apt-get update
sudo apt-get install git rake zsh -y
@aliostad
aliostad / azure-vm-bootstrapper.ps1
Last active April 18, 2016 11:04
Azure VM bootstrapper
# Usage:
# iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/aliostad/a20f0c8d6a439dcff34e63e4a6559008/raw/0e445d869eb47e525512053638489920547a7d75/azure-vm-bootstrapper.ps1'))
# Bootstraps the Azure VM by modyifying settings and installing below:
# 1. Turn off annoying Intrenet Explorer enhanced security
# 2. Install chocolatey
# 3. Install PerfView
# 4. Install DebugView
# 5. Install SuperBenchmarker
# 6. Install notepad++
# 7. Install windbg

I am writing this letter, not necessarily in a position to intimidate or threaten (I am mere a consumer, have little power - although I will use all the power that I have, NOW IT IS PERSONAL) but only with a glimmer of hope that perhaps this could end the misery caused by one of your own contractors and all the incompetence that followed. With regret I have to inform you that the level of incompetence in the organisation is baffling and beyond belief - and sadly only comparable to the worst third-world countries. I have been lied to, I have been given false information and given deadlines that are not met.

As a techie (Solution Architect for an international eCommerce), my life is dependent on internet and it has been 21 days that we have had no internet - let alone having no phone. It is years that we have stopped watching TV and only rely on streaming (Netflix, Amazon) for our entertainment. Considering all holidays we could not watch TV... it has been an awful time. And all this, no end in sight... I have

class Program
{
static void Main(string[] args)
{
Func<string> getStuff = () =>
{
Console.WriteLine("Called!");
return Guid.NewGuid().ToString();
@aliostad
aliostad / ko.js
Last active December 16, 2015 03:38
A simple js view model
function ViewModel(price, discountPercentage){
this.price = price;
this.discountPercentage = discountPercentage;
}
ViewModel.prototype.getRealPrice = function(){
return this.price * this.discountPercentage;