- Create limited user account.
- From admin open gpedit.msc
- Go to Administrative Templates > System > Run only allowed Windows Applications
- Define applications as winword.exe, firefox.exe etc.
- Don't forget whatever you do to include gpedit.msc and mmc.exe otherwise you won't be able to get back in!
- Get rid of run... command.
Monday, December 1, 2008
How to lock down a computer
Monday, November 10, 2008
/!\ FAILSAFE /!\ Status: 500 Internal Server Error wrong number of arguments (1 for 0)
You probably added a method called Send which is causing this error to be thrown.
Rename your method to something other than 'Send'.
http://flexrails.blogspot.com/2008/04/failsafe-mystereous-error-message.html
Saturday, November 8, 2008
installing ruby 1.8.7 on rimuhosting stack
In order to make ruby 1.8.7 the default the symbolic links for ruby/gem/irb/erb/rake all need to be updated. Then all gems will need to be reinstalled, and indeed the passenger configuration in apache will need to be updated.
Installing mysql gem on rimuhosting server
checking for mysql_query() in -lmysqlclient... no
error if you don't do as follows:
gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config
Thursday, November 6, 2008
How to setup passenger on standard CENTOS5 Rimuhosting Stack
- Download latest gem tarball from http://rubyforge.org/frs/?group_id=126
- unpack and run ruby setup.rb
- apt-get install httpd-devel (yum won't work)
- run passenger installation as per www.modrails.com/install.html
- Robert is your father's brother
--
7 Lower shrubbery
Radley College
Abingdon
OX14 2HU
Monday, September 29, 2008
Gems & plugins via proxy
Wednesday, July 9, 2008
How to get a tab separated .txt file of events into Google Calendar
- Open .txt file in Notepad.
- Add first line with column headers: Start Date TAB End Date TAB etc.
- Find/Replace the weird apostrophes that have turned into 'O's with squiggles
- Save
- Open Outlook.
- Import .txt (DOS) file, preferably into a blank calendar
- Export from Outlook to .csv file
- Upload .csv file to Google Calendar.
- Regret not having read these instructions four hours ago.
Saturday, May 17, 2008
How to Show the date in Eruby
<% @today = Date.today %>
<h3 class="date"><span class="month"><%= @today.strftime("%b")%></span> <span
class="day"><%= @today.strftime("%d")%></span><span class="year">,<%= @today.strftime("%Y")%></span></h3>
Wednesday, May 7, 2008
A few things learnt on apache + mongrel cluster
Wednesday, April 30, 2008
Gem via proxy
It is well documented as part of gem help that using the following common options:
-p, –[no-]http-proxy [URL] Use HTTP proxy for remote operations
will allow gem to use the proxy server for remote operations. While this has worked for me before, but recently for some reason I have been getting errors. So, the other alternative that works for me is to set the environment variable HTTP_PROXY as such:
set HTTP_PROXY=http://[proxy url]:[port]
Actually this option is convenient. I have set the above environment variable permanently for the machines that I use at work which are behind proxy servers.
Thursday, April 3, 2008
Testing Mailer in Console
class MyMailer < ActionMailer::Base
def test_email
@recipients = "b@gmail.com"
@from = "blah"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end
MyMailer::deliver_test_email
Wednesday, April 2, 2008
String and Float formats
format(format_string [, arguments...] ) => string
sprintf(format_string [, arguments...] ) => string
Returns the string resulting from applying format_string to any
additional arguments. Within the format
string, any characters other than format
sequences are copied to the result. A format sequence consists of a percent sign,
followed by optional flags, width, and precision indicators, then
terminated with a field type character. The field type controls how the
corresponding sprintf argument
is to be interpreted, while the flags modify that interpretation. The field
type characters are listed in the table at the end of this section. The
flag characters are:
Flag | Applies to | Meaning
---------+--------------+-----------------------------------------
space | bdeEfgGiouxX | Leave a space at the start of
| | positive numbers.
---------+--------------+-----------------------------------------
(digit)$ | all | Specifies the absolute argument number
| | for this field. Absolute and relative
| | argument numbers cannot be mixed in a
| | sprintf string.
---------+--------------+-----------------------------------------
# | beEfgGoxX | Use an alternative format. For the
| | conversions `o', `x', `X', and `b',
| | prefix the result with ``0'', ``0x'', ``0X'',
| | and ``0b'', respectively. For `e',
| | `E', `f', `g', and 'G', force a decimal
| | point to be added, even if no digits follow.
| | For `g' and 'G', do not remove trailing zeros.
---------+--------------+-----------------------------------------
+ | bdeEfgGiouxX | Add a leading plus sign to positive numbers.
---------+--------------+-----------------------------------------
- | all | Left-justify the result of this conversion.
---------+--------------+-----------------------------------------
0 (zero) | bdeEfgGiouxX | Pad with zeros, not spaces.
---------+--------------+-----------------------------------------
* | all | Use the next argument as the field width.
| | If negative, left-justify the result. If the
| | asterisk is followed by a number and a dollar
| | sign, use the indicated argument as the width.
The field width is an optional integer, followed optionally by a period and
a precision. The width specifies the minimum number of characters that will
be written to the result for this field. For numeric fields, the precision
controls the number of decimal places displayed. For string fields, the
precision determines the maximum number of characters to be copied from the
string. (Thus, the format sequence
%10.10s will always contribute exactly ten characters to the
result.)
The field types are:
Field | Conversion
------+--------------------------------------------------------------
b | Convert argument as a binary number.
c | Argument is the numeric code for a single character.
d | Convert argument as a decimal number.
E | Equivalent to `e', but uses an uppercase E to indicate
| the exponent.
e | Convert floating point argument into exponential notation
| with one digit before the decimal point. The precision
| determines the number of fractional digits (defaulting to six).
f | Convert floating point argument as [-]ddd.ddd,
| where the precision determines the number of digits after
| the decimal point.
G | Equivalent to `g', but use an uppercase `E' in exponent form.
g | Convert a floating point number using exponential form
| if the exponent is less than -4 or greater than or
| equal to the precision, or in d.dddd form otherwise.
i | Identical to `d'.
o | Convert argument as an octal number.
p | The valuing of argument.inspect.
s | Argument is a string to be substituted. If the format
| sequence contains a precision, at most that many characters
| will be copied.
u | Treat argument as an unsigned decimal number. Negative integers
| are displayed as a 32 bit two's complement plus one for the
| underlying architecture; that is, 2 ** 32 + n. However, since
| Ruby has no inherent limit on bits used to represent the
| integer, this value is preceded by two dots (..) in order to
| indicate a infinite number of leading sign bits.
X | Convert argument as a hexadecimal number using uppercase
| letters. Negative numbers will be displayed with two
| leading periods (representing an infinite string of
| leading 'FF's.
x | Convert argument as a hexadecimal number.
| Negative numbers will be displayed with two
| leading periods (representing an infinite string of
| leading 'ff's.
Examples:
sprintf("%d %04x", 123, 123) #=> "123 007b"
sprintf("%08b '%4s'", 123, 123) #=> "01111011 ' 123'"
sprintf("%1$*2$s %2$d %1$s", "hello", 8) #=> " hello 8 hello"
sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8"
sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23"
sprintf("%u", -123) #=> "..4294967173"
Conditional validations
class User < ActiveRecord::Base validates_presence_of :password, :if => :should_validate_password? validates_presence_of :state, :on => :create validates_presence_of :state, :if => :in_us? attr_accessor :updating_password def in_us? country == 'US' end def should_validate_password? updating_password || new_record? end end # in controller @user.updating_password = true @user.save @user.save(false) # will avoid any validation in the model
Tuesday, April 1, 2008
time.strftime( string ) => string
Formats time according to the directives in the given format
string. Any text not listed as a directive will be passed through to the
output string.
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
passing a variable to a partial
Passing a variable to a partial means you can be clever about re-using your code to output different collections of data in the same way.
Essentially you just write:
<%= render :partial => '/path/to/_partial', :locals => { :items => @items } %>
The local variable items now makes each element of @items available in the partial. e.g.
<% for item in items -%>
do something...
<% end -%>
Wednesday, March 19, 2008
Password Validation
- Users must supply a passphrase when signing up
- Passphrases should be between 8 and 64 characters in length
- It is not necessary to supply a passphrase when updating an existing record
- Confirmation must be supplied when setting a new passphrase on an existing record
These requirements lead to the following validations:
MINIMUM_PASSPHRASE_LENGTH = 8
MAXIMUM_PASSPHRASE_LENGTH = 64
validates_presence_of :passphrase,
:on => :create
validates_length_of :passphrase,
:in => MINIMUM_PASSPHRASE_LENGTH..MAXIMUM_PASSPHRASE_LENGTH,
:if => Proc.new { |u| !u.passphrase.blank? }
validates_confirmation_of :passphrase,
:if => Proc.new { |u| !u.passphrase.blank? }
Tuesday, March 18, 2008
Wma player embedding example
<object id="MediaPlayer" height=50 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
<param name="filename" value="http://ws.radley.org.uk/Public/Modern%20Languages/Deutsch/media/AQA_GCSE/AQA%202003%20specimen.wma">
<embed type="application/x-mplayer2" src="http://ws.radley.org.uk/Public/Modern%20Languages/Deutsch/media/AQA_GCSE/AQA%202003%20specimen.wma" name="MediaPlayer" width=600 height=50></embed>
</object>
<p>
Download paper <a href="http://ws.radley.org.uk/Public/Modern%20Languages/Deutsch/media/AQA_GCSE/papers/listen%202003%20spec.pdf" target="_blank">here</a>
Partial syntax
<%= render :partial => "signup_form" %>
This would render "_signupform.html.erb" and pass the instance variable @signup_form in as a local variable account to the template for display.
