Skip to main content

Posts

Showing posts from May, 2016

Quick and dirty Android YouTube fullscreen sample code.

I am currently developing an application that requires playing YouTube videos in full screen mode. After scraping around and putting together the pieces, I currently have the following code which I hope is of use to anybody else out there. public void playYouTubeVideo(String videoId) { String videoTemplate = "@YTBASE@@VIDEO@"; String videoAction = videoTemplate .replace("@YTBASE@", "vnd.youtube://") .replace("@VIDEO@", videoId); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(videoAction)); intent.putExtra("VIDEO_ID", videoAction); intent.putExtra("force_fullscreen", true); startActivity(intent); } There are some points to bear in mind though... Once the ACTION_VIEW intent has control, your application is effectively paused i.e. it won't work until you use the back button to exit the player intent and return to your application. It may or may not work in t

Prime Peace

I think prime numbers are the numerical expression of peace. Restful nodes in the vibration of everything. Prime factorisation has always struck me as something truly astounding and it is reassuring to know that awsesome minds are hard at work trying to solve the Riemann hypothesis right now. There are some truly wonderful professional and amateur (in the nicest sense of the word) explorations I have watched recently and the ones that moved me the most, in order of cool factor were: This guy,Carlos Paris, has put in some serious work with AutoCAD and made some interesting observations. I truly enjoyed watching all of his four videos. Awesome work Carlos. As an interested amateur I found his work and thoughts to be very compelling. I am sure the professionals would groan or moan but to me this video is most excellent and informative. Speaking of the professionals, this video is also very interesting to watch as it goes some way to visually explaining the Riemann hypothesis in

Cross platform development with Scheme

Just a quick note about something I recently found whilst trying not to buy MOCL… http://www.lambdanative.org/ LambdaNative is developed and maintained by the Pediatric Anethesia Research Team (PART) and the Electical and Computer Engineering in Medicine (ECEM) group at the University of British Columbia (UBC). I have spent a week or two evaluating it and accidentally contributed a pull request that got merged and one that didn’t and I have to say that, for what it offers, it is awesomely good. Having personally spent many hours with it now, I do not yet think it is ready for mainstream development for a few reasons. I don’t mean that it a bad way either. What I mean is that the language, Scheme, is not really that widely known and as such it probably won’t break out into the public arena any time yet. That’s a real shame because I think that they have achieved an amazing thing; total abstraction of the underlying platform with a really powerful, underestimated language. Go

Control OSX Screen Brightness from Ubuntu 14.04 (on a USB stick!)

After trawling here and there and trying lots of different things, for me this works on my late 2012 21″ iMac with an ACPI card. It’s best to put the script into a file, make sure the file is discoverable on PATH. All details are in the folder: /sys/class/backlight/acpi_video0 which on my machine looks like this: ubuntu@ubuntu:~/mc2$ cd /sys/class/backlight/acpi_video0 ubuntu@ubuntu:/sys/class/backlight/acpi_video0$ ls -l total 0 -r--r--r-- 1 root root 4096 Oct 7 08:29 actual_brightness -rw-r--r-- 1 root root 4096 Oct 7 08:29 bl_power -rw-r--r-- 1 root root 4096 Oct 7 08:28 brightness lrwxrwxrwx 1 root root 0 Oct 7 08:29 device -> ../../../0000:01:00.0 -r--r--r-- 1 root root 4096 Oct 7 08:03 max_brightness drwxr-xr-x 2 root root 0 Oct 7 08:29 power lrwxrwxrwx 1 root root 0 Oct 7 08:29 subsystem -> ../../../../../../class/backlight -r--r--r-- 1 root root 4096 Oct 7 08:03 type -rw-r--r-- 1 root root 4096 Oct 7 08:03 uevent WARNING: If you use values higher than the maximum

Emacs fat fringes and colours

Having gotten used to various editors implementations of distraction free or presentation mode views, I figured that emacs could probably do something similar with little effort. As usual, it could. For me, distraction free means no clutter, no menu bars, tool bars, gutters, line numbers, just the code. The first step is to be able to set the size of the left and right margins to something large, 100px works quite well. I use Aquamacs a lot. This does not work in the terminal! So, here is the little bit of code you need to place into your beloved ~/.emacs file: (defun fringe-bars (width) (interactive "pWidth:") (fringe-mode (cons width width)) (set-face-attribute 'fringe nil :foreground (face-foreground 'default) :background (face-background 'default))) Then, using the Ctrl-U prefix, you would set the left and right margins to be whatever you want, let’s say we wanted to have 500px left and right, which wor

OSX GNU Guile — beating libltdl into submission

After encountering an issue with socket handling in the remote REPL server code I needed to build guile from source but it just wouldn’t. I downloaded a mint latest source from http://www.gnu.org/software/libtool/ and gave it this spell: ./configure --prefix=/opt/local to make it overwrite the Mac Porst version to see if that would fix it. It didn’t. After further close reading of the configure help text for guile the answer was there as usual, resulting in this incantation: ./configure --with-libltdl-prefix=/opt/local --prefix=/opt/local Result… clean run of the configure script! Now all I have to do is build it and get to the bottom of the problem. Apparently it only happens on OSX, Ubuntu is not affected, nor presumably is any other *nix. Oddly, geiser mode works, if that is using com-int buffers then I don’t see why I cannot then use telnet or netcat to connect to the REPL server. We’ll see! It’s got something to do with opening a socket in non-blocking mode then sen

The ultimate programming language ?

After many years of thought and many years of using many languages, I am now more and more convinced that the “perfect” combination, if such a thing exists, is going to be a mix of Haskell, LISP and Prolog. Exactly what “combination” means in terms of the different programming paradigms each presents is completely unknown to me at this point! Haskell is functional, Prolog is logical and LISP is everything. LISP First of all, the uniform s-expression shape of LISP is so absolutely pure, clean and simple that I feel it’s the true shape of expressing thoughts as code. If you work in LISP long enough you don’t even see the parens any more. Really. And the implied return value being the last thing you did is also useful. Haskell Haskell is incredibly clean in its form. The use of a space character as the argument separator is cool. The functional aspect is also very very nice. What I don’t like about Haskell is the IO / monad thing, Sometimes it feels incredibly hard work to do th

Why is software development still so hard?

Total experience to date: thirty-one years. Started with UCSD Pascal and Z80 assembler. Currently into Haskell and Prolog and anything functional. Putting all that to one side, as we all know that the language you use to implement a solution is by and large irrelevant, no really, you know it is… I find myself lately finding it harder and harder to want to embark on any sort of personal project. A mere twenty years ago I was brimming with enthusiasm for it but these days I just find myself wanting to watch cat videos on YouTube. Initially... I was spell-bound (and to some extent still am) at the age of eleven that you could “express an idea” in the language that the computer could understand, be it BASIC or whatever was available and then sometime later have that idea executing. Of course, the idea has to be information processing centric; that’s what the infernal machines do so well. Eventually... I realised that you could express solutions using any number of techniques rang

Command line atmospherics with mpg123

I have loved listening to SOMA.FM for years, especially Groove Salad. I also recently found a brilliant little site called soundrown.com , which plays various background noises in response it seems to recent scientific study that shows a certain level of background noise helps you get in the zone, stay there and be more productive. Being a command line person, I looked around to see if I could mix the two and not have to use a browser, and here is my solution, using mpg123: $ mpg123 -q http://173.239.76.148:8032 & $ mpg123 -q http://www.soundrown.com/Audio/Final%20Normalized/mp33/CoffeeShopFinal15.mp3 & You can put it into a script I guess like I did. The “-q” stops any output and the trailing ampersand backgrounds the processes; this stops junk appearing in your terminal window from time to time. I can’t work without it much these days, it helps to drown out the office noise around me.