Skip to content

Instantly share code, notes, and snippets.

View durgaswaroop's full-sized avatar
💭
Having Fun

Swaroop durgaswaroop

💭
Having Fun
View GitHub Profile
@durgaswaroop
durgaswaroop / tweeter.py
Created December 31, 2017 11:51
Tweet from Python
import tweepy
import os
import re
import CommentParser
import sys
import subprocess
import yaml
def tweet(html_file, post_url):
@durgaswaroop
durgaswaroop / medium_publish.py
Created December 31, 2017 11:41
Publish post on Medium
import json
import requests
import os
import sys
def publish(html_file, title, labels):
access_token_file = '~/.medium-access-token'
expanded_path = os.path.expanduser(access_token_file)
print(expanded_path)
@durgaswaroop
durgaswaroop / blogger_modifications.py
Created December 31, 2017 11:37
Modifications needed to be done on html generated by pandoc for blogger
import sys
import os
import fileinput
# alias modifications="python ~/Desktop/30DaysOfBlogging/modifications.py"
# Run the script with `modifications <markdown file>`
def modify(html_file):
# If file doesnot exist, just exit
@durgaswaroop
durgaswaroop / blogger_publish.py
Created December 31, 2017 11:36
Publish to blogger
# Call easyblogger
# Client secret and authentication is already stored in ~/.easyblogger.credentials
# blogid is stored in ~/.easyblogger
import subprocess
import blogger_modifications
def publish(html_file, title, labels, post_id):
# print('publishing', html_file, 'with title', title, 'labels', labels, 'and post-id', post_id, flush=True)
@durgaswaroop
durgaswaroop / publish.py
Created December 31, 2017 11:21
Publish the article to either Blogger or Medium
# Should read in Article title, tags from the md file
# Call the modifications file and do it on the output html
# Publish to Blogger but as a draft
import sys, os, re
import blogger_publish, medium_publish
import CommentParser
def main():
@durgaswaroop
durgaswaroop / blog-it.sh
Created December 31, 2017 11:05
Script file that starts the main process
#!/bin/bash
shopt -s expand_aliases
source ~/.bashrc
[ $# -eq 0 ] && {
echo "Title argument missing"
echo "Usage: blog-it <article-title>";
exit 1;
}
@durgaswaroop
durgaswaroop / Autoblogging-on-medium.py
Created December 29, 2017 08:51
Write articles on Medium without leaving command line
import json
import requests
access_token = '181d415f34379af07b2c11d144dfbe35d' #Fake token, obviously!
headers = {
'Authorization': "Bearer " + access_token,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84'
}
@durgaswaroop
durgaswaroop / Datasets-part1.java
Last active December 27, 2017 08:09
First part of the Datasets in Apache spark
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import static org.apache.spark.sql.functions.col;
import static org.apache.spark.sql.functions.desc;
public class DataSetMain {
public static void main(String[] args) {
// Initialize Sparksession
@durgaswaroop
durgaswaroop / m2h.py
Last active December 31, 2017 11:13
Markdown to html with pandoc
import sys, subprocess, os.path, time
# alias m2h="python ~\Desktop\30DaysOfBlogging\m2h.py"
# Run the script with `m2h <markdown file>`
# One argument, which is the name of the to be created markdown file
if len(sys.argv) is not 2:
print("ERROR: One and only one argument needed. Markdown file")
sys.exit()
@durgaswaroop
durgaswaroop / blog.py
Last active March 14, 2023 08:35
Script to create md and html files with the given title
import sys
import subprocess
import os.path
import inflect
# alias blog="python ~\Desktop\30DaysOfBlogging\blog.py"
# Run the script with `blog <title>`
def main():