Tuesday, May 13, 2014

Webpage for uploading really large files to your webserver

Background:
I have a website hobby project named GAC (for reasons not so obvious to anyone thats not me). Anyways, this website is hosted locally only on an old laptop of mine and it is connected to my TV and also an arduino board that drives a couple of SSR's for in-house light switching.
Showing GAC 1.5 in Chrome
One of the features of GAC is it's mediacenter controls. I would upload a file to the server using SMB on the LAN and the video files then got listed on the website, where i could then start playback on the TV directly from the browser. A handy feature that makes me start playback from any device in the house with a web browser.

Now i'm a C# guy and not much of a web developer, so when i started wandering over to the world of websites i choose the natural path of continuing to use Visual Studio and create websites with ASP.NET.

The problem:
This went great, up till GAC 1.4 when i added a file-upload feature. There is a file upload control in Visual Studio that you can use, but it has one hidden limitation, and it's a big one.
When you add a file to the FileUpload control and call SaveAs the runtime behind that will start buffering the file, so it has the whole file in RAM before it writes anything to disc. Now this is a reasonable aproach for small files as it lessens the disk load, but in my case it meant i would need to alocate many gigabytes of ram just for the file transfer.
I also hit some bogus limitation with web.config not letting me set the MaxRequestLength above ~4gb. And after spending hours on google and not really getting where i wanted i decided to simply ditch ASP.NET and implement some HTML5/PHP magic for this feature.


I went with Plupload, and you can download it here and also get examples and good documentation:
http://www.plupload.com/
I'm very happy with Plupload, it's providing easy and limit-free implementation, that work well with every browser and configuration i have tried.

And as always my project is available on GitHub, called GAC






Thursday, April 24, 2014

How to avoid the safe volume 'feature' on Samsung devices

I have a Samsung Galaxy S4, and as with many Samsung devices this phone has a feature that lowers the volume when you put a minijack connector in the headphones jack. The reasoning being that users are idiots, and if this feature wasnt there we would all sit with our headset on at earbleeding volumes till we would need hearing aids.

This 'feature' was never a good idea, but it's made worse by the fact that you cannot turn it off.
And the extra fiddle to adjust the volume up is especially annoying when using the phone to listen to music in the car. A reoccurring annoyment every day.

That is untill now. I found a workaround using the app Tasker. Tasker is an app that lets you configure stuff to happen when different events occur, and as such makes a perfect fit for this problem.

<---The tasker icon. You can find Tasker on the app store for next to nothing.


What we will do is create a task that sets the volume to MAX everytime the headphone jack is plugged in, effectively overriding the 'idiot blocker'.

Step 1: Install Tasker
Step 2: Create a new context by pressing the + sign on the bar at the bottom, you then want to select the "State" context from the menu. (I've already done this, so the finished task is visible in the background)
Step 3: Select State category "Hardware" then "Headset plugged"
Step 4: Create a new task, name it something descriptive like "Volume to max"
Step 5: Add a new action by pressing the + on the bottom bar. Select "Audio" action
Step 6: Then "Media volume"
Step 7: Now just set the volume level to maximum and you've created a nice little tweak for your phone.


Monday, February 24, 2014

Fixing Aspire 3680 - No sound on headphone jack

I have an old laptop laying around, an Acer Aspire 3680. It's been a thrusty companion for the years i used it. But about a year ago i replaced it with another cheap, slightly newer office spec laptop. And since then my Aspire has mainly been gathering dust altho it's occasionally booted linux, to avoid dual booting my main machines.


But now recently i found a use for this laptop as a Youtube watching station for my treadmill. And so i flushed my linux install and spun up Windows 7 on it. Installed drivers and all was good. Until i mounted it  by my treadmill and plugged it to the speakers with the 3.5mm jack.
... and nothing happened. No sound.

After reinstalling drivers, newer drivers and googling a bit i found the solution to be odd, but simple:
Simply putting the computer to sleep.
After waking it up again the audio jack will work just fine.

The headphone jack will continue to work untill you restart the computer. Then you will have to put it to sleep again in order to use the headphones again.

Way back when i used the laptop for work i never turned it off, just put it to sleep, so chances are i this issue has always have been there without me noticing.

Tuesday, February 4, 2014

How to force SQL Server 2012 to do what you want

SQL is a pain.

I've been hating on it ever since i first was forced to use it, about a year and a half ago.
I first started out working with MS Access, and while SQL Server 2012 only sucks about half as much, it's still a sore and painful experience.
Now one of the worst things about SQL Server 2012 is that by default it requires you to be 100% flawless in you database design. You're not allowed to change a single thing after deploying the database, and if you try, then you get this error:

And being a grade A noob at database management i assumed there was no way around this. So i have been redoing entire databases from scripts way to many times now. And i must admit that i got a bit mad when i found the solution to this problem ;)

Just go disable this error dialog in:
Tools -> Options -> Designers
And uncheck "Prevent saving changes that require table re-creation"
And voila! no more silly errors!

Wednesday, January 29, 2014

How to delete backlog items in TFS

I'm currently taking a course in software engineering, focusing on the agile development model. And in this course we are using Visual Studio Online. Visual Studio Online is an instance of Team Foundation Server (TFS) hosted by Microsoft, and is free for teams up to 5 people (with some restrictions).

And so at this course we are split into groups of 5 for the whole semester, avoiding spending ;-)

Anyways, one of the things i found non-intuitive with TFS was in the handling of backlog and work -items. Especially deleting items.
One would think that just right-clicking on the item would bring up the option, but thats not the case.


Not here
In order to delete a backlog item you need to doubble-click the item and set it's state to "removed":
Select 'remove' and it will move to trash
And once selected removed, you can still find the item if you do a query for removed items. The trash can model.

As a first time user i find TFS to be way more time consuming than it should need to.

Sunday, January 26, 2014

Coke is IR transparent

Some time ago i made a blog post explaining how to remove the IR filter from a webcam in order to turn the webcam into a IR camera, or at least NIR (Near Infra Red).
Link here to the original post:
turn-normal-webcam-into-ir-webcam

Now i recently came across something interesting. It turns out that Coke is actually IR transparent. It's rather mind boggeling how something so dark in color can look like water with a NIR camera.

Here are some photos:

In the background you can see the webcam feed, seeing the glass as transparrent
How a normal camera sees this glass
Taken with the modified web cam
Another one
You can see thru the whole Coke bottle

Thursday, January 2, 2014

Side-scroller skateboard game with C# and XNA

This summer i was reading this book on game development, and even tho i did make a couple fun projects, i forgot to post them here.
But these past few hours i've been trying to clean up my messy folder structures and import all my repos to GitHub. And going thru all my stuff i found a few nice bits of code.

And this little skating game i made with C# and the XNA framework. The game is called ScrollinBackground.

Skate, avoid the obstacles and grind the rails.

Arrow keys to control the skater.
Space to jump.
Arrow up to grind rails.


Gameplay footage