Skip to content

Instantly share code, notes, and snippets.

View aytch's full-sized avatar

Brandon Presley aytch

  • Portland, OR, United States
View GitHub Profile
@aytch
aytch / gist:4538619
Created January 15, 2013 13:27
Quick hack for grabbing Twitter status in Cinch
require 'Nokogiri'
require 'open-uri
# current regex string matches too much stuff. Trying https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$ instead
on :message, /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i do |m, message|
# on :message, /https?:\/\/(www.)?twitter.com(.+)\W/i do |m, message|
url = message.to_s
doc = Nokogiri::HTML(open(url))
user = doc.at_css("span.username.js-action-profile-name b").text
status = doc.xpath("//div[3]/div/div/div/div/p").text[/\S(.+)/]
@aytch
aytch / gist:4559696
Last active December 11, 2015 06:29 — forked from anonymous/gist:4559621
#requires -version 2.0
# handy global variables
$GLOBAL:SMADLL = ([appdomain]::CurrentDomain.getassemblies()|?{$_.location -match "System.Management.Automation.dll"}).location
# $GLOBAL:SMDIR = (Get-ItemProperty 'hklm:/software/microsoft/System Center/2010/Service Manager/Setup').InstallDirectory
# $GLOBAL:SMSDKDIR = "${SMDIR}\SDK Binaries"
# $GLOBAL:SMDLL = "${SMSDKDIR}/Microsoft.EnterpriseManagement.Core.dll"
$GLOBAL:EMGTYPE = "Microsoft.EnterpriseManagement.EnterpriseManagementGroup"
$GLOBAL:DATAGENDIR = "$psScriptRoot\DataGen"
$GLOBAL:SMDEFAULTCOMPUTER = "US-DC-SCSM-01"
@aytch
aytch / gist:4563011
Created January 18, 2013 07:50
IRC bot using Cinch, plus a twitter link parser and join/part functions. This is ugly.
require 'cinch'
require 'cinch/plugins/AccidentalHaiku'
require 'cinch/plugins/CleverBot'
require 'Nokogiri'
require 'open-uri'
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.freenode.org"
#c.port = "7667"
on :message, do |message|
messagevar = message.to_s
end
@aytch
aytch / gist:4700356
Created February 3, 2013 02:52
Odd Behaviour in Tam_Tam
1.9.3-p327 :028 > m = messages.including("logs")
=> #<TamTam::MessageSet:0x3ffe16067918 size=2>
1.9.3-p327 :029 > m.by_count
=> {"logs, man"=>1, "all the logs"=>1}
on :message, /https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/i do |m, message|
url = message.to_s
doc = Nokogiri::HTML(open(url))
user = doc.at_css("span.username.js-action-profile-name b").text
status = doc.xpath("//div[3]/div/div/div/div/p").text[/\S(.+)/]
message = "Twitter | @#{user}: #{status}"
m.reply message
end
8 po0-3.dsr2.atl.epikip.net (216.81.59.2) 144.488 ms 140.586 ms 124.980 ms
9 * * *
10 episode.iv (206.214.251.1) 199.550 ms 196.257 ms 166.206 ms
11 a.new.hope (206.214.251.6) 162.699 ms 165.235 ms 178.705 ms
12 it.is.a.period.of.civil.war (206.214.251.9) 143.676 ms 154.537 ms 200.501 ms
13 * rebel.spaceships (206.214.251.14) 207.047 ms 169.444 ms
14 striking.from.a.hidden.base (206.214.251.17) 165.096 ms 141.690 ms 166.328 ms
15 have.won.their.first.victory (206.214.251.22) 217.763 ms 148.040 ms 141.027 ms
16 against.the.evil.galactic.empire (206.214.251.25) 157.579 ms 186.840 ms 188.769 ms
17 * during.the.battle (206.214.251.30) 199.371 ms 185.054 ms
@aytch
aytch / gist:4759862
Created February 12, 2013 02:54
Twitter Regex
/https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/i
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid32"
@aytch
aytch / Vagrantfile
Created February 15, 2013 15:43
Sample Vagrantfile that demonstrates how to bring up two servers.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "lucid32"