Another one that is really just a note for my future self;
I’m currently working with large svg files and they are littered with paths that have inline styles defined. I need to strip these and just control the style with css or dynamically with code.
So, using Sublimetext for this, I can use the following regex expression in the find and replace:
style\=\”(?<=”)[^”]+(?=”)\”
Replace ‘style’ for whatever other attribute you want to find.
I so rarely have a need for regex I’ve still not learned it, so this is just something harvested off the web that actually works with the flavour of regex that sublime uses.
My mail server (qmail, plesk, ubuntu) has , for as long as I can remember, been delaying emails from a particular domain. Delays are usually a few hours – not enough to be a big problem usually, but certainly very annoying. Especially as the domain in question is used by most of my family.
I’ve finally had a look and discovered via the logs that greylisting was being applied, which indeed deliberately delays emails while attempting to resist spam in a smart way.
Once I added the domain to the whitelist, the delay has stopped. This is the command I used:
Great! I’ve also noticed such a delay from other email accounts before, but I can’t find a way for the grey_listing program to tell me who it’s delaying so for the moment I’m turning the whole filter off. I can always turn it back on again. This command turns it off:
sudo /usr/local/psa/bin/grey_listing –update-server -status off
Just a quick note to say that this script on github from @clark800 has saved my bacon on many occasions. Usually for professional purposes, but on more than one occasion to restore my minecraft world to before I died.
Dropbox stores your previous versions of changed files, and allows you to restore any of these, however only one file at a time. This script will go through a specified folder and restore the previous versions (and deleted files) at the given point in time. Great for when you accidentally delete the wrong folder (or get blown up by a creeper you didn’t notice 😉 )
Socket.IO is a great socket communication library that I’ve used many times in recent years. To connect to the server from a flash client I’ve had to rely on a library I found on github called FlashSocket.IO, actually on improved fork of an earlie, now stagnant project.
Socket.IO has recently made it to a 1.0 release, which is long overdue seeing as many people have been using it in production for ages. However this is not a ‘finally stable’ 1.0 release. This is more like a 2.0 release with a complete rewrite of the underlying engine and many API and protocol changes. If you were only using it via the official js client and not trying to inspect the internals at all then you can probably just update without a hitch.
However for my flash client this meant trouble. So, I’ve gone through and updated the flash client to work with 1.0, and added a few other features too, such as ssl compatibility (essential for working reliably with public networks), querystring parameter support (for passing arbitrary parameters from the client to the server to be available at connection time) and making the FlashSocket EventDispatcher robotlegs friendly.
It’s up here, so if you need 1.0 compatibility from flash have a go, and let me know if you have any problems.
WebRTC is great, but it’s pretty new, and browser support is unbalanced, to say the least. I was lucky enough to only have to support the latest chrome in my last project, but it was still a challenge to get it working for 100% of users.
Many firewalls, and in particular in corporate environments, don’t much like tunnelling open sockets from across the internet into machines in their networks. That’s understandable really, but it does get in the way of basic WebRTC connections. The solution is described well on html5rocks and involves the use of STUN and TURN servers.
I used rfc5766-turn-server which is open source, well supported on the forums and seemed to work fine. I could get data connections pretty consistently from anywhere now, but I was still seeing problems with video.
Some of my video connections were coming through as black boxes. No errors, all connections appeared to be opened correctly, just no feed. This was a big problem.
The solution came with an unexpected observation, but it makes sense – if the connection to the TURN server is limited to only use TCP, no black square – it all works fine. Presumably it’s a little slower than using UDP (the preferred default) but it’s more reliable in it’s nature.
So when you’re specifying the turn server, simply append ?transport=tcp to the url to disable udp and hopefully you’ll see the same reliability improvement that I did.
Well, maybe not totally, but I couldn’t find a good existing way of doing this.
I wanted to delay a stream by an arbitrary amount of time. The specs talk about ‘time shifting live streams’ but I don’t think there are any implementations around yet in any of the browsers for this.
I tried ‘recording’ the streams – again something that is coming, but not around yet. There are a couple of open js libraries that’ll do it, like this and this, but I needed to be able to constantly buffer dozens of streams at once and these solutions were slow and would crash the browser.
So my solution can be seen here – basically I store a grab of each frame as it comes in, and then draw these every frame back to a canvas object, after a delay. Works great, performance is great, looks like video. Only drawbacks are obviously no audio (wasn’t a problem for my purposes) and it doesn’t render unless the tab is in focus (again, fine for me).
Often I find, particularly with exhibit type projects, there is a requirement for some looping video. Often the loop is required as it’s part of the UI, rather than consumable content. A designer or animator has made some cool effect and video is simply the best way to deliver this asset.
Now there comes a problem – in older versions of flash player it was quite easy to just loop a video, but in more recent releases it’s broken and according to adobe this is not important enough to fix.
The only way that I found to get around this was to convert the file to a swf with the video on the timeline. I had some success with this, but the quality always suffered and every time the designers updated the asset I had to reconvert. Someone on the bug report suggested however that there might be way to get the video file to repeat seamlessly by using appendBytes but hadn’t provided a working example. So I just ran into this again and decided to tackle it once and for all – here’s a class that’ll seamlessly loop an flv (appendBytes only supports flv):
Edit: I recently had cause to use this again in a project so have tidied up the code a little and fixed a bug where I had delays in later loops. Also I’ve added a variation for cases where an animation plays in with one video, then loops with another.
So I’ve been struggling all afternoon to get TLFTextfield to display direction = Direction.RTL without any success. The rtl text still flowed left to right. I just got it to work with the help of this post
Basically it’s just this bit:
var myFormat:TextLayoutFormat = new TextLayoutFormat();
var myTextFlow:TextFlow=tf.textFlow;
myTextFlow.hostFormat=myFormat;
…needs to go at the end and it all starts working. urgh.
For my own benefit, just a note – http response headers are only readable from AIR via HTTPStatusEvent.HTTP_RESPONSE_STATUS, but not from Flash Player. This library does the magic: https://github.com/gabriel/as3httpclient and can give you the headers. I even tweaked it to provide headers for an ICY mp3 stream so I can see where the metadata lies.
This may be well known, but it wasn’t terribly obvious to me from Adobe’s documentation.
If you want to use the adobe AIR update framework including the UI in a pure AS3 AIR project, it looks like you need to start using the flex framework.Indeed, the documentation for “flash apps” recommends custom building an interface.
This is unnecessary – I picked out the applicationupdater_ui.swc from flex_sdk\frameworks\libs\air and accessed the ApplicationUpdaterUI class just as the documentation advised for a flex implementation and Lo – it’s all there, and it doesn’t include the whole of flex. It does add a few hundred kb, but it’s an installable AIR app, so that’s not such a big deal.