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 / 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 / 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 / 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 / JSHintTasks.xml
Created June 20, 2014 06:48
Ant based task to Lint the modified files with JSHint.
<?xml version="1.0" encoding="UTF-8"?>
<!-- @author Kumar Shwetabh, @version 1.0 -->
<!-- Based upon https://github.com/philmander/ant-jshint -->
<!-- Add reference to http://jslinterrors.com in the reports file -->
<project name="LintTasks" default="LintTasks" basedir=".">
<property name="FilesToLint" value="C:/LintFiles"/>
<property name="ReportFile" value="${basedir}/jshint/results.html"/>
<target name="LintTasks">
@kshwetabh
kshwetabh / chromeDevToolsSnippets.js
Last active December 28, 2015 01:09
Chrome Dev Tools Snippets
//Great online repo for more snippets: https://bgrins.github.io/devtools-snippets/
/*************************************************
//Cache Buster
Overwrite all link and (optionally) script tags by adding Date.now()
at the end of href and src attributes, respectively. By default processing
scripts is not performed, you should change the variable process_scripts
to true to run these.
/*************************************************/
(function (){