Skip to content

Instantly share code, notes, and snippets.

@arjunmenon
arjunmenon / Lightweight Speech to Text with PocketSphinx.ipynb
Created December 12, 2021 22:33 — forked from stevemclaugh/Lightweight Speech to Text with PocketSphinx.ipynb
Simple, fast, reasonably accurate speech-to-text processing for audio recordings of speech.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arjunmenon
arjunmenon / codepenclone.html
Created August 14, 2018 12:48 — forked from pachacamac/codepenclone.html
Mini Codepen Clone with sharing function
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MiniCodepenClone</title>
<style>
body,textarea,iframe{ margin:0; box-sizing:border-box; }
textarea,iframe { width:100%; height:50vh; float:left; }
textarea { color:#eee; background:#111; font-family:monospace; font-size:11pt; line-height:1.4; width:33.33%; }
#shareBtn { position:absolute; bottom:0; left:0; }
@arjunmenon
arjunmenon / create_xml.rb
Created June 12, 2018 12:01 — forked from kimjoar/create_xml.rb
Simple Ruby DSL to generate XML
require './xmldsl'
Twitter = Struct.new :name, :avatar, :text
twitters = []
5.times { twitters << Twitter.new("Jonas", "/profile.png", "Hello World!") }
xml = XML.generate do
html do
body do
twitters.each do |tw|
@arjunmenon
arjunmenon / Hash.from_xml
Created June 6, 2018 21:07 — forked from huy/Hash.from_xml
Convert xml to hash using Nokogiri
# USAGE: Hash.from_xml(YOUR_XML_STRING)require 'rubygems'
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#123129
7
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
@arjunmenon
arjunmenon / vin_to_gif.rb
Created April 10, 2018 19:54 — forked from seyhunak/vin_to_gif.rb
Vine MP4 to GIF Converting using Ruby
# space150 vine-to-GIF
# given a vine.co uri, downloads the MP4 and creates an image sequence / GIF from it
# requires ruby, ffmpeg, and imagemagick
require 'open-uri'
require 'nokogiri'
id = ARGV[0]
# try to convert from URL to id.
@arjunmenon
arjunmenon / strip HTML tags
Created October 16, 2017 19:13 — forked from awesome/strip HTML tags
ruby strip HTML tags
# copied from (thanks!): http://codesnippets.joyent.com/posts/show/615
str = <<HTML_TEXT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h1>Application error</h1>
<p>Change this error message for exceptions thrown outside of an action (like
in Dispatcher setups or broken Ruby code) in public/500.html</p>
http://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
http://code.google.com/p/nltk/source/browse/trunk/nltk
http://wordnet.princeton.edu/wordnet/download/
http://code.google.com/p/nltk/source/browse/trunk/nltk/nltk/chunk/named_entity.py
http://www.writingcentre.uottawa.ca/hypergrammar/subjpred.html
http://nlp.stanford.edu/software/crf-faq.shtml
http://sourceforge.net/apps/mediawiki/opennlp/index.php?title=Name_Finder
http://en.wikipedia.org/wiki/Sentiment_analysis
http://arxiv.org/pdf/cs.LG/0212032
http://www.scribd.com/doc/7865458/the-learning-chatbot
@arjunmenon
arjunmenon / plate-snitch.js
Created August 30, 2017 16:18 — forked from taitems/plate-snitch.js
(Extract) Check the status of a vehicle registration and scrape results.
// Open form and submit enquire for `rego`
function getInfo(rego) {
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.open(url)
.type('#registration-number-ctrl input[type=text]', rego)
.click('.btn-holder input')
.waitForSelector('.ctrl-holder.ctrl-readonly')
.html()
.then(function(body) {
@arjunmenon
arjunmenon / convert-gifs.sh
Created August 26, 2017 13:41 — forked from shazow/convert-gifs.sh
Batch convert a directory of gifs into mp4
#!/usr/bin/bash
# Convert *.gif into *.mp4, skip if already exists.
outdir="."
for path in *.gif; do
out="${outdir}/${path/.gif/}.mp4"
[[ -f "$out" ]] && continue
ffmpeg -f gif -i "${path}" "${out}"
done
@arjunmenon
arjunmenon / crf_accuracy.py
Created April 14, 2017 13:54 — forked from kindleton/crf_accuracy.py
Calculate accuracy for CRF++ output file
import sys
f1 = open(sys.argv[1])
count = 0
true = 0
false = 0
sentences = 0
for line in f1:
if line == '\n' or line.split()==[]:
sentences+=1