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 / gist:488e994055bb9b18f0065641f6fbe060
Created November 21, 2019 11:59 — forked from jwebcat/gist:5122366
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@mirfan899
mirfan899 / RasaNLU.php
Created April 30, 2020 16:35 — forked from mpociot/RasaNLU.php
RasaNLU middleware for BotMan
<?php
namespace App\BotMan\Middleware;
use Mpociot\BotMan\Message;
use Mpociot\BotMan\Http\Curl;
use Mpociot\BotMan\Interfaces\HttpInterface;
use Mpociot\BotMan\Interfaces\DriverInterface;
use Mpociot\BotMan\Interfaces\MiddlewareInterface;
@mirfan899
mirfan899 / ffmpeg.md
Created September 23, 2020 05:48 — forked from protrolium/ffmpeg.md
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@mirfan899
mirfan899 / app.py
Created January 9, 2021 10:51 — forked from greyli/app.py
Photo upload and manage with Flask and Flask-Uploads (Multiple file upload support!).
# -*- coding: utf-8 -*-
import os
import uuid
from flask import Flask, render_template, redirect, url_for, request
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField
@mirfan899
mirfan899 / draw_text_with_background_opencv.py
Created February 1, 2021 13:19 — forked from aplz/draw_text_with_background_opencv.py
draw text with background // opencv
import cv2 # opencv
import numpy as np
font_scale = 1.5
font = cv2.FONT_HERSHEY_PLAIN
# set the rectangle background to white
rectangle_bgr = (255, 255, 255)
# make a black image
img = np.zeros((500, 500))
@mirfan899
mirfan899 / perplexity.py
Created March 30, 2021 05:03 — forked from huikang/perplexity.py
calculate perplexity
import math
import torch
from transformers import BertTokenizer, BertModel, BertForMaskedLM, OpenAIGPTLMHeadModel, OpenAIGPTTokenizer
# Load pre-trained model (weights)
model = OpenAIGPTLMHeadModel.from_pretrained('openai-gpt')
model.eval()
# Load pre-trained model tokenizer (vocabulary)
tokenizer = OpenAIGPTTokenizer.from_pretrained('openai-gpt')
@mirfan899
mirfan899 / iamshell.txt
Last active April 24, 2021 06:23
shell
https://drive.google.com/drive/folders/14rA9c0cpK2XptZVDNi7-24jooPEJWKgm?usp=sharing
@mirfan899
mirfan899 / ms-concepts-import.sh
Created September 15, 2021 07:23 — forked from jexp/ms-concepts-import.sh
Load and query the Microsoft Concept Graph in Neo4j https://concept.research.microsoft.com/Home/Introduction
function import_extract_first {
echo "name:ID(Concept)" > concepts.txt
cat data-concept-instance-relations.txt | cut -d $'\t' -f 1 | sort | uniq >> concepts.txt
echo "name:ID(Instance)" > instances.txt
cat data-concept-instance-relations.txt | cut -d $'\t' -f 2 | sort | uniq >> instances.txt
echo $':END_ID(Concept)\t:START_ID(Instance) relations:int' > is_a.hdr
$NEO4J_HOME/bin/neo4j-import --into concepts.db --id-type string --delimiter TAB --bad-tolerance 13000000 --skip-duplicate-nodes true --skip-bad-relationships true \
@mirfan899
mirfan899 / wn3.1.py
Created November 2, 2021 15:23 — forked from e-mon/wn3.1.py
WordNet in NLTK version up from 3.0 to 3.1
import os
nltkdata_wn = '/path/to/nltk_data/corpora/wordnet/'
wn31 = "http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz"
if not os.path.exists(nltkdata_wn+'wn3.0'):
os.mkdir(nltkdata_wn+'wn3.0')
os.system('mv '+nltkdata_wn+"* "+nltkdata_wn+"wn3.0/")
if not os.path.exists('wn3.1.dict.tar.gz'):
os.system('wget '+wn31)
os.system("tar zxf wn3.1.dict.tar.gz -C "+nltkdata_wn)
@mirfan899
mirfan899 / ubuntu-20.04-macbook-pro.md
Created May 31, 2022 05:37 — forked from johnjeffers/ubuntu-20.04-macbook-pro.md
Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)

Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)

These are notes from my efforts to get Ubuntu 20.04 installed on my older MacBook Pro. I'm making this gist public in the hopes that it's helpful to others.

I did a Minimal install, but selected the option to install additional 3rd-party drivers.

Wifi doesn't work during the install (because it requires a 3rd-party driver), so you won't be able to choose to download updates while installing. No big deal, run a software update after the install.

The installer takes about 25 minutes to complete. Post-install, most things work. The only driver I had to manually install was for the FaceTime camera. More on that below.