This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Notice I set UTF-8 as the default above. As far as I'm concerned there | |
# are two choices of encoding: UTF-8, and legacy crap. If I need to deal | |
# with anything else I'll handle it explicitly, as in this example. | |
# Open an ISO-8859-1 file. | |
infile = File.open("iso88591.txt", "r:iso-8859-1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Programs to install from the Java runtimes | |
PROGS = ['java', 'javac', 'javaws', 'jar', 'keytool'] | |
# Plugins for browsers, original lib name then the name to use in the | |
# alternatives system | |
PLUGINS = { | |
'libnpjp2.so' => 'libjavaplugin.so' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) { | |
FILE *ifp, *ofp; | |
ofp = fopen("test.txt", "wb"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Google Reader to Evernote | |
# Quick hack together of a Ruby script which will pull all your Google Reader | |
# starred items into an Evernote notebook in ENML (Evernote export format). | |
# Requires Ruby 2.0, no other special dependencies. Should work on 1.9 but I | |
# haven't tested it. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# encoding: UTF-8 | |
# The audit team wanted to know that we were doing logging as required. As | |
# evidence, they asked for a regular report consisting of the first 10 lines | |
# of each daily log file. I wrote this script to automate the process. | |
# If you want the last 10 lines instead, I suggest the Ruby Gem called Elif, | |
# which wraps any IO object to read line by line backwards. | |
LINES_OF_LOG = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is the script piece of an Automator workflow, it won't work without the rest of the workflow. | |
on run {input, parameters} | |
set maxDaysOld to 14 -- This is the number of days of stuff to keep | |
set oldFiles to {} | |
set oldFilesRef to a reference to oldFiles | |
repeat with n from 1 to length of input | |
set thing to item n of input | |
set dateAddedString to (do shell script "mdls -name kMDItemDateAdded -raw " & quoted form of POSIX path of thing) | |
set dateadded to the (date dateAddedString) | |
set daysold to ((current date) - dateadded) / 86400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Simple password generation in Ruby. | |
# | |
# Generate reasonably secure random passwords of any chosen length, | |
# designed to be somewhat easy for humans to read and remember. | |
# Each password has a capitalized letter and a digit. | |
# | |
# Example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# An example of BluePages / IBM Intranet Password authentication using Ruby. | |
# Uses the gem ruby-ldap, a Ruby wrapper for OpenLDAP. Works with Ruby 2.0. | |
# | |
# To get this code to work, you must | |
# | |
# 1. gem install ruby-ldap | |
# 2. add | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See https://forum.golangbridge.org/t/generation-of-strings-generation/2968/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# Script to take IBM Lotus Domino console input on stdin, and send it to | |
# syslog. | |
# | |
# Allows you to do all your logging via syslog, rather than having to | |
# keep weeks of data in log.nsf. | |
# | |
# In rsyslog, filter like this: |