Search
-
-
Recent Posts
Tags
adwords amazon analytics api apple aws blog browser chrome chromium cloud Design dropbox ec2 email error facebook firefox gmail google google-apps greasemonkey ipad javascript jQuery linux lion mac microsoft mysql os x osx php plugin quicksilver scam social spam ssl twitter unix video windows woo wordpress
Category Archives: Web Development
What is ming for PHP (php5-ming) ?
Reading a recent server setup guide I saw the suggestion to use apt-get install php5-ming to install Ming – as a (suggested) module that WordPress would like to have. so what is MING ? First of all: Ming is not an acronym. Ming is an open-source (LGPL) library which allows you to create SWF (“Flash”) format movies. Ming supports almost all of Flash 4′s features, including: shapes, gradients, bitmaps (pngs and jpegs), morphs (“shape tweens”), text, buttons, actions, sprites (“movie clips”), streaming mp3, and color transforms –the only thing that’s missing is sound events. Note that all values specifying length, distance, size, etc. are in “twips”, twenty units per pixel. That’s pretty much arbitrary, though, since the player scales the movie to whatever pixel size is specified in the embed/object tag, or the entire frame if not embedded. More information about ming is available in the PHP documentation
Install Slanger on Ubuntu 12
Slanger is an open source server implementation of the Pusher protocol written in Ruby. I wanted to install it on Ubuntu 12 but hit a few snags, so here’s how I got it working. First, it seems pretty imperative that you have a good ruby version manager (rvm) tool available. On Mac OS X I use rbenv but on Ubuntu I think the best one is the one from https://get.rvm.io and not the one from apt-get. So if you have installed the one from apt-get then it is probably best to remove it. Disclaimer – back up important files, blah bla blah, you should have some knowledge of linux, bla bla bla, I don’t know what you might accidentally delete while doing this. Be careful. To remove the old rvm: sudo apt-get –purge remove ruby-rvm sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh Then logout of the shell and/or reboot and run: env | grep rvm It should be blank, but if not try and find where the settings are coming from. I changed to the /etc/ directory and ran grep -Hil rvm and found that it was in the bash.profile there so i removed the environmental variables being set there, then logged out of my shell and logged in again. Once that is removed, you need to install the new version of rvm and from the website get.rvm.io the instructions say run this: \curl -L https://get.rvm.io | bash -s stable –ruby –autolibs=enable –auto-dotfiles That worked great, I think it installed ruby … Continue reading
Posted in Tech Tips, Web Development
Tagged gems, ruby, slanger, sockets, web-sockets
Leave a comment
PHP: Convert Ascii To Hex
When working in PHP there are times when I want to see what a string is in HEX – a lot of times there are invisible characters that or non-printing strings that can throw your program or script for a loop. If you save the string to a text file, you can use a hex editor utility, like hexdump to take a look at the hex codes of the ASCII characters: $ echo abcd > test.txt $ hexdump test.txt 0000000 61 62 63 64 0a 0000005 $ Now for the PHP version: header(‘Content-type: text/plain; charset=utf-8′); $ascii = ‘abcd’; $hex = unpack(‘H*’,$ascii); // you can print out the hex result of the ascii conversion: print_r($hex); # Array # ( # [1] => 61626364 # ) // or for a nicer display you can add spaces between every two characters // and wrap the column every 6 characters (change to fit your needs) echo wordwrap(implode(‘ ‘, str_split($hex[1], 2)), 6); # 61 62 # 63 64
Installing php apc with homebrew
I’ve been enjoying using the keg homebrew-php by josegonzalez in order to run the latest versions of PHP, like PHP 5.4 on Mac running OS X 10.8 Snow Leopard. I also like to use Ubuntu on some cloud web servers and have been noticing a huge improvement in performance when the php module apc is installed / enabled. Recently I learned that I can get this same performance boost on in my development environment on my mac by using apc here too. Just install it with homebrew: brew install php54-apc The module will be installed and enabled, and on my system it created a new config file called ext-apc.ini in the directory /usr/local/etc/php/5.4/conf.d and it has some great defaults: [apc] extension=”/usr/local/Cellar/php54-apc/3.1.10/apc.so” apc.enabled=1 apc.shm_segments=1 apc.shm_size=64M apc.ttl=7200 apc.user_ttl=7200 apc.num_files_hint=1024 apc.mmap_file_mask=/tmp/apc.XXXXXX apc.enable_cli=0 One key here is that apc.shm_size needs to be set, and that it also needs to have the suffix M or I guess you could use K if you wanted a really small shm_size but honestly 64M works pretty great.
PHP rjust
Python has a neat feature that does right alignment of strings with the syntax: string.rjust(padding,fill_char) The method rjust() returns the string right justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s). Below you can find how to do it in PHP php rjust function // by techblog.willshouse.com function rjust($string,$total_length,$fillchar=’ ‘) { // if the string is longer than the total length allowed just return it if(strlen($string) >= $total_length) { return $string; } $total_length = intval($total_length); // total_length must be a number greater than 0 if( ! $total_length ) { return $string; } // the $fillchar can’t be empty if(!strlen($fillchar)) { return $string; } // make the fill character into padding while(strlen($fillchar) < $total_length) { $fillchar = $fillchar.$fillchar; } return substr($fillchar.$string, ( -1 * $total_length )); } test php rjust function header(‘Content-type: text/plain’); $items = array(‘one’,'a’,'superduper’); foreach($items as $item) { echo rjust($item,15); echo “\n”; } php rjust function output one a superduper
How to insert a photo from Media Gallery into WordPress
Problem: I am trying to make a post. I have a loaded in our Media Gallery but when I go to the post and try to put in the post I can’t get to it. Solution: try clicking on the left hand column that says gallery / all images Visual Example: Steps: Click Add Media Choose Insert Media Choose Media Library Click on the photo, image, picture you want to insert Click “Insert Into Post”
VideoJS m3u8 example
Here is an example of how to use video.js with HTTP Live Streaming (HLS) with an m3u8 playlist file: < !doctype html> <html> <head> <link rel=”nofollow” href=”http://vjs.zencdn.net/c/video-js.css” rel=”stylesheet”/> <script src=”http://vjs.zencdn.net/c/video.js”></script> </head> <body> <video id=”my_video_1″ class=”video-js vjs-default-skin” controls preload=”auto” width=”640″ height=”264″ poster=”my_video_poster.png” data-setup=”{}”> <source src=”http://server.name.tld/HLS/path.m3u8″ type=’application/vnd.apple.mpegurl’/> </video> </body> </html> via
How to use HLS (HTTP Live Streaming) with Amazon CloudFront
I have a mp4/h.264 video that is a around 300mb. I would like users to be able to watch it on both desktop browsers and mobile devices. I have the video file stored on Amazon S3. I have two cloudfront sources enabled – one for download and one for streaming. I know I can use something like VideoJS to play the file with the ‘video/mp4′ source being the “download” cloudfront source which, I believe, plays while the file is being downloaded – I think this is called “progressive download” but it is not true streaming. I also realize that I can use something like JWPlayer and the “streaming” cloudfront source to give users on a desktop device, or a device that supports flash, the RTMP streaming experience. The problem I’m facing is poor performance on iOS devices – especially ones with limited bandwidth. From what I’ve been reading HTTP Live Streaming (HLS) seems to be the only “streaming” protocol that iOS devices really support. And as far as I can tell, Amazon Cloudfront only natively offers RTMP streaming of uploaded mpeg/h.264 files (not HLS). Amazon has a Live Smooth Streaming tutorial for use with Amazon CloudFront which appears to be, in a nutshell, a Windows IIS server running Adobe Flash Media Server and pushing out the HLS stream via Amazon Cloudfront. So, my questions were: If I want to push H.264/mpeg4 files “streaming” to iOS devices or HTML5 players, is the “right” way to do this to use HLS? Can … Continue reading
Using VideoJS with YouTube
I have been using VideoJS for some streaming videos and mp4 videos, but also wanted to pull YouTube videos into the player along with the other videos I had on the site. First of all, the working example. Then, the list of problems ;) VideoJS and Youtube Example How to replicate the Youtube and VideoJS integration: First, clone or download this fork of videoJS and build it. Next, place this in your webpage’s <head> (needs to be there to work with older browsers). Also fix the odd character after the href in the first line (sorry about that) and make sure the path points to the correct location for the files. <link href≠”/video-js/video-js.css” rel=”stylesheet” type=”text/css”/> <script src=”/video-js/video.js”></script> And then place this in your document’s <body>: <video id=”example_video_1″ class=”video-js vjs-default-skin” controls preload=”none” width=”640″ height=”360″ data-setup=’{“techOrder”:["youtube","html5"],”ytcontrols”:false}’> <source src=”http://www.youtube.com/watch?v=v1uyQZNg2vE” type=’video/youtube’ /> </video> There is also an example file in the dist directory which will only be created after you “build” the fork you have cloned from github. VideoJS and Youtube Problems With Integration I tried simply giving VideoJS the URL to the YouTube video but that didn’t workout so well. Here are a few things that might help you out with playing You Tube videos in Video JS: There is a pull request for changes that would allow VideoJS to work with YouTube. A few problems with it are: Has not been pulled in Both the Video JS maintainer and the pull requestor have become busy with other projects so it might not … Continue reading
How to Select a jQuery UI tab with Javascript
The documentation for jQueryUI tabs is a bit cryptic. It was not immediately clear how to Select a jQuery UI tab with Javascript, but I got it working with this little bit of code: $( “#tabs” ).tabs( ‘select’, “#profile” ); #profile is the id of the tab you would like to select, and #tabs is the element you set up the tabs on by calling $( “#tabs” ) You may also have to use jQuery instead of $ if you have noConflict mode enabled, the tabs need to be initialized first (as previously mentioned), and it is possible you will need to put all this info inside the ‘jQuery document ready’ wrapper: jQuery(function($){ $( “#tabs” ).tabs( ‘select’, “#profile” ); });