Skip to content

Instantly share code, notes, and snippets.

View mgrigajtis's full-sized avatar

Matthew Grigajtis mgrigajtis

View GitHub Profile
@mgrigajtis
mgrigajtis / gist:144897e0a20c890e5891
Created August 8, 2014 20:05
DataTables in Rails
In the CoffeeScript:
# Row clicking
selected_id = ''
$('#table_name tbody').on "click", "tr", ->
if $(event.target.parentNode).hasClass("info")
$(event.target.parentNode).removeClass "info"
selected_frame_order = ''
else
table_name.$("tr.info").removeClass "info"
$(event.target.parentNode).addClass "info"
enscript -1rG --line-numbers -p - --highlight=javascript --color=1 --word-wrap file_name.txt > ~/http://out.ps && open ~/http://out.ps`
@mgrigajtis
mgrigajtis / gist:e8cc737ecf405b14bf24
Created May 29, 2014 13:53
Parsing ElasticSearch Results with Java
import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;
import org.json.JSONArray;
import org.json.JSONObject;
protected void foo () {
// The input stream from the JSON response
BufferedInputStream buffer = null;
@mgrigajtis
mgrigajtis / jSearch.ashx
Created December 12, 2012 19:19
jSearch Addon
Imports System.Net
Imports System.Web
Imports System.Web.Services
Public Class jSearch
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim byteRequestedHtml() As Byte = Nothing
@mgrigajtis
mgrigajtis / gist:4236084
Created December 7, 2012 20:03
JavaScript function that returns info from between tags (Requires jQuery).
function getTitle(html) {
var strHtml = null;
try {
strHtml = html.replace(/<!\[CDATA\[(.+?)\]\]>/g, function (_match, body) {
return body.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
});
strHtml = strHtml.replace(/<!--.+?-->/g, '');
@mgrigajtis
mgrigajtis / ScrapeCraigslist.rb
Created January 30, 2012 17:18
Script that searches Craigslist
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'tlsmail'
require 'time'
require 'net/smtp'
def send_email(from, from_alias, to, to_alias, subject, message)
msg = <<END_OF_MESSAGE
From: #{from_alias} <#{from}>