Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sudevschiz's full-sized avatar
🎯
Focusing

Sudev sudevschiz

🎯
Focusing
  • Soon enough!
  • Tokyo, Japan
View GitHub Profile
@sudevschiz
sudevschiz / feed_fish.py
Created December 28, 2022 15:26
Gist to control the servo connected to Raspberry Pi that feeds the fishes at specific time and notify by telegram
import pigpio
from time import sleep, strftime
from telegram.ext import Updater
BOT_TOKEN = ""
CHAT_ID = ""
# Pin
PIN = 17
@sudevschiz
sudevschiz / build_raw_data.py
Last active August 13, 2020 10:21
Concats all raw_data files with cleaning steps. Compares with the gospel to output the differences.
import pandas as pd # pylint: disable=import-error
import re
from pathlib import Path
import logging
import sys
import os
from urllib.error import HTTPError
# Set logging level
logging.basicConfig(stream=sys.stdout,
format="%(message)s",
@sudevschiz
sudevschiz / query_results.txt
Created July 25, 2020 16:53
Twitter results
(#AndamanFightsCOVID19) (from:ChetanSanghi)
------------------------------
(COVID-19 OR patients OR recovered OR discharged OR Active) (from:Andaman_admin)
------------------------------
***
http://twitter.com/Andaman_Admin/status/1287044453862055936
from datetime import datetime
import pandas as pd
import numpy as np
# Read merged data
df = pd.read_csv('https://api.covid19india.org/csv/latest/raw_data.csv')
df.head()
df['Date Announced'] = pd.to_datetime(df['Date Announced'])
df = df[df['Date Announced'] <= '2020-04-26']
df['District_Key'] = df['State code'] + "_" + df['Detected District']
@sudevschiz
sudevschiz / vision_response
Created June 20, 2020 08:39
vision_response
label_annotations {
mid: "/m/0fbf1m"
description: "Terrestrial animal"
score: 0.993838369846344
topicality: 0.993838369846344
}
label_annotations {
mid: "/m/03bk1"
description: "Giraffe"
score: 0.9926815032958984
@sudevschiz
sudevschiz / fetch_raw_data.py
Created March 30, 2020 10:41
Raw data from api.covid19india.org
import requests
import pandas as pd
r = requests.get("https://api.covid19india.org/raw_data.json")
pdb = r.json()
df = pd.DataFrame.from_dict(pdb['raw_data'])
@sudevschiz
sudevschiz / time_wise_update.gs
Created March 26, 2020 10:15
In Google Scripts : Fetch data from an API, compare some change and update last updated time
function time_wise_update(){
var getSheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var setSheet = SpreadsheetApp.getActive().getSheetByName("Sheet2");
var url = 'https://xxx/data.json';
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
var json = response.getContentText();
var data = JSON.parse(json);
var ss = data.ss;
@sudevschiz
sudevschiz / rand_color_gen.py
Created November 27, 2019 06:38
Generate list of N random HEX values, which can be used as coloring palettes in plotting libaries
def rand_color_gen(n=1):
h_v = []
for i in range(0,n):
i+=1
r = lambda: random.randint(0,255)
h_v.append('#%02X%02X%02X' % (r(),r(),r()))
return h_v
# Just random colors. No guarantee of any sort.
import io
def load_vectors(fname):
fin = io.open(fname, 'r', encoding='utf-8', newline='\n', errors='ignore')
n, d = map(int, fin.readline().split())
data = {}
for line in fin:
tokens = line.rstrip().split(' ')
data[tokens[0]] = list(map(float, tokens[1:]))
return n,d,data
#### Function to validate classification models####
accuracy_metrics <- function(y_actual, y_predicted) {
#Check if the input is factor
if(is.factor(y_actual)){
print("Info : Actual values provided as factor. Factor converted to numeric. ")
#Convert to numeric