Skip to content

Instantly share code, notes, and snippets.

View indrajithi's full-sized avatar
:octocat:
Namaste

Indrajith Indraprastham indrajithi

:octocat:
Namaste
View GitHub Profile
@indrajithi
indrajithi / exception_handler.clj
Last active October 23, 2019 04:42
Compojure Exception Handeling Middleware, Clojure.
(ns nurture-clj.middleware.exception-handler
(:require [clj-http.client :as client]
[cheshire.core :refer [generate-string]]
[config.core :refer [env]]
[nurture-clj.log :as log]
[clojure.string :as str]
[schema.utils :as sc]
[config.core :refer [env]]
[ring.util.http-response :as respond]))
@indrajithi
indrajithi / random_string.clj
Created October 22, 2019 16:33
Generate random strings in cojure
;; Create random string in clojure
(defn rand-str [len]
(apply str (take len (repeatedly #(char (+ (rand 26) 97))))))
;small
(defn rand-strB [len]
(apply str (take len (repeatedly #(char (+ (rand 26) 65))))))
;caps
@indrajithi
indrajithi / flask_multy_file.py
Created June 4, 2019 17:42
flask multiple file upload
import os
import uuid
from flask import Flask
from flask import request
UPLOAD_FOLDER = 'uploads/'
ALLOWED_EXTENSION = set (['Pdf', 'docx'])
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@indrajithi
indrajithi / xpath_soup.py
Created May 28, 2018 19:56 — forked from ergoithz/xpath_soup.py
Generate unique XPATH for BeautifulSoup element
import itertools
def xpath_soup(element):
"""
Generate xpath of soup element
:param element: bs4 text or node
:return: xpath as string
"""
components = []
child = element if element.name else element.parent
@indrajithi
indrajithi / crawler.py
Last active May 3, 2018 09:45
A tiny web crawler in Python
# -*- coding: utf-8 -*-
# filename: crawler.py
# Author: Indrajith Indraprastahm
# Lisence: GPL v3: http://www.gnu.org/licenses/
#--------------------------------------------------------------------------------
# README
#--------------------------------------------------------------------------------
# Install Requirements
# pip install validators beautifulsoup4 lxml
import glob
import subprocess
for file in glob.glob('*.mp4'):
out = file[:len(file)-3]+"mp3"
proc = subprocess.Popen(["ffmpeg","-i",file,out,"-y"], stdout=subprocess.PIPE)
#Sat Feb 11 02:27:07 IST 2017
#Indrajith Indraprastham
from subprocess import call
import os
from os import listdir
from os.path import isfile, join
#get current directory path
mypath = os.getcwd()
alert("success");
@indrajithi
indrajithi / contest.c
Created September 6, 2015 21:14
CodeChef Contest
//Sunday 06 September 2015 10:56:37 PM IST
//Programmer: Indrajith indraprastham
// Other link: http://hostcode.sourceforge.net/view/3332
/*............... Question ...................
Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.
Relational Operators are operators which check relatioship between two values. Given two numerical values A and B you need to help chef in finding the relationship between them that is,
First one is greater than second or,
@indrajithi
indrajithi / lex_expression.l
Created August 18, 2015 20:18
Lex Program to check the entered arithmetic operation is valid or not
// Lex Program to check the entered arithmetic operation is valid or not
// Programmer: Indrajith Indraprastham
// Date : 19 AUG 2015 ; 1:34
// Note:
// Final expr with (a+b)*(a-b): ^({op1})({op1}?{op2}{op1}{op1}?)*{op2}?{op1}$
// Final expr with (a+b)(a-b) : ^({op1})({op1}*{op2}{op1}{op1}*)*{op2}?{op1}$
// ^({op1} : starts with op1;
// ({op1}*{op2}{op1}{op1}*)* : matches a+b+c+d
// {op2}?{op1}$ : ends expr with op1