Wednesday, December 14, 2011

Generic USB Driver Windows 7

If you are having issues with finding a driver for a USB Drive, here's a trick.

Go to C:\Windows\System32\DriverStore\FileRepository\usbstor.inf_

and get the latest directory, copy the contents to 

C:\Windows\Inf

Reinsert your USB stick, it should detect it now and install it.


Monday, October 31, 2011

dotless Configuration Options

Unless my googling is failing me, I can't find any documentation on the dotless configuration for Web.Config, so I've gone through the code, I think I understand the different options
  • minifyCss
    • true or false
    • Minifies the CSS output
  • cache
    • true or false
    • Caches the CSS after being created
  • web
    • true or false
    • if true, this uses http specifc options,  must be set when using on the web,  Response.Cache, Request.QueryString for parameters, Server.MapPath for mapping, puts the Log Messages in the Response
    • if false, uses in memory cache, uses console logger,  uses paramaters from the console, 
  • log
    • info, debug, warn, error, default
  • optimization
      • 0-n
      • Optimizes the output...
  • source
    • How dotless reads the files of interface IFileReader, its the type usually FileReader but can be VirtualFileReader which uses HostingEnvironment.VirtualPathProvider
  • logger
    • Can be set but then gets overidden by the "web" boolean, there are AspNetTraceLogger (HttpContext.Trace.Write), aspResponseLogger (Response.Write as Css), ConsoleLogger (Console.Write), DiagnosticsLogger (Debug.WriteLine) and NullLogger (Swallows).

  <dotless minifyCss="false" cache="false" web="true" log="debug"
           optimization="10" 
           logger="dotless.Core.Loggers.AspNetTraceLogger" />


Thursday, September 29, 2011

Greasemonkey Script to Remove Facebook in Facebook plus more

Here's a simple script to remove the right hand column on Facebook, which has Facebook-in-Facebook, adverts and crap, also Greasemonkey is easy.

// ==UserScript==
// @name           Remove Facebook Right Column
// @namespace      http://sarkies.blogspot.com
// @description    Remove all the pointeless stuff in the right column, the ad's, the facebook-in-facebook, and duplicated events
// @include        http://*.facebook.com/*
// @include        https://*.facebook.com/*
// ==/UserScript==

var rightColumn = document.getElementById('rightCol');

if(rightColumn) {
 rightColumn.parentNode.removeChild(rightColumn);
}
Download

Download the script or copy and save it as rightCol.user.js and drag and drop it in to Chrome and/or Firefox (if you have Greasemonkey enabled) go to Facebook. Rejoice.

Friday, July 08, 2011

Duke Nukem Forever Stutter work-a-round

When playing the game on my PC, it was stuttering like hell, thought it was to-do with not being optimized, since I have a dual screen, I ran task manager in the other monitor. This showed Steam.exe was using 30% of my CPU regardless.

The work-a-round I propose till its fixed will mean no Achievements whilst playing, so its up to you!

Right click Duke Nukem Forever, turn off "Enable Steam Community In Game"

Run the game

Alt-Tab out of the game

Set Steam.exe affinity to one core and set its priority to low via Task Manager.

Kill GameOverLayUI.exe if its running

Play the game and if its still stuttering set DukeNukemForever.exe to the other affinity.


Tuesday, May 24, 2011

Getting Hexxeh's Chromium Builds Network working

If you're trying to get ChromiumOS working on Virtual box, you'll need these network settings.
It took me a while, since its the last in the list!!

Bridge Adapter

Adapter Type: Paravirtualized Network (virtio-net)


Should give you Ethernet in the login screen now?

Its a bit slow for me though....


Friday, January 07, 2011

Sys is undefined error

Having tried every single way of fixing this error, I came across and two part fix.


Add that to your Web.Config

and

Disable and Renable,

Use HTTP 1.1
Use HTTP 1.1 through proxy connections

In your Internet Explorer Options.




Tuesday, November 30, 2010

Western Union Scam! Another one.

Firslty, the scam.

"Don't send me money, just send it someone else, friend or family and show me proof you can afford to buy the product / rent the room etc, show me proof using a photocopy of the receipt"

How the scam works?

Western Union, don't need any proof of you or the recipient to take the money, ridiculous if you ask me!

Secondly, a list of scammers I'm picking up along the way, I'll be adding to it:

anzy84@hotmail.com / Anzia Scott

timmsproperty@gmail.com / Sherwood Tim

amoo9989@hotmail.com / Amoo Raymond

aidataube@yahoo.de / Aida Taube

Phone numbers

070 2404 4128
07045 766243
07045 734145

conta
ct you, they are scammers. The more people who can the address, the better.


If in doubt, never use Western Union and use TinEye.com for reverse picture search.


Wednesday, October 06, 2010

Can't download Chrome behind a Corporate Network?

There seems to be an issue with the Chrome installers:

ChromeSetup.exe
and
ChromeStandaloneSetup.exe

The only one I found to work was the ones from FileHippo:

There was a way to download straight from Google but it doesn't seem to work anymore, unless I'm doing it wrong.

The filename should be

chrome_installer.exe


Friday, July 30, 2010

HTC Desire SPP 2.1 Issues

If you have an HTC Desire and you are having issues with your Bluetooth code, such as:


  • Service Discovery doesn't work or flaky
  • Can't see Misc devices, i.e. those with a Bluetooth device type of Headset, Phone or Comp
  • If you have issues communicating via SPP (Serial Port Profile)
  • Just plain not working
You will need to upgrade the ROM on the phone, these may all be fixed with HTC Desire 2.2 update which out "today", but if not its the bluez bluetooth code that has been fixed.

The only ROM that fully supports all of this is the http://www.cyanogenmod.com/ ROM, I've tried all ROMS this one is the only one that works correctly, but its based on the Nexus One ROM, so you won't have Sense, but if someone updates the ROMs with the latest BlueZ stuff, it *should* work.

OpenSource ftw?

I had similar issues when developing for a J2ME app on my old K800i, but what could I do?

Finding Bluetooth Service Address on Windows

If you have connected to a device, but want to write code to discover it, you need to know the service address/guid of the bluetooth device, in order to talk to it.

On Windows if you navigate to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\BTHENUM\

You will see the devices connected and then in HardwareID you will see the value at the end for SPP it is usually.


BTHENUM\{00001101-0000-1000-8000-00805f9b34fb}

Wednesday, July 14, 2010

Could not create the driver from NHibernate.Driver.SqlServerCeDriver

Using Fluent NHibernate and MsSqlCeConfiguration, I wanted to use an SQL Compact DB for my Database by changing the FluentConfiguration but I started getting the errors from the InnerException.

"Could not create the driver from NHibernate.Driver.SqlServerCeDriver"

The fix is simples,

You need to add a reference to

"System.Data.SqlServerCe"

Located in

"C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll"

If you don't have it, you'll need to install it from.

http://www.microsoft.com/sqlserver/2005/en/us/compact-downloads.aspx

Once you've added it you need to set the

"Copy Local" to true.

Then you should be good to go.

Wednesday, July 07, 2010

Failed object initialization (ISupportInitialize.EndInit). Error on Windows XP


Failed object initialization (ISupportInitialize.EndInit). Method not found: 'System.Windows.Threading.DispatcherOperation System.Windows.Threading.Dispatcher.BeginInvoke(System.Delegate, System.Object[])'


If you get this error, looking at the MSDN page for the method call

http://msdn.microsoft.com/en-us/library/cc190824(VS.90).aspx

It says at the bottom:

Version Information
.NET Framework
Supported in: 3.5 SP1, 3.0 SP2


The computer was running 3.5 vanilla, install the update and you'll be good to go.

Sunday, June 20, 2010

Bit of Hex Education

So I've started my Virtua Tennis Savegame editor, so in order to follow, I need to teach you about hex. So firstly, the easy stuff.

If you want to get properly confused, go to the Wiki Page but here's a nicer one:

http://www.itnewb.com/v/Introduction-to-Hexadecimal-or-Base-16-Number-System

Hex is base 16, i.e. numbers go from 1-16, we usually deal with base 10, (since that's the number of fingers we have), but hex is from 0 to 15, inclusive, so we get our 16.

Also instead of having 10 to 15, we have A-F, (aside, why A-F, why not A-Z and we get even more numbers?).

So therefore, lets take 29 in denary

Binary = 11101

Hex = 1D

So easier to store and easier to read, if that was just denary, the most we could store is 100 values from 00-99, in hex, we can store 00-FF which is 256 values.


Next thing to know is Endianness, so Big endian and Little Endian and Most Significant and Least Significant bit.

In a big endian systems, the most significant bit is the furthest to the right, go back to our 29 in binary.

16 8 4 2 1
1 1 1 0 1

So in this instance, the most significant bit is the bit in the 16's column and least significant bit is the 1's column. This is how everyone learns binary.

The Virtua Tennis Savegame is stored in LSB, so therefore in this case it'd be.

1 2 4 8 16
1 0 1 1 1

So once we figure out the values, you'll need to swap the values backwards in order to make the change, but since we are doing it in hex it'll be like this.

Hex = 0A 01

Big Endian = 0A 01 = 2561
Little Endian = 01 0A = 266

The reason I think it's stored in Little Endian is because the PC Port, was just emulated, from the Dreamcast version which runs in Little Endian.

http://www.netbsd.org/ports/dreamcast/faq.html#endian

So there's my Hex Education, I'm sure I'm missing stuff. This is just a tasty for when we start hacking the file.

Saturday, June 19, 2010

Fixing N95 8GB keypad and save yourself money!

Problem: My N95 8GB keypad stopped working and just broke into pieces, cost for some one to fix it, £30-£40.

I'm a cheap bloke, so I decided to fix it, this is how I did it!

Firstly, I looked for a new case this is called "housing", so ebay time.


Ebay search for N95 8GB


It took about 3 weeks for the delivery and it was about £3.50 and from Hong Kong! (How do they make money?) I bought a White one to make it look sexy.

It should come with the Torx 4/5/6 tools, for you to dismantle your phone, i.e. the for the screws that look like stars.

This is probably the best video

http://www.youtube.com/watch?v=jc33lBQzVy8

I just did it myself, I then found I needed to get a new membrane for £8

Ebay search for N95 8GB Membrane

I then replaced it, so for under £15 I managed to fix my keypad, get a new case and learn how my phone goes together.

This post is shorter but it took me a while to find what I needed and get replacements and keep my phone working till I get my HTC Desire!!

Wednesday, June 16, 2010

Getting HTC Desire working with ADB

Got an HTC Desire, I tried installing the Drivers with the Android SDK, it wouldn't work, I first had to enable USB Debugging.


Settings -> Applications -> Development -> USB Debugging


Plugging it in, it wanted to install ADB (Android Debug Bridge)I first tried updating the .inf file


;HTC Desire
%SingleAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C87
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C87&MI_01



This made it install. Yay!
But, running adb devices in the tools folder of the SDK showed it wasn't working.

I then looked on HTC Site for Drivers and found the HTC Sync here:http://www.htc.com/www/support.aspx



Downloaded installed it and then removed the Device and added it again.
adb devices then showed it and Eclipse then saw it.
Yay!


Friday, June 04, 2010

Bitmap Serialize

So I've been tasked to fix a database full of pictures that weren't displayed, no matter what I tried, the Image (Stored as a byte array) was always invalid.

So I thought I'll save the file and see if I can get an image fixer on it, I just used a FileStream opened it and wrote to it


var fileStream = new FileStream("output.dat", System.IO.FileMode.Create);
fileStream.Write(bytes, 0, bytes.Length);
fileStream.Close();


Upon opening the file, I was expected to see something beginning with "Exif" or "JPG" or something, but what I saw was even better.


System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


A, ha!! The actual Bitmap object was being saved, not the actual Image, therefore I put together a bit of code to get me the Image and put it back as the Image for my code to work correctly. In this case, I could fix it, but if I couldn't I'd have to have a bit of a legacy converter for it.



public static Bitmap BitmapObjectToBitmap(byte[] data)
{
using (var ms = new MemoryStream(data))
{
var bf = new BinaryFormatter();
Bitmap bitmap = (Bitmap)bf.Deserialize(ms);
return bitmap;
}
}


Then the working code for the Image to Byte Array



public static byte[] ImageToByteArray(Image image, ImageFormat format)
{
using (var ms = new MemoryStream())
{

var bm = new Bitmap(image);
bm.Save(ms, format);
return ms.ToArray();

}
}



Comments welcome!!

Transfer Data between two SQL Server's

Everyone probably knows this, but hey ho.

I needed some data from one of my tables in one server to be inserted into another, here is the simplez SQL to do it.




insert into Server1.Database.dbo.Table(Col1,Col2,Col3)
select Col1,Col2,Col3
from Server2.Database.dbo.Table



Edit:
thanks to @duncansmart just a bit more info, I'm running on 2008 R2, on previous systems you may need to run


Execute sp_addlinkedserver Server1


To link in the other Server

Monday, May 24, 2010

Facebook Privacy Checks

Here is a list of Facebook Privacy scanners I've found.

1.) Save Face by Untangle is an automated script that will go through your settings and disable them.

http://www3.untangle.com/saveface

All you have to do is drag it on to your Bookmark toolbar for later.

2.) Reclaim Privacy, which is a scanner which gives you a breakdown on which settings / info you are leaking to the internet, as 1.) you just need to drag the bookmark on to your bookmarks toolbar.

http://www.reclaimprivacy.org/

Now you should log in to Facebook and click number 1, it will automatically go through your settings. (Easier to turn on Info then turn it off in my books)

Now click number 2, then update any settings it tells you to. Some I leave public, such as "find me via search" and "send me a message" set to everyone.

Now once you've done that we have another link to click.

3.) Profile Watch, this will scan your profile as an external person could and will show you info you are still showing the world.

http://www.profilewatch.org

4.) Honourable mention is an Application, so this shows you what your Apps can see about you and send to people.

Privacy Check

http://www.rabidgremlin.com/fbprivacy/




Hopefully this helps everyone!

Wednesday, May 19, 2010

InvalidateRequerySuggested on GUI Thread

I've been having issues where buttons weren't getting enabled on my WPF application, only by clicking the form would they work.

I found that I need to force the refresh using CommandManager.InvalidateRequerySuggested but that didn't work, the reason being I wasn't on the GUI Thread, I was on another thread, so here is my little helper class to do it.


public static void RaiseInvalidateRequerySuggested()
{
Dispatcher dispatcher = null;

if (Application.Current != null)
{
dispatcher = Application.Current.Dispatcher;
}

if (dispatcher != null && !dispatcher.CheckAccess())
{
dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)CommandManager.InvalidateRequerySuggested);
}
}



This tries to get the application, then gets the dispatcher for the application, makes sure you have access, and then dispatches the Invalidate to that thread.

bingo.

Tuesday, May 18, 2010

Dieting for Programmer

Right,

I've decided to do a post on dieting, not exactly technical but very much of the, "Healthy body, Healthy mind" manta, so my history, I used to be nearly 16 stone so I'm not from the "always been thin, eat what you like" bunch of twats most diet people are.

So here is my diet plan / life plan thing.

Firstly, we need to work out our BMR (Basal Metabolic Rate) basically the amount of calories you'd burn by sitting still all day.

http://www.bmi-calculator.net/bmr-calculator/

So I'm going to take me as an example, I'd probably over weight currently due to being on a bulk, long story my figures.

Age: 24
Weight : 13 stone, 1 pounds
Height: 6 foot, 2 inches.

(Hint: 14 pounds in a stone for all you cool metric kids)

( 13 * 14) + 1 = 169 lbs

my BMR = 1895.47

Now we use Harris Benedict Equation to work out our calories

http://www.bmi-calculator.net/bmr-calculator/harris-benedict-equation/

Since we're programmers, * 1.2

My calories for a day should be 2274.564

Now, in order to lose weight, we need to create a deficit, so the recommended number I feel is 500 calories, anything more, your body thinks its being starved and will hold onto your fat and not let go. It think its in a field starving and needs to keep you warm till you find an animal to eat.


So our Dave's Daily Diet Allowance is.... 1774.564(we're going to round it up for ease of use.) 1800 calories.

Now if you get any good food you'll see your RDA (recommended daily allowance) of what to eat, the average man is 2500 calories and each woman is 2000 calories. so if I stuck to it, I'd be putting weight on if I sat around doing nothing all day.

Type Male Female
Calories 2500 2000
Protein 55g 45g
Carbs 300g 230g
Of those carbs sugar 120g 90g
Fat 95g 70g
of that fat, Saturate 30g 20g
Fibre 24g 24g


So here are your RDA off the side off a Cornflakes packet! :), so here we have our aim, since you are probably eating more than your need you need to try and curb a little bit off this list too. So just try and keep within your boundaries and just count calories for now.

Time for the diet. I know from before we have 1800 calories to play with over the course of the day, time to split it, you should refine this to how you live, but you always must eat something at the times



  • Breakfast - 8am - 500 calories

  • Snack - 11am - 100 calories

  • Lunch - 1pm - 400 calories

  • Snack - 4pm - 100 calories

  • Dinner - 7pm - 600 calories

  • Snack - 11pm - 100 calories



Now that is my breakdown for my calories, I've give myself the most calories for my main meals, your main meal of the day is your breakfast. Skipping this is the worst mistake for your diet, it starts your metabolism kicks it into gear!

Now a sample diet


  • Porridge - Main stay of dieters, keeps you full for longer, since its a complex carb (takes a while to breakdown, simple carbs is sugar which takes minutes rather than hours

  • Apple + Skips

  • Chicken Salad with lots of trimmings or Soup and bread or jacket potato

  • Handful of nuts, Almonds are meant to be the best, full of protein

  • Lamb chop and lots of vegs and mash

  • Cottage Cheese and ryhvitta, cottage cheese is a slow releasing protein, so makes your metabolism work while you sleep





So that's a sample day, now all you have to do is tailor the diet to your calories, the foods you like and your lifestyle.

Keep a food diary for a week See how many calories and such you are eating, doesn't have to be 100% accurate, but gives you an idea where you are eating the worse!

If you feel you are snacking and want more food, increase your calories. This diet is meant to be one you're on for the rest of your life, not a quick fad one.

You are allowed one cheat meal a week make yourself feel bad when you eat it, thinking of the calories etc! But enjoy it, know that its bad for you etc.


Regarding food things I've learnt.


  • Anything with Hydrogenerate Fat avoid like the plage, seriously.

  • Eat protein!! It fills you up and your body works harder to digest it

  • Omega 3 1000mg capsules are amazing, ASDA sells them, eat at least 5 a day

  • When hungry drink a pint of water and wait 20 minutes, then see if you are hungry

  • Any exercise is better than none, don't over do it, or you'll get pissed off and stop

  • Don't let anyone say, "you look good as you are"

  • Weightwatchers meals are pretty nice!





So that's it, any comments would be grateful and I'll update the post if I need to!

Hope I haven't rambled too much!