Skip to content

Instantly share code, notes, and snippets.

View mirfan899's full-sized avatar
🏠
Working from home

Muhammad Irfan mirfan899

🏠
Working from home
View GitHub Profile
@mirfan899
mirfan899 / urlmarker.py
Created April 16, 2019 16:08
URL regex
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
"""
ANY_URL_REGEX = r"""(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))"""
@mirfan899
mirfan899 / mic_client.py
Created April 29, 2019 16:59 — forked from fopina/mic_client.py
microphone streaming with pyAudio
#!/usr/bin/env python
import pyaudio
import socket
import sys
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 4096
@mirfan899
mirfan899 / sound_recorder.py
Created April 29, 2019 17:02 — forked from mabdrabo/sound_recorder.py
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"
# Keras==1.0.6
import numpy as np
from keras.models import Sequential
from keras.layers.recurrent import LSTM
from keras.layers.core import TimeDistributedDense, Activation
from keras.preprocessing.sequence import pad_sequences
from keras.layers.embeddings import Embedding
from sklearn.cross_validation import train_test_split
from sklearn.metrics import confusion_matrix, accuracy_score, precision_recall_fscore_support
@mirfan899
mirfan899 / mlp.py
Last active November 15, 2019 04:14
import codecs
tagged_sentences = codecs.open("../data/data.txt", encoding="utf-8").readlines()
print(tagged_sentences[0])
import ast
import numpy as np
from keras.layers import Dense, InputLayer, Embedding, Activation
from keras.models import Sequential
from keras.optimizers import Adam
@mirfan899
mirfan899 / cuda_installation_on_ubuntu_18.04
Created May 29, 2019 16:31 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
cuda 9.0 complete installation procedure for ubuntu 18.04 LTS
#!/bin/bash
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
apt-get update && apt-get install -y \
sox \
curl \
libicu-dev \
g++ \
git \
python \
python-dev \
python-setuptools \
@mirfan899
mirfan899 / Install NVIDIA Driver and CUDA.md
Created June 27, 2019 09:37 — forked from zhanwenchen/Install NVIDIA Driver and CUDA.md
Install NVIDIA CUDA 9.0 on Ubuntu 16.04.4 LTS
@mirfan899
mirfan899 / cuda_setup.sh
Last active September 23, 2019 05:27
Install cuda 9 and cudnn 7 directly from nvidia
sudo apt-get purge cuda
sudo apt-get purge libcudnn6
sudo apt-get purge libcudnn6-dev
# resources for nvidia deb package.
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
@mirfan899
mirfan899 / python_3.6.9.sh
Last active September 20, 2019 05:20
Compile Python 3.6.9 from source
#!/usr/bin/env bash
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xzf Python-3.6.9.tgz
cd Pyhton-3.6.9
./configure --enable-optimizations
make -j 2
make altinstall