Skip to content

Instantly share code, notes, and snippets.

@arjunmenon
arjunmenon / Lightweight Speech to Text with PocketSphinx.ipynb Simple, fast, reasonably accurate speech-to-text processing for audio recordings of speech.
View Lightweight Speech to Text with PocketSphinx.ipynb
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 Aug 14, 2018 — forked from pachacamac/codepenclone.html
Mini Codepen Clone with sharing function
View codepenclone.html
<!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; }
View Readme.md

Run test_glade.rb
Run basic.rb

@arjunmenon
arjunmenon / create_xml.rb
Created Jun 12, 2018 — forked from kimjoar/create_xml.rb
Simple Ruby DSL to generate XML
View create_xml.rb
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 Jun 6, 2018 — forked from huy/Hash.from_xml
Convert xml to hash using Nokogiri
View Hash.from_xml
# 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 Apr 10, 2018 — forked from seyhunak/vin_to_gif.rb
Vine MP4 to GIF Converting using Ruby
View vin_to_gif.rb
# 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 / python_server
Created Jan 1, 2018
Python server monitring any HTTP requests
View python_server
#!/usr/bin/env python
# Read requests from HTTP methods GET, POST, PUT, DELETE, NOTIFY or any other custom method
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
View index.js
var Client = require('./upnp_client.js')
var client = new Client('http://192.168.1.6:49152/description.xml');
console.log(client);
// Get the device description
client.getDeviceDescription(function(err, description) {
if(err) throw err;
console.log("starting device description module")
console.log(description);
@arjunmenon
arjunmenon / strip HTML tags
Created Oct 16, 2017 — forked from awesome/strip HTML tags
ruby strip HTML tags
View 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>
@arjunmenon
arjunmenon / Ruby Snippets.md
Last active Nov 14, 2017
Practical Ruby snippets
View Ruby Snippets.md
  1. Split sentence preserve punctuation
    https://stackoverflow.com/a/15687656/2096740

Use scan (throw strip in there to get rid of trailing spaces).

s = "I am a lion. Hear me roar! Where is my cub? Never mind, found him."
s.scan(/[^\.!?]+[\.!?]/).map(&:strip) # => ["I am a lion.", "Hear me roar!", "Where is my cub?", "Never mind, found him."]

  1. Simple detect puncutation in string