Wednesday, March 22, 2017

weird chrome bugs and weirder chrome hacks: the case of the disappearing border-radius

For an April Fool's project at work, I hacked together circle avatar by having a border-radius set to the width and height. Thing ones, when the panel they were on grew enough to need scrolling on Chrome on my laptop, the boder-radius would be ignored! But NOT on the same version # of Chrome on a coworkers laptop.

Weird. Stackoverflow to the rescue as usual; putting a opacity:0.999; or a perspective:1px; made my system behave.

Saturday, March 18, 2017

i want my own website! now what? a guide for friends of kirk and others

Every once in awhile a non-techie friend will hit me up interested in setting up their own website but not sure where to start. I decided to summarize my usual advice and explanation here, to save myself typing in the future.

OK... websites! By website I'm going to assume you mean your own domain (or possibly, just subdomain)... i.e. yourname.com (or in the case of subdomain, yourname.someoneelse.com) as opposed to somesite.com/blahblah/yourname/ .

There are 3 parts to making this happening:
1. Securing/Owning the Domain Name, saying that, in the whole wide world (or, rather, the whole world wide web) only you have the right to put stuff up at that web address.
2. Making the site, the layout and graphics and stuff.
3. Hosting the site, so that it sits on a computer that people can connect to with their browser.

There are two general approaches to this: DIY (maybe with some help from me), or using a service like wordpress.com or wix.com. I'll try to talk about both ideas as we go over those 3 parts:

1. Securing/Owning the Domain Name
For a .com domain this can run around $10-$12 a year. Other .net, .org, .biz etc can cost a bit more or less.

For personal friends of Kirk, you might be able to have a "yourname.alienbill.com" or something based on one of the other domains I own, for free, but all the domain names are a little goofy or Kirk-centric (.kirk.is, porchfest.info , etc)

If you use a service like wordpress, sometimes they will give you a "yourname.wordpress.com" for free, but if you want "yourname.com" to work you have to pay.

2. Making the site. 
There might be tools to help beginners assemble a site (in a layout language called html/css or sometimes html5) but I've been doing this long enough that I prefer to do it from scratch...in fact generally it's easier for me to do something from scratch than to learn how to use a new tool, so I'm more willing to make a simple site for a friend than to teach them how to use a tool I'm not familiar with myself.

There are lots of learning resources available online for free - I kind of like the attitude http://www.html-5-tutorial.com/ has, they seem to be comfortable with expressing the idea that "yeah, this going to seem stupid and arbitrary and weird and fiddly, but that's the way it is and we have belief that you can do it".

Assuming you don't want to learn how to write html... Wordpress.com or Blogger.com would be my choice for any site that updates regularly. Others like Wix.com might be better for "static" sites where you're just putting up your personal info and contact info in a one time way (I think Wix also has business specific templates, like if you run a physical therapy or counseling type service?) I use Wordpress.com/Blogger.com a lot (this blog is on blogger, for instance, or as it used to be called blogspot) and honestly don't know a lot about the others, but here's a page that compares various site building services.

3. Hosting the Site. 
So it's not enough to write the site - if you're doing it on your own (vs using wordpress or blogger or wix etc) you need to put the stuff on a computer that's connected to the internet 24/7 (in theory you could host a small site at home over like a cable modem, but that's a more complex scenario)

Of course, if you're using wordpress or one of them, this step is taken care of.

I used to pay about $10/month for each domain at a site called phpwebhosting.com/ - I'd recommend them highly if you want a lot of control over everything. I pay a bit more per month with them for a "Virtual Private Server" so I can run as many domains as I want (actually they were pretty good about letting me run extra domains even before I upgraded my account.)

If you are a friend of Kirk and don't need to update your site very often, I'd be happy to give you a "yourname.alienbill.com" style address for free, or if you want to pay $12/year for "yourname.com" I can put those files on my server. But- you won't have much direct access to update those files often, it will go through me. And if you're a good friend of Kirk I'd even make a simple site for you. (If you're a REALLY good friend of Kirks maybe someday I'll come up with a system to let files be updated, but for now, no, if you need to update I'll be involved.)

So that's it! Friends of mine can reach me personally for more information.

Wednesday, March 15, 2017

iphone simulator

Just a reminder, for an even deeper experience than Chrome's Devtools Phone Emulator , on a Mac if you have xcode you have an even deeper iPhone simulator and can even do debugging by going into Safari.

Saturday, March 4, 2017

musical "development"

A bit off topic for this blog, but I made tutorial about the blues - specifically a guide to "The Blues Scale" and the "12 Bar Blues" pattern, right now oriented towards beginning trumpet and trombone players. (Which we have in abundance at the School of Honk)

Tuesday, February 28, 2017

fun with sounds from the terminal

Someone at work praised Linux and posted this oneliner "white noise machine":
play -q -c 2 -n synth brownnoise band -n 1600 1500 tremolo .1 30

It can run on MacOS; play is part of sox which you can get via brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"to install brew, then
brew install sox

It reminded me of the fun you can have with the 'say' command on Macs-- a lot of voices there, get a list by running 
say -v '?'
or better yet hear each one with this clever one-liner:
for voice in `say -v '?' | awk '{print $1}'`; do say -v "$voice" "Hello, my name is $voice."; done
(it only reads the first part of multiword voice name, but things still work.)

Monday, February 20, 2017

weirdbinary: fun (?) with an alternate binary packing

A friend of mine, Ken Bernstein, caught me at the end of the "Science and Spirituality" reading and discussion group we share and mentioned this idea to me, and was wondering if I could help him figure out if if i was useful or not. It involves binary numbers.

Typical positive binary numbers, the right most place is the "ones", the next one over is the "two's place", next one is "fours" etc. and it goes like this:
0000 = 0  (0*8 + 0*4 + 0*2 + 0*1)
0001 = 1  (0*8 + 0*4 + 0*2 + 1*1)
0010 = 2  (0*8 + 0*4 + 1*2 + 0*1)
0011 = 3  (0*8 + 0*4 + 1*2 + 1*1)
0100 = 4  (0*8 + 1*4 + 0*2 + 0*1)

etc.

But what if every other digit was flipped in value? Right most place is "ones", next one over is NEGATIVE twos, next one over is "fours", next one over is NEGATIVE eights...

First few counting numbers are like this
0000 = 0  (0*-8 + 0*4 + 0*-2 + 0*1)
0001 = 1  (0*-8 + 0*4 + 0*-2 + 1*1)
0110 = 2  (0*-8 + 1*4 + 1*-2 + 0 *1)
0111 = 3  (0*-8 + 1*4 + 1*-2 + 1 *1)
0100 = 4  (0*-8 + 1*4 + 0*-2 + 0 *1)

(At least I think this was the idea Ken was describing to be)

To be frank, I'm not very smart about thinking this kind of stuff through, but I can throw some computer work at, which I've done here: http://kirkdev.alienbill.com/2017/weirdbinary/

That's some extremely loose and crappy code. For one thing I wasn't smart enough to write a "decimal to weirdbinary" converter directly, but I could go the other way, so I start by generating all the decimal values for a lot of binary counting and storing the result, keyed on the decimal value.

Then I could plot the bit ordering, if you're just doing decimal counting, what do the bits look like... and I got this:


The red column on the right is regular binary, the blue is weirdbinary. Regular binary has a nice pattern, once you know what to look for... the ones place toggles every line, the twos place toggles every other line, the fours place toggles every four lines, etc. Weirdbinary... I guess it's about the same, but the rows are kind of offset?

After that, I tried seeing how different translations from weirdbinary to regular binary looked, using regular binary as the "standard" for calculating the y position:


Ok, so for that, the diagonal red line is the trivial case: binary 000001 = 1 pixel up, binary 0000010 = 2 pixels up, 00000011 = 3 pixels up, etc. The blue is where I take the decimal values (1,2,3 etc), get the "weirdbinary" bits for it, and then plot those bits as if they were an ordinary binary number. (So every value there is positive, since I'm not using a regular binary notation that can do negatives)

I then added the green by going the other way around: I take the counting decimal values, convert to binary, then see what those bits represent if we read them as weirdbinary. This forms a complementary pattern, which makes some intuitive sense.

So, getting back to Ken's question, is this useful for anything? Well, it might be kind of nice that you can represent negative numbers without using two's complement (which requires a fixed number of binary digits to work). I don't know if there's an "easy" way to count in weirdbinary, or to do basic addition and subtraction. 

Any thoughts?

FOLLOWUP: I have some smart friends on Facebook!  Jeremy pointed out that this "weirdbinary" system can be explained as being "Base Negative Two"... Wikipedia even mentions a polish computer that used it. I guess the term is "negabinary".

Scott pointed out Gray Code, another binary encoding system which has a lovely property that subsequent numbers only vary by one bit - clearly a win for making signal more robust and less prone to big error.