Tuesday, March 14, 2017

Align text centered vertically


Awesome, but doesn't work on older browsers:

.parent {
display: flex;
align-items: center;
}

Works on older browsers:

.parent {
display: table;
}

.child {
display: table-cell;
vertical-align: middle;
}

Thursday, February 26, 2015

Things about vim

Find replace

Show line numbers

:set number

Replace using ranges

Insert # at begin of line from line 1 to 10
:1,10s/^/#

Find each occurrence on each line and replace

:%s/find/replace

e.g:
:%s/^0/27

Find each line starting with 0, and replace the zero with 27

Sort, removing duplicates

:sort u

Thursday, January 08, 2015

MySQL - create database and user quickly

I'm not a MySQL fan. I don't use it enough to remember some basic things.

mysql> create database mydb;
mysql> create user 'myuser'@'localhost' IDENTIFIED BY '*******';

mysql> grant all privileges on mydb.* to 'myuser'@'localhost';

Wednesday, January 07, 2015

Things about python that I constantly forget (hate)


SyntaxError: Non-ASCII character '\xe2' in file blah.py on line 67, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Gaaaaah!

Put at top of file:
# -*- coding: utf-8 -*-

Friday, October 03, 2014

Things about developing on Mac that I constantly forget (hate)



Apache

Starting apache:

sudo apachectl start

Browsing to the right place


http://localhost/~username/

Monday, August 25, 2014

SCU-17 on Ubuntu

Configuring FLDIGI to work with SCU-17 on Ubuntu 13.10, I ran into a permissions issue.

Normal users can't access /dev/ttyUSBx You have to:
sudo chmod o+rwx /dev/ttyUSB0
sudo chmod o+rwx /dev/ttyUSB0 

Or (to make permanent) - from some sites on the internet (links lost - sorry):
sudo adduser youruser 
dialout sudo reboot

Friday, July 25, 2014

d3.js - Hello World

<!DOCTYPE html>
<html>
<head>
<!-- d3 uses extended ascii characters, so we HAVE to specify utf-8 -->
<meta charset="utf-8">
<script type="text/javascript" language="javascript" src="d3.v3.js"></script>
</head>
<body>
<script type="text/javascript">
// 1. Select a DOM element with a CSS selector
// 2. Create (and append) a new p DOM element, append it to body
// 3. Set the text of the DOM element p, to "Hello World!"
d3.select("body").append("p").text("Hello World!");
</script>
</body>
</html>

Sublime Text on MAC -


Go to end of line/begin of line, and select to end of line, begin of line defaults were driving me crazy. I wan home to move to begin of line, and end to go to end of line - not begin/end of document. Same deal for shift+home and shift+end - I want to select to begin/end of line.

Here's how to "fix" it - just add this to the keymaps.
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },

Tuesday, April 01, 2014

macports - rsync blocked

Rsync is blocked at my work because stuff.

http://www.dreamchain.com/how-to-sync-mac-ports-without-rsync/ says:

If port 873 is blocked on your network and you need to sync MacPorts do this:
In /opt/local/etc/macports/sources.conf replace
rsync://rsync.macports.org/release/ports/ [default]
with
http://www.macports.org/files/ports.tar.gz [default]
and run
sudo port sync
instead of
sudo port selfupdate
MacPorts is now synching using http over port 80 instead of rsync over port 873.

Wednesday, March 19, 2014

Why I love Python

Reason #1

monkeys.sort(key=lambda monkey: monkey.height)


Reason #1.2

monkeys.sort(key=lambda monkey: (monkey.height, monkey.age))

Reason #1.3

monkeys.sort(key=lambda monkey: (monkey.height, monkey.age), reverse=True)

Wednesday, June 02, 2010

WPF - ListViewItem - MouseOver

I keep forgetting the style, to set the mouseover color of a listview item


<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>

Friday, March 19, 2010

Evolution - GMail - IMAP

Lies and more lies.

Here's how I got evolution to work with Gmail using IMAP

Receive:

IMAP

imap.gmail.com:993

SSL

Send:

SMTP

smtp.gmail.com:465

server requires authentication

ssl encryption

authentication type PLAIN


Sunday, January 24, 2010

ffmpeg and mp3

I went to the trouble of compiling ffmpeg on windows - but there was an issue with compiling lame. It felt so unnatural on windows anyway. I'm so used to just having all the tools right there. With Ubuntu it's just so EASY. Most programs are just a quick apt-get away. If I need to compile something, it's just make install and you're away!

I'm supposed to be studying - but looks like this post : http://symbiotix.net/articles/compiling-ffmpeg-mp3-ubuntu-revised-ubuntu-gutsy-server is what I need. I'll give it a try when I have time - or maybe medibuntu has a ffmpeg with it build in?

Stolen from his site:
"However, we’re using Ubuntu based servers and Ubuntu has a strict policy not to include non-free software. This means that the ffmpeg version in the repositories is not built with essential functionality, like mp3 support for audio conversion.

Solution: compile from source. Don’t run away screaming. It’s real easy.

1. enable universe and multiverse repositories
UbuntuGuide » general notes » how to add extra repositories

2. get your tools

sudo apt-get install checkinstall build-essential subversion 

3. get the latest ffmpeg sources

cd /usr/local/src sudo svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg 

4. get the necessary dependencies

sudo apt-get install liblame-dev libfaad-dev libfaac-dev libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev  

5. configure

cd ffmpeg sudo ./configure --enable-gpl --enable-liba52 --disable-debug --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-pthreads --disable-vhook 

6. compile

sudo make 

7. go have a snack

8. create the .deb package

sudo checkinstall 

note: just press [return] each time when asked for a configuration option

9. install the .deb package

sudo dpkg -i [ffmpeg_your_version.deb] 

10. rejoice "

Sunday, December 27, 2009

ffmpeg - MTS to MOV with DNxHD

So I'm trying to get some insane high quality .MTS video, down to the same quality as my DSC's .MP4 stuff in DNxHD.

I can't for the life of me convince ffmpeg to get the FPS right. So for now my solution is NOT to take it to DNxHD, but to MJPEG

The video is easier than the sound - due to Vegas having that stupid sound bug. I spent more than an hour today trying to find an audio stream that Vegas likes. So far I have this:

ffmpeg -i source.MTS -vcodec mjpeg -s 1280x720 -qscale 1 -r 30 -acodec ac3 -ac 2 -ab 192k -ar 44100 target.AVI

Video works sweet - sound still messed up!


Thursday, December 24, 2009

Sony Vegas - it's worth the trouble to get it to work

After battling for hours - I have the solution.

Problem: Sony Vegas won't play audio for .MP4 - they blame QuickTime (LAME!!). All other non-pro video editors suck. Apart from the ones I blogged about - I tried a whole bunch of open source ones. They all suck.

Solution:
1. Pay for Sony Vegas (incentive to get it to work + I'm a Sony whore even though their laptops suck)
2. Download DNxHD codec from Avid woohoo for open standards!
3. Set up a nice Ubuntu install in VirtualBox (I'll have to dual boot until Civilization and Vegas run native under Linux.) Skip this step if you are hard core enough to compile ffmpeg to work under Windows.
4. Praise the mighty ffmpeg

ffmpeg -i INPUT.MP4 -vcodec dnxhd -b 60Mb -acodec pcm_s16be OUTPUT.MOV

5. Boom. You're ready!!!


Tuesday, December 22, 2009

Video Editing - With Adobe Premier Elements 8

Awesome i7 chip, 7200rpm drive is decent enough - lets give this a spin

1) Massive download, install Adobe Premier Elements 8
2) Woohoo! It can edit .MP4 files!!!
3) Ok. It stopped working. W.T.F???
3.1) Damnit! Fine - I'm learning how to use ffmpeg
3.2) Install ubuntu in virtualbox - I'm not rebooting all the time
3.3) ffmpeg -i M4H00471.MP4 -vcodec mjpeg -sameq output.avi
4) Ok - sweet - I can open my files
4.1) I wonder if it works in Vegas now?
4.1.1) Nope
5) Ok - lets do some easy fade in / fade out effects
5.1) Damn this shit is slow.
5.2) DAMN!!! THIS IS SLOW!!!
5.3) W.T.F? It's not even touching my processor! My machine is just sitting back and relaxing!
5.3.1) Lots of free memory also... hmmm...
5.4) Ok ok - maybe I need to defrag?
5.5) Still slow as all hell.

Come on!!! How hard can this be! I just want to edit some some video mp4 video from my little digital camera. 720p 30 - that's not even a crazy high resolution. It should be a dream!

Sunday, December 06, 2009

Video Editing - With Kdenlive

New laptop with Ubuntu Karmic Koala. Time to edit those holiday videos.

1) Hello Kdenlive. Ok.. lets load in all the clips... BOOM CRASH.
2) Ok. Let's try only one. Hmm... sound playback kinda broken. Let's drag it on anyway. BOOM CRASH.

SOD THIS!

Video Editing - With Sony Vegas Platinum 9.0

New laptop with Windows 7. Time to edit those holiday videos.

1) After messing around and trying to figure out what I was doing wrong.... No sound? Oh excuse me - mp4 from my Sony DVC doesn't provide a understandable audio track?
1.1) Ok - I'll convert it to something else
1.1.1) To VLC!
1.1.1.1) .OGG maybe? .OGG with VLC - bad quality, and sound is skippy. And Vegas can't play it.
1.1.1.2) .ASF then. Blegh. I think VLC is a bit ill.
1.1.2) Sod VLF - there must be something else! Ooow how about handbrake?
1.1.2.1) Nope - only for transcoding to nice little happy viewable formats.
1.1.3) MediaCoder?
1.1.3.1) Need 7zip to extract
1.1.3.2) Error code 8? That doesn't help me!

Forget this!!! I'm booting back into ubuntu!

Monday, November 23, 2009

xkill

alt-f2 xkill

killing those nasty applications that i make...

Monday, October 19, 2009

WPF and the modal dialog (boring)

Warning boring tech related blog entry follows:

Holy cows! WPF has made it VERY difficult to create a modal dialog box. It's difficult, because to do it properly, your modal dialog has to have a pointer to it's parent window. You can skip this step, have have one of those really junky applications that hide away your modal dialog in a land far far away.

The trick (hack) is the following

1) You need a System.IntPtr containing a pointer to the windows handle (this.Handle if you are lucky enough to be in a System.Windows.Window.Form)

2) You need to feed this pointer into your dialog thusly:

WindowInteropHelper wih = new WindowInteropHelper(myUserControl);
wuh.Owner = myIntPtr;
// then, with magical flair:
myUserControl.ShowDialog();