Skip to content

Instantly share code, notes, and snippets.

View zenchild's full-sized avatar

Dan Wanek zenchild

View GitHub Profile
# To get Sinatra PUT methods to work read the request body instead of params.
# This was discussed in the Sinatra Google group:
# http://groups.google.com/group/sinatrarb/browse_thread/thread/7d1a52806492d5ea/9615ffc455a6336c?lnk=gst&q=put#9615ffc455a6336c
require 'rubygems'
require 'sinatra'
put '/:id' do
if( ! File.exists? "outfiles" )
Dir.mkdir "outfiles"
# Initial mock-up of a Facebook Connect adapter for Facebooker. This takes some additional
# changes in session.rb if you want it to be cleanly implemented.
module Facebooker
class FacebookConnectAdapter < FacebookAdapter
def secret_key
warn 'Secret Keys are depreciated in Facebook Connect'
return nil
# To link to OWA from an EWS item_id you must first convert the ID to something OWA will understand. You can do it using the following. After that, open the item like so:
# https://host/owa/?ae=Item&a=open&id=<converted item id>
$: << 'lib'
require 'viewpoint'
vp = Viewpoint::ExchWebServ.instance
vp.authenticate
vp.find_folders
msgs = vp.get_folder('Inbox').get_todays_messages
msg = msgs.last
desc "generate FFI constants"
task :ffi_consts do
require 'rubygems'
require 'ffi'
require 'ffi/tools/const_generator'
consts = FFI::ConstGenerator.new("Utmp") do |cg|
cg.include 'utmp.h'
process_constants = %w{
EMPTY RUN_LVL BOOT_TIME NEW_TIME OLD_TIME INIT_PROCESS
LOGIN_PROCESS USER_PROCESS DEAD_PROCESS ACCOUNTING
--- io_nix.c 2008-03-29 16:53:32.000000000 -0500
+++ io_nix.c.new 2009-11-24 08:36:45.000000000 -0600
@@ -192,6 +192,11 @@
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
+ /* You cannot guarantee that this will automatically be set to 0 so
+ * it is explicitly set here.
+ */
+ addr.l2_cid = 0;
# Test NTLM authentication for httpclient
require 'rubygems'
require 'httpclient'
client = HTTPClient.new
domain = 'https://test.com/ews/'
user = 'user'
pass = 'pass'
@zenchild
zenchild / cal2ical.rb
Created December 11, 2009 01:48
Exchange Cal to iCal
require 'rubygems'
require 'viewpoint'
# Get the instance of Viewpoint. This is a singleton class and will
# have only one instance ever instantiated no matter how many times
# you call #instance
vp = Viewpoint::ExchWebServ.instance
# Set authentication parameters (probably NTLM)
vp.authenticate
// This is a convenience method that exists to determine if the window should be closed or not.
// There could be a lot more logic here, but for now we are just closing any window whose
// location property is equal to "chrome://global/content/commonDialog.xul", which is what the
// alert boxes that I have tested use.
alertClose: function (subject) {
if(subject.location == "chrome://global/content/commonDialog.xul") {
window.setTimeout(function() { subject.close(); }, 1000);
}
}
require 'openssl'
class Encryptor
def initialize(key_pass, key_size = 1024, key_name = 'rsakey.sec', cipher = OpenSSL::Cipher.new('aes-256-cbc'))
@key_size = key_size
@cipher = cipher
@key_name = key_name
if( File.exists?(@key_name) )
require 'openssl'
require 'yaml'
class Encryptor
def initialize(key_pass, key_size = 2048, key_name = 'rsakey.sec', cipher = OpenSSL::Cipher.new('aes-256-cbc'))
@key_size = key_size
@cipher = cipher
@key_name = key_name