Skip to content

Instantly share code, notes, and snippets.

@Arcath
Arcath / oufavorites.vbs
Created December 14, 2011 09:18
OU Based Favorites
' Assign Favorites Based on OU
' Written by Adam "Arcath" Laycock
' December 2011
' Variables
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objShell=CreateObject("Wscript.Shell" ) 'Create the Shell Object
favUnc = "\\hpml350\School Folders\Pupil Favorites\" ' Set This to the UNC path for your favorits folder
@Arcath
Arcath / seasonal.vbs
Created December 12, 2011 10:00
Seasonal Greeter for BGinfo
' Very Basic Seasonal greeter for BGInfo
' Add a case for each month, and then a sub select for the day (if needed)
Select Case (DatePart("m", now))
case 1 ' January
Select Case (DatePart("d", now))
case 1, 2, 3, 4, 5, 6, 7, 8, 9
Echo("Happy New Year!")
End Select
@Arcath
Arcath / ouprinters.vbs
Created December 6, 2011 13:42
OU Based Printer script
' Printer Script based on AD OU
' Written by Adam Laycock (Arcath)
' July 2009
' Updated December 2011
' Variables
Set WshNetwork = WScript.CreateObject("WScript.Network") ' Network Object
Set oPrinters = WshNetwork.EnumPrinterConnections ' Printers Sub Object
printServer = "printserver" ' Hostname of your Print Server (add more if you have multiple print servers
@Arcath
Arcath / adsettings.rb
Created April 19, 2011 11:57
Code for AD Auth post
SERVER = '10.0.0.1' # Active Directory server name or IP
PORT = 389 # Active Directory server port (default 389)
BASE = 'DC=arcath,DC=local' # Base to search from
DOMAIN = 'arcath.local' # For simplified user@domain format login
@Arcath
Arcath / gist:888650
Created March 26, 2011 21:27
LDAP Omniauth session code (post ldap improving)
def create
ldap_user = ActiveDirectoryUser.authenticate(params[:username], params[:password])
user = User.find_by_provider_and_uid("ldap",params[:username]) || User.create_with_omniauth("ldap",params[:username])
user.name = ldap_user.name
user.groups = ldap_user.groups.join(",")
user.save
if LDAP_AllowedGroups != (LDAP_AllowedGroups - user.groups.split(",")) then
session[:user_id] = user.id
redirect_to "/pages/splash"
else
@Arcath
Arcath / gist:888172
Created March 26, 2011 09:51
LDAP Omniauth session code (pre ldap improving)
def create
user = User.find_by_provider_and_uid("ldap",params[:username]) || User.create_with_omniauth("ldap",params[:username])
session[:user_id] = user.id
redirect_to "/pages/splash"
end
@Arcath
Arcath / restactivedesktop.vbs
Created February 17, 2011 10:12
Resets Active desktop so that on next login it works fine
HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer\Desktop\SafeMode\Components"
strValue = "0"
ValueName = "DeskHtmlVersion"
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
@Arcath
Arcath / gist:705370
Created November 18, 2010 18:18
TrainBBCode Callback Demo
def up_handler(input)
input.upcase
end
>> "[up]HeLlo WorLd[/up]".tbbc(:custom_tags => [[/\[up\](.*?)\[\/up\]/,"Callback: up_handler",true]])
=> "HELLO WORLD"
@Arcath
Arcath / comments_controller.rb
Created October 17, 2010 08:03
Nested model create action using SpamHam
def create
@post = Post.find(params[:post_id]) if params[:post_id]
@post = Post.find(params[:comment][:post_id]) if params[:comment][:post_id]
@comment = @post.comments.new(params[:comment])
@comment.user_id = current_user.id if current_user
if @comment.body.spam? then
unless params[:recaptcha_challenge_field] then
flash[:error] = "Comment looks like Spam"
render :action => 'new'
else
@Arcath
Arcath / gist:580440
Created September 15, 2010 08:43
gist embedding tag for tbbc
[/\[gist\](.*?)\[\/gist\]/,'<script src="http://gist.github.com/\1.js"> </script>',:code_enabled],
[/\[gist=(.*?)\](.*?)\[\/gist\]/,'<script src="http://gist.github.com/\2.js?file=\1"> </script>',:code_enabled]