Skip to content

Instantly share code, notes, and snippets.

View kirankulkarni's full-sized avatar

Kiran kirankulkarni

View GitHub Profile
;;; Implementation of Spacy example in Clojure using libpython-clj
;;; Ensure that clj-python/libpython-clj "1.45" is added in deps or project.clj
;;; Recommend to use Conda as your Python environment
(require '[libpython-clj.require :refer [require-python]])
(require '[libpython-clj.python :refer [py. py.. py.-] :as py])
;;; Import the Spacy python package
;;; Install Spacy using `pip install spacy` and model using `python -m spacy download en_core_web_sm`
(require-python 'spacy)
@kirankulkarni
kirankulkarni / find-offsets.clj
Last active April 17, 2017 12:28 — forked from kapilreddy/find-offsets.clj
Kafka message offset finder
;; project.clj
;; [clj-time "0.6.0"]
;; [org.clojure/data.json "0.2.4"]
;; [clj-kafka "0.2.8-0.8.1.1"]
;; Utility to find offsets in a given Kafka topic for a given
;; cursor/point in time. The code assumes that each message has a
;; monotonically increasing number (ex. unix timestamp) associated with
;; it.
@kirankulkarni
kirankulkarni / vagrant_helpers.sh
Last active August 29, 2015 14:06
A set of helper functions to suspend/resume your vagrant boxes from shellscript
#!/bin/bash
function vagrant_get_status()
{
cd "$1"
local status_op=$(vagrant status --machine-readable)
echo "$status_op" | while read line
do
local status_line=(${line//,/ })
local vagrant_type=${status_line[2]}
@kirankulkarni
kirankulkarni / objc-mode-config.el
Created October 12, 2012 22:29
Switching between header and source file in objective-C
(defun objc-in-header-file ()
(let* ((filename (buffer-file-name))
(extension (car (last (split-string filename "\\.")))))
(string= "h" extension)))
(defun objc-jump-to-extension (extension)
(let* ((filename (buffer-file-name))
(file-components (append (butlast (split-string filename
"\\."))
(list extension))))
@kirankulkarni
kirankulkarni / frequency.clj
Created August 18, 2011 19:27 — forked from kirankulkarni/frequency.clj
Get top 10 frequent words from file
(ns freq.core
(:import (java.io BufferedReader FileReader))
(:require [clojure.string :as string]))
(defn read-file-lazy
"Opens a file and creates a lazy-sequence to read each line"
[file-name]
(with-open [reader (BufferedReader. (FileReader. file-name))]
(line-seq reader)))
@kirankulkarni
kirankulkarni / frequency.clj
Created August 18, 2011 16:17
Get top 10 frequent words from file
(ns freq.core
(:import (java.io BufferedReader FileReader))
(:require [clojure.string :as string]))
(defn read-file-lazy
"Opens a file and creates a lazy-sequence to read each line"
[file-name]
(with-open [reader (BufferedReader. (FileReader. file-name))]
(line-seq reader)))
@kirankulkarni
kirankulkarni / nthroot.clj
Created December 14, 2010 11:52
Finds nthroot of given number
(ns kk_samples.nthroot)
(defn abs
"Calculate the absolute value of number"
[n]
(if (neg? n)
(* -1 n)
n))
(defn pow