Thursday 4 December 2008

mysql database copy

problem: its always good to have a dev version of any working database for learning purposes...

what im not doing: going all 'gui'... the command line rox and it all starts there


this is surprisingly difficult with my set-up. xampplite setup on a xppro box (its my work setup, dont judge me)! in the end i had to do the following;

create database test;

then export my production database to file via phpMyAdmin, .sql

then i seemed to hit a brick wall. found posts that advised adding 'use test;' at the top of the file then issuing the following command;

mysql < c:/backup.sql;

wouldnt work. tried;

mysql -u root -p ***** < c:/backup.sql;

no good :(

but then, almost as a last gasp;

use test;
source c:/backup.sql;

job done! always remember '\' escapes in mysql so windows absolute paths are initially annoying!

Friday 21 November 2008

flac to mp3

problem: downloaded 'king of leon - because of the times', and all in flac format

what im not doing: just leaving it, got a cheapo mp3 player that doesnt support flac (i know flac is lossless and so much better, but needs must). im also installing nothing with a gui, not needed!


installed on ubuntu, flac & lame

sudo apt-get install lame flac

get into the terminal and navigate to dir with files for convertion. a wee for loop should sort it out

for i in *.flac; do $(flac -dc "$i" | lame -h "$i.mp3"); done;

point - could have stuck in a bit of magic to chop off .flac from resulting mp3 (something.flac.mp3) but no curly braces on wee boys keyboard!

outlook express opening s-l-o-w-l-y

problem: outlook express taking 14 fortnights to open

what im not doing: just installing 'live mail' (although it is slightly better...)


seems that a dodgy autopatcher run has resulted in the above behaviour, but fairly straightforward to repair. logs show dcom error for

FB7199AB-79BF-11d2-8D94-0000F875C541

so a wee search in the registry takes me to

HKEY_CLASSES_ROOT\CLSID\{FB7199AB-79BF-11d2-8D94-0000F875C541}

InProcServer32
LocalServer32

default value seems to be path to messenger. remove this to blank entry and we are back to normal!

Thursday 18 September 2008

recursive for loops

problem: for example, reading a text file input, searching for the entry in a database and outputting specified csv's

what im not doing: hitting this with vbs, because vbs is only for when batch cant do it


try it, recursive for loops arent supported in winxp cmd / batch files, but here is a wee workaround

for /f %%a in (list.csv) do call :list %%a
:list
if not %1'==' for /f "tokens=1-5* delims=," %%a in ('findstr /i %1 db') do echo %%~c,%%~d,%%~e >> summary.csv

save the batch and watch it recurse!

winxp sucks again

slightly different post here, but ive not really been on for a while, but got to highlight this!

got
this message and here is the proof


now, you will notice that all of the google results feature either vista or enhanced ie7 issues, generally with network shares, but i got this when trying to extract a file from a compressed archive within another compressed archive, a zip within a zip if you will. now, i know that it was poor practice but that is how the file arrived.

also, do you want to move or copy files from this zone, yes / no? move or copy? yes or no? this is almost nonsensical to me...

Friday 20 June 2008

update local website with live info

problem: customers stock system doesnt play nice with web, so stock levels and prices are manually updated each morning. local copy of website on sales laptops information can be out by two weeks!

what im not doing: calling in sales reps every day to get up-to-date info


so, vbs to the rescue again. as this is a text file, read into an array by php live it is uploaded using ftp binary type to preserve carriage returns. downloading via ascii should preserve this file characteristic.

on error resume next
url = "onlinepathhere"
path = "localpathhere"
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "GET", url, False
xmlhttp.send()
if xmlhttp.Status = 200 then 'if status is anything other than 200 it is not ready
Set fstemp = CreateObject("Scripting.FileSystemObject")
fstemp.GetFile(path + "pricelist.bak").Delete 'on error statement ensure script carries on if file doesnt exist
fstemp.MoveFile path + "pricelist.dat", path + "pricelist.bak"
Set filetemp = fstemp.CreateTextFile(path + "pricelist", true)
filetemp.write (xmlhttp.responseText)
filetemp.close
else
msgbox "please ensure that you are connected to the internet to update stock figures" + vbcrlf + vbcrlf + "if you are connected please try again later"
end if
wscript.quit()

Wednesday 18 June 2008

winxp wmi / wbem problems (for no good reason!)

problem: tasklist wont run (dialogue framedyn.dll not found) and the following error in event viewer

The Windows Security Center Service was unable to establish event queries with WMI to monitor third party AntiVirus and Firewall.

what im not doing: an 'inplace reinstall' [edit: i maybe am!]



step 1 - copy framedyn.dll from %windir%\system32\dllcache to %windir%\system32\wbem (as admin)... tasklist runs, but logging out & back in takes us back to problem!

step 2 - run rundll32 wbemupgd, UpgradeRepository to diagnose and repair wmi... wbemupdg module not found... no good!

step 3 - run rundll32.exe setupapi,InstallHinfSection WBEM 132 %windir%\inf\wbemoc.inf, insert winxppro cd then restart... now i have additional warnings along with initial problem!

A provider, HiPerfCooker_v1, has been registered in the WMI namespace, Root\WMI, to use the LocalSystem account. This account is privileged and the provider may cause a security violation if it does not correctly impersonate user requests.

A provider, CmdTriggerConsumer, has been registered in the WMI namespace, Root\cimv2, to use the LocalSystem account. This account is privileged and the provider may cause a security violation if it does not correctly impersonate user requests.

A provider, Rsop Planning Mode Provider, has been registered in the WMI namespace, root\RSOP, but did not specify the HostingModel property. This provider will be run using the LocalSystem account. This account is privileged and the provider may cause a security violation if it does not correctly impersonate user requests. Ensure that provider has been reviewed for security behavior and update the HostingModel property of the provider registration to an account with the least privileges possible for the required functionality.

may have to come back to this one...

Friday 6 June 2008

remote remote desktop

problem: forgot to enable rdp on domain workstation

what im not doing: driving all the way there to tick a box!


easy, connect to remote registry, navigate to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server

change

fDenyTSConnections

to

0

Wednesday 14 May 2008

windows nt command line enable / disable accounts

problem: enabling temp admin account for app specific use (yes, sage again!)

what im not doing: going through the server management console just for this


pretty simple from the command line, but difficult to find and documentation on it

net user tempaccount /active:[yes|no]

picked up that there is also a /time switch for enabling only during certain times, but dont need this just now

Monday 12 May 2008

ubuntu desktop enviroment summary

problem: keep forgetting this stuff

what im not doing: raking through forums every time i need reference


ubuntu (gnome desktop enviroment)
login manager: gdm
window manager: metacity
file manager: nautilus

kubuntu (kde desktop enviroment)
login manager: kdm
window manager: kwin
file manager: konqueror

xubuntu
login manager: xdm
window manager: xfce(4)
file manager: thunar

can all be mixed / matched / added / removed, but this is the default setup

Thursday 1 May 2008

xp show / hide login

problem: a friend and his family have just got their pc back from re-installation and wish to have everyones login reduced to limited user

what im not doing: disabling the graphical login screen


this instance applies specifically to xphome, but can translate to pro dependent on its applied use. as you no doubt know, winxp home requires at least one user account with admin rights in addition to the existing administrator account, which can only log on in safe mode. the idea is to setup an account with admin rights, hide it from the graphical logon screen and leave all additional users as 'limited users'. this situation isnt really scalable as adding any additional users and basic admin right dependent tasks cannot be performed from user only accounts, but my friend was ok with this.

so, create your user scheme then, as a member of admin navigate to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList

create a dword named the account name that you wish to hide, and assign the hex value '0'. if you need to log in under this account, 'ctrl-alt-del' x2 at the glogin screen and enter your credentials. easy!

Tuesday 1 April 2008

bluetooth phone (samsung) to laptop (ubuntu 6.06 lts)

problem: installing strange, unstable drivers for cheap, bluetooth dongle on windows, but phone getting full.

what im not doing: installing strange, unstable drivers for cheap, bluetooth dongle on windows


stick in the dongle, lsusb;

Bus 001 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

then dmesg to check if kernel modules are present and loading;

[17179599.760000] Bluetooth: HCI device and connection manager initialized
[17179599.760000] Bluetooth: HCI socket layer initialized
[17179599.816000] Bluetooth: HCI USB driver ver 2.9
[17179599.816000] usbcore: registered new driver hci_usb

the above makes me happy! so, to the terminal;

sudo gedit /etc/rc.local

and add to the bottom;

hciconfig hci0 inqmode 0 (not sure if this is required but google told me, restart the machine)

hcitool scan gives me the phones mac and all seems good to go! pair from the phone (1234 by default) and i thought i was there! unfortunately i couldnt find 'applications > accessories > bluetooth file sharing', so a quick;

sudo apt-get install gnome-bluetooth

start it up and send to the home folder. class, linux does it again!

Wednesday 12 March 2008

more batch goodness!

problem: app generated csv encases entries with double quotes, we want the double quotes removed... please!

what im not doing: using wsh (the client googled and suggested that i use vbs, looking nervous as they obviously didnt know what this meant).

start at the start, batch as always (i hate myself);

for /f "tokens=1* delims=," %a in (foo.sv) do echo %~a,%~b >> bar.csv

kinda easy!

Tuesday 4 March 2008

winxppro startup issue (panic panic panic)

problem: client pc starts-up to desktop (almost) and displays 'services.exe unable to start, some dll missing, blah, blah, reinstall, etc' inciting real panic and confusion... restarting the machine boots to blue screen (for a second) then restarts (as is the default setting). talk of a brand new pc ensues as i stroll into the office...

what im not doing: agreeing with a new purchase and blagging the pc, i mean i have a soul (and i think its still under warranty, so i would be filling in forms and making calls... no) also, stating the obvious, this isnt a trick or anything new, im just tracking problems and fixes.


boot of xppro cd, enter recovery console and enter the mighty;

chkdsk c: /r

and restart. job done.


thoughts - my linux distro of choice runs a similar tool every 30 mounts, winxppro would benefit from such pragmatic steps.

Monday 3 March 2008

batch magic!

problem: client has a generated csv of months credit notes issued, each item credited should be (but sometimes not due to human error) flagged as damaged, quality issue, shortage, not-as-ordered or error (*d*, *q*, *s*, *nao*, *e*). a summary of each catergory should be generated for that month. during the brief i offered a futher category of 'misc' for items not flagged and was hailed as the hero i am (for a short while).

what im not doing: playing football tonight probably... it has snowed!

batch solves the above, toffee!

setlocal enabledelayedexpansion
copy foo.csv cred.csv
set foo=foo
for %%a in (d,q,nao,s,e) do (
type !foo!.csv find /i "*%%a*" >> %%a.csv
type !foo!.csv find /i /v "*%%a*" >> "%%a%%a.csv"
del !foo!.csv
set foo=%%a%%a
)
rename ee.csv misc.csv

notes on the 'cdrill.bat'
name the initial file 'foo.csv'
need setlocal or the variable expands to 'e' instantly
piping output of type for tidyness (no ----- blah.csv at head of file as when 'find' is used), pipe doesnt seem to show up in post

Friday 29 February 2008

Ubuntu screen resolution issues - cannot get 1024x768

After installin Xubuntu onto my old IBM thinkpad 600, I was restricted to 800x600 resolution.

What I'm not doing:
Phoning Robin! (just yet)

I checked out the config file for all hardware on the sytem. this file is located in /etc/x11/xorg.conf

Im checking 2 things. First that under 'modes' for the screen section of the file that 1024x768 is listed. This should look something like this:

Section "Screen"
Identifier "Default Screen"
Device "Neomagic Corporation NM2160 [MagicGraph 128XD]"
Monitor "Generic Monitor"
DefaultDepth 16
SubSection "Display"
Modes "1024x768"
EndSubSection
EndSection

The next thing your checking is that the DefaultDepth is 16 (probably 24 as default). This needs to be changed to 16bit to enable the higher res.

Save your changes and reboot. Problem solved!

BT Voyager 1060 Wireless PCMCIA Card on Ubuntu

This will probably work on most/all models of systems. Im using an IBM Thinkpad 600 in this example.

After converting from the dark side to my first release of Linux, namely Xubuntu 7.10, my first problem was installing the wireless card named above.

The Linux kernel version 2.6.22 included in Ubuntu 7.10 uses the bcm43xx driver for Broadcom wireless cards.

The firmware code is still not distributed with Ubuntu and must be downloaded and extracted before bcm43xx will work.

2 files are required in order for the network card to work. These are:

installation file - bcm43xx-fwcutter, which can be found here:
http://archive.ubuntu.com/ubuntu/pool/universe/b/bcm43xx-fwcutter/bcm43xx-fwcutter_006-3_i386.deb


and the firmware, which can be found here:
http://downloads.openwrt.org/sources/wl_apsta-3.130.20.0.o


Once you have the files onto the machine in question, double click on 'bcm43xx-fwcutter' to start the package installer. During installation it will ask you if you would like it to fetch and extract the firmware. This step will fail without an Internet connection so just click 'forward' and then close the the package installer.

Open Applications>System>Restricted Drivers Manager and you will see under the firmware drop down arrow it says Firmware for Broadcom 43xx chipset famiy and under Status it says not in use. Tick the enable the firmware box.

Click enable firmware.

Select use local file and browse to the wl_apsta-3.130.20.0.o firmware file that you downloaded previously anc click open. Click OK to extract the firmware.

If the status has changed to In Use then you are successful.

You can now go into Network Connection and connect to your network.

Hyperlinks on an Excel Userform

Got a problems & Solutions database created in Excel for Standard Life's internal websites. The dasebase is mostly fronted by a userform GUI. Here you can search for a problem, and once a problem is selected a solution is suggested in a textbox underneath.

Problem:

sometimes the solution offered suggests the user to seek more information from a website. For easy use I want a control box to appear when this is the case that the user can click on and it will take you to the website suggested. However I do not want the control box to be visible unless there is a website as part of the solution.

What I'm not doing:

Creating a separate control box for every solution that offers a website for further info.

Solution:

First, I created a control box with the default visible value to false.

Then, I added the following code to the click event of the problem selection box:



Private Sub txtsol_Change()
If Left(txtdetsol, 4) = "http" Then
cmdgo.Visible = True
Else
cmdgo.Visible = False

End If
End Sub




Then added the following code to the contrl box that will take the user to the website:



Private Sub cmdgo_Click()

Dim sTxt As String
Dim x As Variant
txtbox = Me.txtdetsol.Value
x = Split(txtbox, " ")

ThisWorkbook.FollowHyperlink x(0)

End Sub




What this code effectively does is this:-
everytime a problem is selected and the solution appears, the code looks at the solution and says 'if the first 4 letters of this solutoin is "http" then show the link control box'.
The code behind the link control then splits all the text before the first space in the solutions box and creates this text as the hyperlink.

The only downside being that this only works when the web address is the first thing written in the solution. However this is a compromise that will still save alot of time.

Hopefully can further this improvement so that this will happen no matter where the link appears in the solution, whether it be the start, middle or end of a string.

Watch this space...

sage line50 (and all sage products) suck c8ck!

problem: performance problems with sage line50 v11.01.035 (last version before the 2007 release, which we are NOT upgrading to until there is no other choice).

what i am not doing: calling sage, i have tried this before and THEY DONT KNOW... ANYTHING... EVER!


after a recent hardware and network upgrade (all machines hp p4 3ghz, half gb ram, 1gb managed switch) i was hoping the occasional data transfer pauses and slow reporting would dissipate. not so! even scrolling through the admittedly large product db causes stuttering. the helpdesks last offering was that we had an 'unusually large dataset', but im not buying this! so, i will start with two machines (test and server) and see what i can do. im not going into the specifics of this network (no of hosts, whatnot) as generally the network is fairly quiet. ok, ok, i know that the server shouldnt really be used as a desktop, but it is, and does the bulk of the sage work, the other machines occasionally searching products or invoices. so, some figures (just using taskmanager monitors):

steps i have taken to no avail: ensured that the server shared folder is mapped on the test client (to eliminate any unc queries or hostname resolution) and that the mapped address is entered in the 'company' file in the sage program folder, disabled firewalls between test client and server, and sage.ini tweak (enter or change 'Files=100' in the [SG50] section).

general use

server
ram: 240mb available (os and sage running, occasional pop checks)
cpu: 1-15% load, with occasional 25-30% during big saves, but only touching then dropping to zero
network: never over 0.5 %

test
generally the same

test scenario
scroll product list top to bottom, restarting sage each time on test client

server
cpu: 1-5%
network: spikes almost 2.5% coinciding with test client screen stutters

test
cpu: 1-10%
network: spikes 1-2% coinciding with screen stutters

WHY THE STUTTER?

test scenario
scroll product list bottom to top, restarting sage each time on test client

server
cpu: 4-10% (never dropping back to zero during scroll)
network: steady 1%

test
cpu: 15-30% (one 33% spike and slight stutter)
network: steady 2%


WHY NO STUTTER?

can only assume that it is something to do with file caching or something (the fastest cache of info ever, <.5 sec to cache whole db).

im not satisfied with this and will continue to try to improve user experience, but in the meantime will scroll bottom to top and curse sage daily.

Thursday 28 February 2008

s l o w remote desktop

problem: 5-6 sec delay when rdp'ing into domain clients, even on 256 colour setting. big, branded bitmap rendering during logon before user settings kick in and remove background image.

what im not doing: being unreasonable... i mean its normally just in and out, and depending on isp, can take up to a few minutes.


easy reg fix! the key is:

HKEY_USERS\.DEFAULT\Control Panel\Desktop\Wallpaper

and the value (string) just a path to a local file. Unbranded machines value is (none).

Wednesday 27 February 2008

the wee boys edubuntu usplash

problem: when the wee boys edubuntu box starts up, im getting 'cannot display this video mode' when i should be seeing usplash. the live cd displayed nice graphical usplash, but after install, black screen, white font. without getting out this seat (and im listening to the football) hes got an nvidia chipset graphics card and a dell 15" flatscreen monitor of some kind.

what im not doing: risking the install... the wee boy loves his classic arcade games (mame) and his box is now a mythtv backend when he is at his mums (more about this another day). i dont really want to reinstall...


google helps (as always) and first stop is checking the usplash config file:

less /etc/usplash.conf

this reads:

# Usplash configuration file
xres=1280
yres=1024

doesnt match current config (1024x768), so sudo gedit and altered usplash config file. then, the magic:

sudo initramfs-update -u

and sweat for a few seconds... reading lets me understand that as of 2.6 kernels, some initialisation can be shifted from the kernel to userspace, and loaded before initrd's. more reading https://wiki.ubuntu.com/Initramfs

which image?

problem: i have been supplied a cd containing images of products (404 images) and need to copy images matching keywords for further processing.

what i am not doing: clicking through this cd via explorer for 4 hours


normally these images are supplied named by supplier code but this particular one has a brief description as image names. keywords are;

Gleneagles
Edinburgh
Newbury
York
New York
Homestead
Sunset
Devon

now, im not using xcopy as i dont really want a copy of the dir structure (there are a few on the cd) on my target, so;

for /f "tokens=*" %a in ('dir /s /b *glen*.jpg,*edin*.jpg,*bury*.jpg,*york*.jpg,*home*stead*.jpg,*sun*set*.jpg,*devon*.jpg') do copy "%a" "%userprofile%\desktop\%~na.jpg"

and i am down to 79 images, all of which are relevant to this project.