Skip to content

Instantly share code, notes, and snippets.

@kshwetabh
kshwetabh / feeds.opml
Created January 24, 2023 06:23 — forked from stebennett/feeds.opml
The feeds I currently subscribe to.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Stephen subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="Companies" title="Companies">
<outline type="rss" text="Trello" title="Trello" xmlUrl="https://trello.engineering/feed.xml" htmlUrl="http://tech.trello.com/"/>
<outline type="rss" text="IMVU" title="IMVU" xmlUrl="http://engineering.imvu.com/feed/" htmlUrl="https://engineering.imvu.com"/>
@kshwetabh
kshwetabh / GMailReminder.gs
Created February 11, 2013 02:09
Reminder script for GMail: A simple Google Apps Script to create a Google Calendar event (reminder) for any mail (with a specific label). You can then setup ("timed") triggers in Apps Script... (public version of the GMailReminder gist)
/**
* Reminder script for GMail: A simple Google Apps Script to create a Google Calendar event (reminder) for any mail (with a
* specific label). You can then setup ("timed") triggers in Apps Script (hourly, etc) to monitor your Inbox.
* How to Use:
* 1. Log into Google Drive account and create a Google Script.
* 2. Copy and paste the below snippet into the gs file.
* 3. Make sure to update the 'reminderLabel', 'calendarName' and 'reminderDuration' as per your preference.
* 4. Test the script to make sure it is working properly.
* 5. Setup a time-driven Project Trigger (hourly, etc) to automatically run this script and create calendar events.
*
@kshwetabh
kshwetabh / textToSpeech.py
Created March 2, 2020 10:00
This script speaks and converts text-to-speech (mp3) using python's pyttsx3 library. This code has been tested on Windows 10 system and requires pywin32 and pyttsx3 python packages to be installed.
import pyttsx3
text = "When you invest for five years or above, you can expect gains that comfortably beat the inflation rate and are also higher than fixed income options. But be prepared for ups and downs in your investment value along the way. Aggressive"\
" hybrid funds invest 65-80% of your money in equity shares and the rest in bonds and commodities. Their returns are slightly lower than pure equity funds which"
engine = pyttsx3.init();
engine.setProperty('volume', 1)
engine.setProperty('rate', 160)
engine.say(text)
@kshwetabh
kshwetabh / InstallEmacs In WSL (Windows 10)
Created December 20, 2019 05:33
InstallEmacs In WSL (Windows 10)
## Copied from https://github.com/hubisan/emacs-wsl for duplication in case that repo is gone.
## install dependencies
sudo apt install -y build-essential texinfo libx11-dev libxpm-dev \
libjpeg-dev libpng-dev libgif-dev libtiff-dev libgtk2.0-dev \
libncurses-dev gnutls-dev libgtk-3-dev libgnutls28-dev
# some more from a stackoverflow, eww was not working before
@kshwetabh
kshwetabh / android_video_stream_to_opencv.py
Last active August 14, 2019 05:11
This script requires IPCam app (or any other app that can stream images/videos over HTTP) to be installed on Android device and OpenCV to installed on Desktop machine. On running this script, OpenCV will detect front-faces in videos streamed on the desktop. #python #opencv #android #face-detection
import requests
import cv2
import numpy as np
# Online code reference: https://www.youtube.com/watch?v=-mJXEzSD1Ic
# Image URL being streamed from IPWebCam app (I used the one written by Pavel Khlebovich).
# Make sure that the android device and the machine running opencv are on the same network and
# you can access the streaming URL from that machine
url = 'http://192.168.43.236:8080/shot.jpg'
@kshwetabh
kshwetabh / JavaScript Convenient Logger.js
Last active July 25, 2019 05:45
A convenient method to direct console.log/error statements to be written into a DIV and in browser's console.
//Code borrowed from: https://github.com/aws-samples/amazon-kinesis-video-streams-media-viewer
function configureLogging() {
console._error = console.error;
console.error = function(messages) {
log('ERROR', Array.prototype.slice.call(arguments));
console._error.apply(this, arguments);
}
console._log = console.log;
@kshwetabh
kshwetabh / XoomXChangeRateTrendGraph.gs
Last active June 17, 2018 14:23
Xoom Exchange Rate Trend - Draws a graph indicating the exchange rate trend of Xoom.com Online Money Transfer Website.
/**
* Services combined together:
* ~Yahoo Pipes~, Gmail, Google App Script, GDrive, Google Charts
*
* This is a Google App Script Web App that draws a Column Graph highlighting the current and historical exchange rate trend of
* Xoom Money Transfer. Created this simple app to keep an eye on the $ to Rupee up/down trend.
* Has a related excel sheet also.
*
* Output (snapshot): https://plus.google.com/photos/108969069990423509081/albums/6115274347350257297?authkey=CKOFv9-t77O4kAE
*
@kshwetabh
kshwetabh / useful_pandas_snippets.py
Created January 11, 2018 04:11 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@kshwetabh
kshwetabh / LoadDataIntoPostgreSQL.py
Created January 11, 2018 04:06
Use this script to load NIFTY Intraday data into PostgreSQL Database
import psycopg2
conn = psycopg2.connect("host='localhost' port='5432' dbname='stocks' user='xxxxxx' password='xxxxxx'")
cur = conn.cursor()
SQL_STATEMENT = """
COPY %s FROM STDIN WITH
CSV
HEADER
DELIMITER AS ','
"""
@kshwetabh
kshwetabh / CurrentWeatherWall.py
Created January 8, 2012 20:52
Change Wallpaper based on current weather condition
import os
import pywapi
import string
'''
CurrentWeatherWall
Set you desektop wallpaper as per the current weather condition
OS: Ubuntu {I have tested on Ubuntu 11.10}
See the import statements for Python module dependencies