Skip to content

Instantly share code, notes, and snippets.

Avatar

Suhail Ghafoor Phoenix-Effect

View GitHub Profile
@Phoenix-Effect
Phoenix-Effect / random.sh
Last active Nov 14, 2019
This script generators a random number in bash and saves it to a variable.
View random.sh
#!/bin/bash
NUM=$(shuf -i 100-300 -n 1)
echo $NUM
@Phoenix-Effect
Phoenix-Effect / articles.py
Created Jul 27, 2018
Downloads a bunch of DOI numbers from airtable, gets information related to that DOI number and upload it back to airtable.
View articles.py
from habanero import Crossref
from airtable import Airtable
from airtable.auth import AirtableAuth
import time
import pprint
import requests
import datetime
import html.parser
apikey = "API KEY"
@Phoenix-Effect
Phoenix-Effect / googlebooks_to_airtable.py
Created Jul 17, 2018
Pulls ISBN numbers/titles from an airtable and then download's the book information from google books and reuploads to airtable.
View googlebooks_to_airtable.py
import os
import re
from airtable import Airtable
from airtable.auth import AirtableAuth
import requests
import pprint
from pathlib import Path
APIKEY = "ENTER THIS"
BASEURL = "ENTER THIS"
@Phoenix-Effect
Phoenix-Effect / bam_index.sh
Created Jul 15, 2018
Checks if the bam index files in a directory are newer than their corresponding bam files.
View bam_index.sh
#!/bin/bash
# Directory of the directory you want to scan
DIR="ENTER DIRECTORY HERE"
TOTALBAMS=0
OLDINDEX=0
UNINDEXED=0
for file in $DIR*.bam; do # Iterate over all bam files in given directory
@Phoenix-Effect
Phoenix-Effect / main.py
Last active Feb 11, 2022
Scrape videos data from youtube and push to airtable. By default reads from videos.txt but can defined with an argument.
View main.py
import pafy
import os
import glob
import re
from airtable import Airtable
from airtable.auth import AirtableAuth
import requests
from pathlib import Path
from webvtt import WebVTT
@Phoenix-Effect
Phoenix-Effect / frequency.java
Created Jul 3, 2018
Count frequency of a string in a given array without using any functions or classes in Java.
View frequency.java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Main {
static void staircase(String[] votes) {
@Phoenix-Effect
Phoenix-Effect / main.java
Created Jul 3, 2018
Example of how you can read and parse JSON file in Java. Requires JSON library.
View main.java
import org.json.*;
import java.io.*;
public class main {
public static JSONObject obj;
public static void main(String args[]){
try {
obj = new JSONObject( fileToString("src/main/resources/questions.json") );
JSONArray questionsArray = obj.getJSONArray("question");
@Phoenix-Effect
Phoenix-Effect / videoThumbnail.php
Created Jul 3, 2018
Given a url of a video hosted on ted, youtube or vimeo, finds where the video is hosted and outputs the thumbnail for that video.
View videoThumbnail.php
<?php
function outputVideoThumbnail($url){
$parsed_url = parse_url($url);
// if youtube is detected
if($parsed_url['host']=='www.youtube.com') {
$query = $parsed_url['query'];
$Arr = explode('v=',$query);
$videoIDwithString = $Arr[1];