shadowy-refugee
shadowy-refugee
shadowy-refugee
shadowy-refugee

Simple Javascript Text Input Counter

I never really put javascript on here other than greasemonkey scripts, but here’s a little simple one that has been overcomplicated in so many places around the net.

It simply shows how many characters you have left in a text input box. (I made it with twitter in mind hence the 140 example)…
Example:


In code that all looks like:
<script type="text/javascript">
function countchar(element){
element.nextSibling.innerHTML = element.getAttribute("maxlength")-element.value.length;
}
</script>
<input onkeyup="countchar(this)" type="text" maxlength="140"/><span></span>

Just alter the red number to whatever you need for your own purposes. You can “prime” the counter with the same number by puting it between the ;<span></span> tags at the end of the input box.
btk


De-Brand Wordpress Etc.

I’ve written a small php script that allows you to search for all instances of a string recursively through a directory tree and replaces the results with another string, it can be used to debrand a wordpress in the default mode but there are certain files within a WP install that need to retain the “wordpress” so be careful and BACK UP your installation first.

Your system should have perl installed to use this. Note too that this won’t change your DB entries so any instances of the string within posts for example will remain, this will only change FILES i.e the php files that serve WP etc etc.

Simply open the extracted debrand.php file and alter the appropriate search strings then upload to your directory of choice and navigate to it.

I think this file should come with some warnings though.

  • Don’t typo the search string!
  • It’s CASE INSENSITIVE so WordPress is the same as wordpress or WoRDPReSs
  • It’s RECURSIVE so all child folders of the one you are in are affected.
  • I take no responsibility for the use of this script by inexperienced users, other than the responsibility of insisting you BACK UP your database and files before using the script.

Still interested?

Get it here (Downloaded 25 times) | Signature

btk


Sorting Files In A Directory With PHP

I’ve seen a load of scripts to do this but they all seem overly-complicated imo. In the spirit of KISS I’ve run off a simple php script to do just this. (I don’t know why there’s no built-in function in php listdir($dir,SORT_TYPE) kinda thing, but there isn’t.

So here’s my offering… (Downloaded 43 times) | Signature
Toggle Code

btk


Twossers

I’m pretty happy with how the Twossers thing has gone. I’ve opened it up to the public now as the OAuth seems to be mostly behaving itself. I’ve also implemented a way of cleaning out the database of folks who’s accounts are already suspended by twitter, I still have to do it manually but that’s OK for now.

Twossers - Logged In Thru Twitter

So if you have a twitter account, head on over and have a play around. Please especially add your own block lists to the database, it only takes a second and really helps with the numbers.

btk


Musical Beeps

Here’s another weird script I’ve done for linux & PHP.

It’s a very simple web interface for the linux “beep” program. You give it a sequence and your system beep plays the sequence.

first do a sudo apt-get install beep
then save the file to your web dir and play with it:
Get This Script(Downloaded 112 times)

If my linux machine is up you can see it in action at http://billy.thruhere.net/musicalbeep.php. Remember you won’t hear anything at that site, I will!

btk


Multi-Page Offline (x)HTML Validation

@Clarkee21 was looking for one, seems there are many online versions available and many single-page versions available but less easy to find are offline whole site validators. So I did a very simple one in PHP.

You need to install the htmlhelp validating proggie…
sudo apt-get install wdg-html-validator

Then save this as validate.php into the webserver folder you want to hit…
<?php
$path = dirname(__FILE__) ;
$dir_handle = @opendir($path) or die("Error opening $path");
echo "<h2>Validating ".getcwd()."</h2>\n";
while ($file = readdir($dir_handle)) {
if( is_dir($file) ||$file == ".." || $file == "." || $file == __FILE__ || strrchr($file,".bz2") == ".bz2" || strrchr($file,".png") == ".png" || strrchr($file,".jpg") == ".jpg" || strrchr($file,".gdf") == ".gdf" || strrchr($file,".JPG") == ".JPG" || strrchr($file,".gif") == ".gif" || strrchr($file,".exe") == ".exe") {
continue;
}
system('validate --verbose '.$file);
echo "<hr/>\n";
}
closedir($dir_handle);
echo "\n<h2>Validation Complete</h2>\n";
?>

and navigate to localhost/your/path/validate.php and see how you get on.

If my linux box is on you can see the results here (I recommend viewing source to easier read the output)

You can probably see the line where I parse out file types I don’t want checked, alter that to suit your setup. Possibly easier to just put the type(s) you DO want checked in there!

btk


PHP Redirect Script While Retaining Variables

That’s a long winded title isn’t it, but the point is this. I sometimes want to redirect different users to different pages of a site, however using a regular header() redirect meant that you weren’t passing through any $_GET variables as they came in.

So I wrote this small workaround script to forward whatever GET variables were passed in to the page from which I’m redirecting.

Get it here (Downloaded 141 times) | Signature

Seems to work like a charm. It could even be expanded to forward all $_REQUEST parameters in their appropriate format I guess but $_GETs are fine for my needs.

btk


Webgeekery

I’ve been doing some webfoolery over the past week or so. Firstly I registered and started working on the missions in HackThisSite. What a brilliant site it is, I was up to level 3(Apprentice) when they, somewhat ironically, had to restore the site to a backup because of an exploit discovery! If you are at all interested in hacking/programming/computers you should get over there and try out the basic missions for starters. I started on the programming missions which look to be pretty good too. My first program source is here for anyone interested.

Also I wanna tell you about a project I started on a few weeks ago then kinda forgot about. It’s called Twossers. In a nutshell it’s [hopefully going to be] a huge database of recognised twitter spammers/marketers etc. It’s like everyone’s block list added together. Eventually I hope to have the ability also to unfollow and block anyone on the database. At the moment it’s in the very early stages of production but you can check it out (and add your own blocks) at twossers.com

It’s been interesting developing my own take on twitters oauth system(how you can sign in to a program without giving away your passwords etc, also you can revoke access at any time, great idea) and integrating that with AJAX and SQL. Much bigger project than I’m ready for probably but hey, gotta learn somehow.

I’m also in receipt of my first Unit from my OU course, yes I’m officially, in the eloquent words of Paul Calf, a fookn student!

Happy Days!

btk


Linux File Shredder

Here’s a bash script that does exactly what it says on the box.

the key line is

shred -uz *.*

which tells linux to remove all files that have extensions from the folder from which you are running the command. It overwrites the files 26 times with jargon, then recursively renames the files with decreasing numbers of zeros to leave them un-get-backable!

So get the script, make it executable, put it in the folder you want to cleanse and run it!

Get it here (Downloaded 139 times) | Signature

Toggle Code

btk


Quick Note

My Linux based PC is currently in storage. This means that the iTeddy video converters are currently offline for the foreseeable future.

I will be looking at somehow hosting them on this web-host but I’m not sure that’s even possible as I don’t have direct privileges to install the software that’s required. I will look into this further and apologize for any inconvenience this is causing.

btk


Yes I Can

…make it easier for you that is.

I ended my last post with the question

“Couldn’t make it easier than that could I?”

Well after some productive typing I’ve created another form which will handle conversion to .amv and extraction to .mp3 on uploaded videos. Not only this but if you enter a YouTube URL it will skip over to YouTube, grab the video directly and do the conversion(s) for you.
So here it is:

This saves you time as this PC can download the video from the site instead of having to wait for you to download then upload it. If you have a slow connection that could be ages! (not that my connection is anything to brag about!)

You can find this form here.

Now, I really can’t make it any easier can I?

btk


How To Get The Audio From A YouTube Video

I’ve made this brilliant online tool to extract the audio from a downloaded Youtube(or other video) file.

All the rest of this post is obsolete now as I added the option to input a Youtube URL into the form but feel free to follow it for downloading only.

So how to actually download the file from youtube?

Well I suggest using this free Firefox browser plugin. Then simply navigate to the youtube video of your choice and click the little spinning balls in the bottom of your browser thus:
DLHelper Screenshot

There may be more than one option for download but if it’s just for the soundtrack I’d suggest the .flv as this always works in the converter, other file types may work just as well it’s just that I’ve not tested for those. If you want the video and size is of no consequence I’d suggest getting one of the HQ/HD versions.

So get your video then upload it into my form above where my computer will perform black magic that strips the music/audio out and sends it back to you as an .mp3

Couldn’t make it easier than that could I? (Well if you ask nicely I’ll give you one you can use on your own linux machines for when mine’s is offline!)

btk


Seven Things You Don’t Know About Me

I’ve been tagged by Stuart Brown of OU fame and this brilliant blog for a seven things you (possibly) don’t know about me meme (pronounce this as meem not meemee, I made that error in the company of geeks once, not nice!)

Normally these wouldn’t make it onto this blog but, like with the TV Licence post there’s nowhere else for them now! So here goes…

The Rules?

  • Link to your original tagger(s) and list these rules in your post.
  • Share seven facts about yourself in the post.
  • Tag seven people at the end of your post by leaving their names and the links to their blogs.
  • Let them know they’ve been tagged.

Seven things?

  1. I have four children. My eldest was born when I was just 19 years old, she turned 10 last year and yet I insist I’m still 24, go figure. My youngest is 2 years old. I’ve undergone a medical procedure to ensure she is also the last!
  2. I taught myself mIRC scripting having never learnt any other language, and with a tentative grasp of English, truth be told. Some of my scripts have been downloaded from various sites thousands of times! I’ve since dabbled in javascript with greasemonkey scripts and am currently learning PHP.
  3. I met my girlfriend when we were both only sixteen, she was still in high school!
  4. I have applied to the Open University for enrolment for a BSc in Computing course. I should start later this year having just missed out on the Feb start. My girlfriend already has a similar degree and I am very jealous of her, she’s a software engineer for an engineering company(Aker Solutions) and writes the control software that runs offshore oil rigs, she recently put in a system that lets BP make £900,000 a day! If her software fails for 20 minutes she would need to work for 33 years to pay back the lost revenue!(that’s not in her contract so don’t worry unduly – the oil will still be in the ground!)
  5. I am a time served plumber to trade but don’t do plumbing any more, this is why I am also poor!
  6. I passed my driving test first try at 17 and in the time since then have owned 13 vehicles, which I’ve listed(sad I know!) here
  7. I stopped smoking on the same day as I started my first blog, I’ve now been ‘clean’ for over 3 years. I never meant to stop I just stopped buying them one day, which led to 2 days and so on. I still to this day have the cravings and I don’t think they will ever go away. It’s easier to NOT buy smokes than it is to buy them so I’ll remain smoke free. Nothing to do with will power, just laziness!

Who’s Next?
AmyWhy Am I Here Again?
RussellThe Tomahawk Kid
DavidDavid’s Blog
ChrisFlight of TheEaglehawk
RashaanStep Into the Nexus
Michelle – Critical Musings
CharlesPlurkfiends

btk


Twitter Greasemonkey Script

I’ve done a GM script that simply removes the DM count number from being displayed on your twitter page. It annoys me as it doesn’t show NEW DMs only but ALL DMs including those already seen. There’s no option to hide it and I don’t want to delete them.

I use tweetdeck on twitter anyhow so don’t need to see that count on the occasions I do visit my twitter home page. This just removes the annoyance.

Get it here (Downloaded 233 times) | Signature

Toggle Code

btk


TV Licensing – Gotcha By The Balls

This isn’t particularly techy or geeky but since I closed my personal blog I’ll put it here as it’s ‘just’ internetty enough!

According to the TV licensing site you need a license if you watch TV ‘as its being shown live’ no matter which medium you use, be it a PC with a TV card or a TV itself. The wording being

You must be covered by a valid TV Licence if you watch or record television programmes as they’re being shown on TV.

Interestingly though, until recently(and I’ve not bothered to verify, favouring writing this blog post on it instead) you needed some sort of hardware designed specifically for the reception of TV signals. Now however that wording revision, backed up on this BBC page*, means that you need a TV license IF YOU HAVE INTERNET ACCESS AT HOME!! (as that’s live streaming at the same time as it’s shown on TV.)

Alternatively that wording could be construed to mean that you need to actually WATCH TV now to require a license. In which case I have a TV, digibox, PC and VCR, but since I’m not recording or watching I need no TV license?? I wonder which version the authorities favours…

Anyone wanna start a revolt?

*-clicking this link requires a TV license!

btk





billy.the-kid.org is Digg proof thanks to caching by WP Super Cache

© 2004-2009 billythekid