IE9 couldn’t be downloaded
If you are getting this error in IE9, there is a simple fix, but no always easy to find
Untick this bad boy:
LinqDataSource join
Hi guys,
If you are ever using a LinqDataSource and want to join a second table, bad news, you can't. BUT if your edmx file sees the join between the tables, you can still reference it.
See following extract from the ASP.NET file:
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="MyDatabase.MyDatabaseEntities" EntityTypeName=""
OrderBy="DateCreated desc"
Select="new (ID, Name, Author.Name AS Author)"
TableName="Posts">
</asp:LinqDataSource>
Script summary: Failed loading then steps
This Kaseya error can be quite annoying to diagnose if you don't know what to look for.
It is caused by having a step (such as Set Registry Value) with < or > in it, as Kaseya use XML to save their scripts.
You can double tag it, eg <<br>> instead of <br> and it will run as expected.
Searching Recent Event Logs with C#
Hi guys,
Today I was looking into event log searching. I run a script that does a chkdsk on reboot but then when the machine boots I want to see the log from that report.
To do this, I search the registry for the most recent event within a certain time period (I choose 1 day). We can use Linq to make the filtering quite easy.
EventLog el = new EventLog();
el.Log = log;
el.MachineName = ".";
try
{
var result = (from EventLogEntry elog in el.Entries
where (elog.TimeGenerated >= DateTime.Now - new TimeSpan(days, 0, 0, 0))
&& (elog.Source.ToString().Equals(source))
&& (elog.EventID == id)
orderby elog.TimeGenerated descending
select elog).First();
Console.WriteLine(result.Message);
}
catch (InvalidOperationException)
{
Console.WriteLine("No results found. ");
}
Cheers to StackOverflow for the basis of this code.
RVM, Merb, Rake and RSpec
I was having terrible difficulty getting Merb to work with RSpec. Turns out that Merb now uses Bundler, and if you don't edit your Gemfile to include rspec it bails on you.
sam@shiny-dev:~/Projects/mojo$ rake db:migrate
(in /home/sam/Projects/mojo)
Merb root at: /home/sam/Projects/mojo
/home/sam/.rvm/gems/ruby-1.9.1-p378@merb/gems/dm-validations-1.0.0/lib/dm-validations.rb:33: warning: already initialized constant OrderedHash
Loading init file from ./config/init.rb
Loading ./config/environments/development.rb
rake aborted!
no such file to load -- spec/rake/spectask
/home/sam/Projects/mojo/Rakefile:24:in `require'
(See full trace by running task with --trace)
This was solved by adding the line:
gem "rspec", :require => "spec"
to the bottom of the Gemfile in the project root.
Ruby chat-server with Fibers & Eventmachine
Posting this mostly for my reference so I don't lose it again later.
require 'rubygems'
require 'eventmachine'
class Connection < EventMachine::Connection
attr_accessor :fiber, :name
def initialize
@fiber = Fiber.new { poll }
@name = nil
end
def post_init
(@@connections ||= []) << self
@fiber.resume
end
def poll
send_data( "What is your name?" )
@name = Fiber.yield
send_data( "OK, your name is #{@name}\n")
loop do
msg = Fiber.yield
@@connections.each do |conn|
conn.send_data( "#{@name} said: #{msg}\n")
end
end
end
def receive_data( data )
@fiber.resume data.strip
end
end
EventMachine.run do
EM.start_server "0.0.0.0", 2000, Connection
end
FUSS++
A while ago I started work on an improved version of SMAUG FUSS
While I since got distracted and stopped work on it, I'm releasing what I did so the community can continue it.
I place no additional license on the work I have added.
Note: It currently does not compile, but if you do get it to compile it you can use lua within mobprogs, roomprogs etc. I think I setup most of the triggers, eg rand triggers, drop, etc.
A lot of the commands I didn't set up, mpgoto etc, but they could be done better now with the lua support anyway.
It is available for download, here
Converting from VMWare to Virtualbox
Yesterday I used Virtualbox for the first time, to create a Beowulf cluster.
Today, I am migrating my Ubuntu VM from VMWare Player to VirtualBox.
This is dead simple with a linux client:
- Copy your VMware image to your Virtualbox VM location
- Open up VirtualBox and go File->Virtual Media Manager
- Add the .vmdk file as a hard disk in the Virtual Media Manager
- Create a new VM, using the hard disk you copied as the disk.
That's it! Could it be simplier?
For Windows, things are a bit more difficult. See this link for more details.
String matching with C++ PCRE
bool regex_match( const char *pattern, const std::string str, std::vector *substrings )
{
const char *err;
int erroffset = 0;
pcre *re = pcre_compile( pattern, 0, &err, &erroffset, NULL );
int ovector[90];
size_t rc;
if ( !re )
{
bug( "%s: regular expression compilation failed at: %d: %s", __FUNCTION__, erroffset, err );
return false;
}
if ( ( rc = pcre_exec(re, NULL, str.c_str(), str.length(), 0, 0, ovector, 90 ) ) < 0 )
switch( rc )
{
case PCRE_ERROR_NOMATCH: return false;
default: bug( "%s: Matching error: %d", __FUNCTION__, rc ); return false;
}
if ( substrings )
for ( size_t i = 0; i < rc; i++ )
substrings->push_back( str.substr( ovector[2*i], ovector[2*i+1] - ovector[2*i] ) );
return true;
}
bool simple_match( const char *pattern, const char *str )
{
std::string newPattern = "^";
for ( size_t i = 0; i < strlen(pattern); i++ )
{
if ( !isalnum( pattern[i] ) && !iscntrl(pattern[i]) )
{
if ( pattern[i] == '*' )
{
newPattern += ".*";
continue;
}
else
newPattern += '\\';
}
newPattern += pattern[i];
}
newPattern += "$";
return regex_match( newPattern.c_str(), str, NULL );
}
no such file to load — mkmf (LoadError)
Ever get this error when installing a gem?
/usr/bin/ruby1.9 extconf.rb install mysql
extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:10:in `'
It happens when you don't have the development library installed. Easy enough to fix, just install ruby1.9-dev.
For ubuntu:
sudo apt-get install libruby1.9
