Friday, May 12, 2023

light mode bookmarklet

javascript:{ c = document.querySelectorAll("*"); for (var ii=0; ii < c.length; ii++) { var s = c[ii].style; s.background = "ivory"; s.setProperty('color', "black", 'important'); } console.log(); }

Friday, March 13, 2020

Deleting GNOME's hidden keyboard shortcuts

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1250

tl;dr - gnome has shortcuts that are installed by default and not visible in the control center. if setting a shortcut doesn't produce the desired result, it's likely that a hidden shortcut already exists and gnome is ignoring your "redundant" one. which is terrible UI design, but that's another story

to fix the problem, do something like: gsettings list-recursively | grep "\['6'\]" | while read schema key line; do gsettings set $schema $key "[]"; done leaving this here mostly as a note to myself for the next time i run into this

Monday, April 1, 2019

LibreOffice unable to select "English (USA)" - spellcheck not working

i was unable to use the spell checker in libreoffice 5.1.6.2 (and the problem appears intermittently with many versions). i'm using ubuntu 16.04, but the issue appears to be common on fedora and other ubuntu versions as well

not sure how common this bug is, but it's tough to track down so documenting it here

symptom:

  • spell check fails to find any problems
  • "Text Language" shows as "None"
  • sometimes other options can be selected, but they don't work and it falls back to "None"
  • clicking Style -> Edit Style -> Font -> Language, "English (USA)" is shown as an option, but it doesn't have an "ABC check" icon to the left

the fix:

  • make sure hunspell-en-us is installed (that's the ubuntu package name)
  • Settings -> Options -> Language Settings -> Writing Aids
  • "Hunspell SpellChecker" shows up as ticked
  • click Edit
  • "Hunspell SpellChecker" shows as not ticked
  • tick it
  • spelling works



in short, the UI appears to get confused and believes a tool is activated, but clicking edit forces it to reload the true state and you can actually activate it

good luck




Saturday, June 23, 2018

SimpleSSHD with android in 2018

i used SimpleSSHD for a couple of years to ssh from my desktop to my phone and copy pics and such back and forth it stopped working at some point (maybe last year), presumably due to an android update, and i finally tracked the issue down

find the IP and MAC addresses for the phone, and on the desktop run:

  • arp -s 192.168.xx.xx yy:yy:yy:yy
after that, ping and ssh should work again. my understanding is that an android update started blocking arp requests, so when the desktop tries to connect to the phone, it can't convert the ip address to a mac address and gives up





Monday, March 5, 2018

list locally installed maven dependencies

i posted the following question to stack overflow, but the Close-Vote-Ring tends to delete "niche" questions like this so i'm posting it here as well:
on my development machine i'm actively working on perhaps 20 inter-dependent maven projects, most of which get published to ossrh from time to time, and i also depend on many other projects from maven central i'd like to list the dependencies that have been installed locally as opposed to those that have been downloaded from a repository. i'm aware that mvn -U will check remote repositories for snapshot dependencies, but in many cases my versions aren't -SNAPSHOT is there a way to tell which dependencies have been installed locally ?
user JF Meier made the critical observation in a comment that there's a _remote.repositories file in the local repository. based on this, i came up with the following:
versions=$(mvn dependency:list -DoutputAbsoluteArtifactFilename -DoutputFile=/dev/fd/2 2>&1 1>/dev/null | grep -o "/.*/" | xargs -Ixxx grep -L "jar>central=$" xxx_remote.repositories) | grep -o ".*/"
and then i use that to copy the local artifacts to a remote machine for testing: rsync -aRvO $versions example.com:/ caveat emptor - the file format isn't a public api and includes the following
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.

Tuesday, January 30, 2018

load a java class with a different parent classloader

in the process of debugging issues with an incorrect classpath for the compiler api when run inside maven, i wanted to be able to create a duplicate instance of an existing object (that had been produced by a factory) by loading the class using a custom classloader with a different parent. it didn't fix the classpath problem, so i also tried loading directly by the path that i found, to no greater success my solution is somewhere between kludgy and elegant, so i wanted to publish it in case some other sucker goes down a similar road less traveled (and it doesn't deserve it's own repository), so here it is: public static void demoJailbreak() throws Exception { ClassLoader parent = Thread.currentThread().getContextClassLoader(); String jre = System.getProperty("java.home"); String jdk = jre.endsWith("/jre") ? jre.substring(0,jre.length()-3) : jre; JavaCompiler broken, byPath=null, compiler; try { byPath = (JavaCompiler) loadByPath( "com.sun.tools.javac.api.JavacTool", "file:" + jdk + "lib/tools.jar", parent ); } catch (Exception ex) {} compiler = ToolProvider.getSystemJavaCompiler(); broken = (JavaCompiler) jailbreak(compiler.getClass(),parent); System.out.println("jailbreak : " + broken); System.out.println("loadByPath: " + byPath); } /** * create a new instance of a class * using a new url classloader with a specified parent * and the same resource path as the original class instance */ public static Object jailbreak(Class klass,ClassLoader parent) throws Exception { String cname = klass.getName(); String path = getPathForClass(cname,klass.getClassLoader()); Object dup = loadByPath(cname,path,parent); return dup; } /** return the path at which an original classloader finds a class at */ public static String getPathForClass(String cname,ClassLoader orig) throws Exception { String rname = cname.replace(".","/") + ".class"; java.net.URL url = orig.getResource(rname); String full = url.getPath(); // need to split the jar url on an exclamation mark per: // https://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html String path = full.split("!",0)[0]; return path; } /** * create a new instance of a class by name * from a new classloader using a file:/path/to/jar style path * and the designated parent */ public static Object loadByPath(String cname,String path,ClassLoader parent) throws Exception { java.net.URL url2 = new java.net.URL(path); java.net.URL [] urls = new java.net.URL [] {url2}; ClassLoader cl = new java.net.URLClassLoader(urls,parent); Class klass = cl.loadClass(cname); return klass.newInstance(); } all static methods, no maven dependencies and shouldn't require importing anything, so cut and paste should work. note: this example will only work if you have a jdk installed (the compiler isn't in the jre), and the byPath version will only work if the jre path is "jdk_path/jre". that said, the jailbreak and loadByPath will work fine anywhere

Thursday, January 25, 2018

Integrating Spring with a legacy app

Spring is a behemoth and doesn't play well with others, preferring to take over all aspects of an application - inversion of control gone wild. The best bet is to avoid it entirely, but if you're stuck with Spring for whatever reason, and want to implement something non-trivial, you're likely to need to integrate it with non-spring POJO objects - what the Spring fan-persons call "Legacy Applications"

To inject a non-spring POJO into a Spring Boot application:

  • create an ApplicationListener
  • in the listener call registerSingleton with the non-spring object
  • register the listener with the app

this allows the field to be initialized early during the application lifecycle
@RestController @SpringBootApplication public class SpringLegacy { public SpringLegacy() {} @Lazy @Autowired @Qualifier("legacyBean") Object myBean; @RequestMapping("/dir") public Object dir() { return "hello world " + myBean; } static class LegacyObject {} public static void main(final String[] args) throws Exception { Object obj = new LegacyObject(); SpringApplication app = new SpringApplication(SpringLegacy.class); ApplicationListener lis = new ApplicationListener() { boolean first = true; @Override public void onApplicationEvent(ApplicationEvent event) { if (first & event instanceof ContextRefreshedEvent) { ((GenericApplicationContext) (((ContextRefreshedEvent) event).getApplicationContext())). getBeanFactory().registerSingleton("legacyBean", obj); first = false; } } }; app.setListeners(Arrays.asList(lis)); app.run(args); } }
full source is https://github.com/nqzero/spring-legacy
run the maven project, and then browse to localhost:8080/dir - you should see "LegacyObject" in the output

Thursday, November 16, 2017

java reverse proxy for websockets

this is easy to do with node:
https://github.com/nodejitsu/node-http-proxy

but with java it's proven much more difficult to find. just found this:
https://github.com/barrett-rob/java-websocket-reverse-proxy


haven't tried it, but looks like it will work


Saturday, February 13, 2016

save bash history remotely by sending a signal to all interactive bash

my bash history is an important resource and the primary way i record how i've solved problems. i use a unique file for each machine and store them in version control periodically

a problem that i run into every few months is i've solved a problem on one machine, but haven't yet exited from the shell so the solution is not stored in the history file yet. and i'm at a remote location, so i can't run "history -a"

solution


add the following to .bashrc


# safely append the bash history function .save_hist { exec 200<${HISTFILE} if flock -w 5 200; then history -a flock -u 200 echo "SIGHUP received, history file saved" else echo "SIGHUP received, but lock failed, history not saved" fi exec 200<&- } trap '.save_hist' HUP # signal all bashes function save_hist { # not no tty and user and bash (ps h -o pid -Nt - | sed "s/ //g"; pgrep -u "$USER" bash) | sort | uniq -d | xargs kill -HUP }
to use it, ssh into the machine and run "save_hist"
Note: this is semi untested and has the potential to kill background process (the ps arguments aren't documented perfectly). but it appears to work
Note: *all* shells to have been started since the bashrc change to work

how it works

i wanted to use SIGUSR1, but bash doesn't appear to trap that signal until the user presses enter. which defeats the purpose. SIGHUP isn't really intuitive, but it is used by some daemons to reload their config file, which is somewhat along the same lines. and afaict, interactive bash doesn't use SIGHUP for anything. i'm open to other suggestions

trap is used to catch the HUP signal and then run "history -a". i use flock since it's not clear that bash handles simultaneous saves safely, and i routinely have dozens of bash tabs open.

you can use kill directly to send the signal, but i wanted to be able to save all the active interactive shells. i couldn't find an easy way to list them, so i came up with listing everything with a tty, combining that list with the users bash instances, filtering for only duplicates, and passing those PIDs to kill. it seems to work

good luck, and let me know if you have any problems

alternatives

i posted this on [/r/bash](https://www.reddit.com/r/bash/) and got downvoted as usual. but [lihaarp](https://www.reddit.com/user/lihaarp) pointed out that you can set PROMPT_COMMAND. this saves the history after every command. i prefer my approach as it saves each bash instance in order, but it does mean you risk losing history if the computer crashes. ymmv

Sunday, January 31, 2016

vertical inches matter - 16:10 or better (3:2, 4:3) laptops, ie "real laptops" or "business laptops"



business laptops are generally pretty solid - tons of options for cpu, pixel density, memory, storage, graphics. but there's very little choice when it comes to aspect ratio - the vast majority of laptops for sale today (jan 2016) are 16:9. this translates to very short screens that are great for watching movies, but just aren't useful for doing real work.  in the hopes of encouraging sales, and hence production, of real business laptops, i'm going to maintain a list


  • HP spectre x2 - windows 10 convertible, 3:2, 12", core m, $800 (m5 6y54, 8gb, $950)
  • Lenovo miix 700 - $750, m3-6y30, 4GB ram, 64GB ssd, 12", 3:2
  • ipad pro - 4:3, 12.9", A9X cpu, 32GB, $800
  • macbook pro 13 retina - $1300, 13.3", 16:10, i5, 8GB ram, 128GB ssd ($1100 non-retina)
  • macbook air 13 - $1000
  • surface pro 4 - $900, 12", 3:2 aspect ratio
  • surface book - 13.5", 3:2, $1500
  • chromebook pixel - 3:2, 13", i5, 8GB ram, 32GB SSD, $1000 (i7/16/64/$1300)
  • samsung ATIV book 9 - 12.2", 16:10, 4GB ram, 128GB ssd, core m 5y31, $1300
  • panasonic CF-SZ5 - 12.1", 16:10, core i5, 8GB ram, 128GB ssd, $1400 (in japanese, so i'm guessing)
  • panasonic toughbook - more of a bulldozer replacement than a desktop replacement
  • Hp Pavilion X2 12 - 12" 3:2 1920x1280, Core M 4GB, convertible, $600
  • Thinkpad X1 Tablet - 12" FHD+ 2K (2160 x 1440) IPS, 3:2 - Core M - up to 16GB Ram - $999+(?) not yet released

edit: posted on reddit. thanks to SaneBRZ for the samsung and panasonic info

all of these machines have at least one major flaw. the macs are macs, the pixel lacks storage, most of them have touchscreens (pretty much useless) which are expensive, many of them aren't user serviceable (maybe the spectre and miix), the SZ5 doesn't appear available in the states, and overall they're all expensive. 16:9 business laptops are available for $250 with better specs. a better aspect ratio translates to more surface area for the display, hence higher cost, but only marginally so


vertical inches ... the surface book is 7.5", pixel is 7.2", macbooks are 7.05", my old lenovo x60 (4:3, 12") is 7.2", and a nominal business laptop (lenovo 14", 16:9, $250) is 6.86"

so the macbook air is $750 extra for .19" and the surface book is $1250 for .64". that's something on the order of $2000 an inch ... outrageous


Tuesday, January 19, 2016

accessing the command line in java


would be convenient to be able to define a main() in an abstract superclass and have it automatically "run" the subclass that java was invoked with. there's nothing builtin, but at least on linux this info is easy to get.  here's a simple demo


import java.nio.file.Files; import java.nio.file.Paths; public static void main(String[] args) throws Exception { // linux only, might work on windows // https://cygwin.com/ml/cygwin/2007-04/msg00817.html byte [] bytes = Files.readAllBytes(Paths.get("/proc/self/cmdline")); String [] text = new String(bytes).split("\0"); String klassname = text[text.length-1-args.length]; System.out.println(klassname); } if anyone tries this on windows, leave a comment if it works

Wednesday, January 13, 2016

Asynchronous Java webserver "Hello World" baseline

the TechEmpower plaintext benchmark (TEBM) attempts to give some rough measure of how a server (or framework) responds to the simplest of requests, and as such provides some guidance when configuring a server. however, most of the implementations are blocking (ie, use one thread per connection). i'm working on a demo for a database that i've written, and want to choose an appropriate server. the database:
  • is implemented in java and uses java methods (and lambdas) as the query language
  • uses the Kilim fiber library for high concurrency, ie imperative code is transformed into coroutines
  • is initially targeting low-end boxes, eg a VPS with limited cpu and memory resources, rentable for approximately $5 a month
  • is targeted at java developers that don't want the complexity of an enterprise environment
so i've reproduced something vaguely resembling the TEBM for a few asynchronous java servers, and a couple blocking implementations as a baseline, with a focus on simplicity and high concurrency, each implemented as an embedded server:
  • Jetty blocking
  • Undertow blocking
  • Jetty Async (servlet)
  • Kilim Async - a simple http server that's part of the library
  • Comsat Async - a Quasar (another fiber library) shim that integrates with a Jetty servlet
  • Undertow Async (native)
i also looked at spark-java, but the performance wasn't comparable so i haven't included it here

my test machine is a i3 at 3100Mhz with 16GB. memory didn't appear to be an issue. the test client is ApacheBench. the servers and client are run with "ulimit -n 102400", and i've used sysctl to get 64000-ish available ports. i would run each server and sweep the AB concurrency from 1000 to 20000, each AB test running for approximately 10 seconds, for a total of 40 million requests for each server (half timed, half warmup). i then waited for 60 seconds to account for any delayed effects. throughout, i crudely monitored cpu usage. keep-alive was used (without it, the connection time dominated the performance). the tests were run many times to eliminate problems and develop an understanding of the performance, but in the end only 3 sweeps for each server were needed to get "good" data

source code for the embedded servers and some scripts used for testing:
https://github.com/nqzero/jempower

Async:

the async servers are truly async, not solely using the async APIs. for Undertow and Jetty, the request stores the request in a queue, and a worker thread (or 3) services the queue periodically and sends the response (during extensive searching i did not find an example of this behavior online). for Comsat Jetty, Comsat provides a shim that does the equivalent of the queuing, and the userspace handler runs as a fiber, ie it yields when a blocking operation is performed. Kilim Http is entirely fiber-based, ie even the network code is non-blocking. both Comsat (Quasar) and Kilim transform imperative code into fibers / coroutines by weaving the bytecode

in all cases, the async server handlers are sleeping before responding, and a single thread is responding to 1000s of connections

Results:

the chart below shows the concurrency sweep. the left axis is median requests per second, the right is max (over 3 sweeps) failures. at 20000, undertow-async is all over the place, so don't read too much into the specific number (see the discussion below). here's an interactive version of the chart



Discussion

Undertow, both blocking and async, excelled at absolute throughput at low concurrency (consistent with the TEBM). At higher concurrencies (both sync and async), undertow exhibited 2 issues - "receive failures" and long periods (10-20 seconds) of max-cpu when the sweep finished. neither of these is mentioned in the TEBM. In addition to these problems, the documentation for undertow was limited (i'm waiting on some more feedback from the mailing list) so i'm not planning on going further with this server

Jetty performance, for both blocking and async, was a very nice middle ground - decent low-concurrency performance and a graceful falloff at higher levels. the cost of using async was about 15% across the range (at lower concurrency my async implementation sleeps a little too long to saturate the connection, but that's an artifact of the highly artificial use of async)

Comsat added a substantial overhead on top of async Jetty, and exhibited some failures at high concurrency. i've tried several different implementations based on the documentation and code from TEBM, and all performed about the same

kilim performance was competitive with Jetty, especially at high concurrency and kilim has some nice properties - true fibers (like comsat) so handlers are simple to write, the server itself is fiber-based (unlike Comsat) so blocking IO isn't a problem (async IO can be used in Jetty, but is a pain). however, the server is fairly primitive feature-wise, so at the least another server would be needed to proxy it. i have a working integration with my database that's very elegant, and i'll keep that, but want to add a more versatile server as well

Conclusions

  • Kilim offers competitive performance and the advantages of a true fiber-based server
  • Jetty Async offers a good mix of features, performance, and ease of use
  • Comsat performance was underwhelming, but the ability to shim fibers with servlets isn't (i haven't looked at the source, but my understanding is that it's a pretty simple and elegant hack) and i may investigate using Quasar in my database
  • undertow seems very capable, but isn't accessible to non-experts (or at least, not to me)
i'll be using Kilim and Jetty for my demo

Caveats

  • i'm not an expert
  • ApacheBench doesn't rate-limit connections, so the results aren't necessarily apples-to-apples (ie, faster servers get worked "harder")
  • at least the undertow handlers could saturate ApacheBench at low concurrencies, and running a second instance of AB increased throughput (120000 requests per second). not the focus of this study, so the results above use only a single AB
  • pull requests are welcome (though part of my need is for my demo to be easy for potential users to understand, so i probably won't integrate solutions that greatly increase complexity)



Friday, January 8, 2016

sudo absolute path within script - bash, linux, ubuntu

inside a script, sudo does something weird with the path used to execute it's command argument. this is on a default install of ubuntu - not sure if the sudoers file affects it. i'm not talking about the path that the command sees in its environment, but the path used to find the command to run


  • sudo: cmd_on_my_path: command not found


this is counter-intuitive, but i guess makes sense if i think about it enough - sudo only sees the command name, not the full path, and presumably for security they don't want to respect $PATH

but in the case in which the user has full sudo rights, i don't see how this helps anything. so in my script i've replaced "sudo myCommand" with:

  • sudo "$(which myCommand)"
not enough of a guru to know if this is perfect or really safe, so buyer beware. but wanted to post something - doesn't appear to be a good answer available via google

Tuesday, December 29, 2015

caffeine, theobromine and theophylline content of coffee, tea and chocolate



http://www.caffeineinformer.com/caffeine-content/coffee-beans

hershey's cocoa powder, per T (5g powder): 8.4 mg caffeine, 106 mg theobromine
espresso, 1.5oz shot (7g beans)
starbucks drip coffee, 8oz: 165 mg caffeine
coffee beans: 6 mg per bean (300-330 mg, from wp)


used coffee grinds: 41mg per 7g of beans used, 4-8 mg per g (depending on method)
8oz brewed coffee (amount of bean unspecified): 145 mg drip, 108 mg french press

black tea, 8oz liquid (1 tea bag): 42 mg, 55mg for lipton, 4g theobromine (WP:tea)

yerba mate, 8oz: 85mg





wikipedia:

caffeine metabolites:


  • Paraxanthine (84%): Increases lipolysis, leading to elevated glycerol and free fatty acid levels in blood plasma.
  • Theobromine (12%): Dilates blood vessels and increases urine volume
  • Theophylline (4%): Relaxes smooth muscles of the bronchi, and is used to treat asthma. The therapeutic dose of theophylline, however, is many times greater than the levels attained from caffeine metabolism

43g of 45% hershey's cacao --> 31 mg caffeine (guessing 8-10g cocoa)
  • this is twice what CI says for cocoa
Tea contains small amounts of theobromine and slightly higher levels of theophylline than coffee
tea also contains ... https://en.wikipedia.org/wiki/Theanine


theophylline: Amounts as high as 3.7 mg/g have been reported in Criollo cocoa beans




http://helios.hampshire.edu/~nlNS/mompdfs/TeaTheoph.pdf

tea: 1mg theophylline per 5oz cup black tea



http://www.ncbi.nlm.nih.gov/pubmed/6396642
cocoa: .21% caffeine, 1.9% theobromine




http://chromsci.oxfordjournals.org/content/45/5/273.full.pdf


Powder from roasted ground paste: 6.0% theobromine, .2% thoephylline, .8% caffeine
assuming that this includes the butter, as the caffeine number matches cocoa powder 2:1

so cocoa: 12% theobromine, .4% theophylline







Thursday, December 24, 2015

at&t mvno "pay as you go" data plans

looking for a GSM plan for USA

  • data on a per MB basis
  • low monthly costs
  • AT&T network
  • willing to buy in $100 increments
  • byod
  • plan info available in english


wikipedia maintains a list and i went thru each entry for AT&T, and also googled a bit - ignoring plans with high per month minimums (ie if an operator didn't offer a plan under $30 per month they're not listed here). plans / prices as of december 24, 2015:

  • h2o - $100, 1 year service, 5¢ per min or sms, 10¢ per MB or mms
  • black - $100, 1 year service, 5¢ per min or sms, 10¢ per MB or mms
  • tracfone - $140 per year for service/voice,  plus 1.5¢ per MB, terms are somewhat confusing
  • consumercell - $10 per month service, plus $10 per month for 500 MB, additional data at 25¢ per MB, means that effectively you need to pre-purchase data (uses T-mobile too)
  • airvoice - $30 per 5 months, $1 per month, 10¢ per min/sms/mms, 6.66¢ per MB
  • at&t - go phone, $2 per day but claims (unconfirmed) only charged if voice/sms is used, $1 per 100 MB
  • jolt - $15 per month for service/30MB, additional data at 50¢ per MB





and for t-mobile:
  • ting - billing is confusing (buckets), could do data-only for $6 per month service, plus $12 for 500 MB (next bucket is $19 for 1 GB)
  • campus - sketchy, $25/month includes 500 min, unlimited sms, 500 MB. details lacking
  • tempo - $70, 1 year service, 7¢ per min or MMS, 2¢ per sms, 14¢ per MB
  • lyca - $19 per month, unlim voice/sms, 100 MB data, not clear if you can buy more data
  • net10 - not clear that any "cheap" plans include data
  • proven - confusing, $25 per month includes 750 min, 250 sms, 100 MB
  • ptel - $60 per year service, 5¢ per min, 2¢ per sms/mms, 10¢ per MB out of business
  • simple - $20 per month data-only, includes 1.5 GB
  • ultra - $19 per month, unlimited talk/text, 100 MB (not clear if you can buy more)
  • usmobile - $16 per month, including 1 GB (talk+text is extra, but reasonable)



took a look at verizon:

  • callmr - $17 per month including 500 MB, plus 5¢ per min/sms/MB (or $20 for 1 GB)
  • pageplus - 50¢ per month, plus 5¢ per min/sms, 10¢ per MB (cannot activate 4g device)
  • envie - $25 per month, includes 500 min, unlim sms, 1 GB (lte)


Friday, September 4, 2015

dynamic DNS on DD-WRT won't update after power up / boot

my setup is a dsl modem with a DD-WRT based buffalo router, configured to use DDNS to connect to dyndns.org. i've tried the modem in both bridge mode and router mode. after a cold start, ie after both the modem and router have been powered down and the phone line disconnected, the IP address doesn't always get updated and the "DDNS Status" log shows:
Thu Jan 1 00:00:50 1970: INADYN: Started 'INADYN Advanced version 1.96-ADV' - dynamic DNS updater.
Thu Jan 1 00:00:50 1970: INADYN: IP read from cache file is 'xx.xx.xxx.xx'. No update required. 

the problem appears to be a race condition between the new IP address being assigned and the DDNS check (the "thu jan 1" date suggesting the time of day hasn't updated either). a fix is suggested by:

http://www.dd-wrt.com/phpBB2/viewtopic.php?p=886044
Go to: Administation-> Management 
In Additional Cron Jobs write: 
*/10 * * * * root /usr/sbin/inadyn /tmp/ddns/inadyn.conf > /dev/null 2>&1 

which runs the inadyn command every 10 minutes using cron. i've just applied/saved this setting. the DDNS updated immediately after applying this. since the problem was intermittent, i can't know if it's solved. if the problem reoccurs, i'll update this post


edit 2018.01.24:

i ended up disabling the cron job years ago, i believe because i was worried about the logs filling up memory. or perhaps because it resulted in multiple inadyn processes running. at this point, i'm still not sure if it ever really (since the problem is so intermittent) worked

i just disabled the external ip check

but i understand the fundamental issue better now than i have. inadyn is running, but failing to recognize that the cached value differs from current value. there's a verbose option for the config file, but i don't currently have it enabled (the UI doesn't have an option for it). i believe that there's a way to use the nvram tool to manually fix it, ie without the UI, but i haven't delved into it yet

good description of how to force inadyn to restart shortly after booting (to allow it to pick up the correct ip address):
https://www.dd-wrt.com/phpBB2/viewtopic.php?p=70161



an unrelated issue is that the sshd running on the router only supports a no-longer-current encryption method and ssh by default refuses to connect, so need to use a workaround

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 root@192.168.11.1


(i provided a public key, but it's likely that this would work for password-based login too)




Monday, April 20, 2015

a tale of two tunnels, in which iptables proxies a bridge

poor man's VPN for android emulator
  • genymotion
  • running on virtualbox
  • running on an ubuntu linux host
  • redirected thru a transparent proxy on the host
  • routed thru an ssh tunnel to a remote server (nqzero.com in the examples)
  • iptables based masquerade for NAT
i thought this should be pretty simple, but it ended up being a couple days of work, so documenting it here. i'm not a networking guy, so most of this was trial and error based on google searches

on both the host and the remote machines:
  • sudo cp ~/.ssh/authorized_keys /root/.ssh
  • set in /etc/ssh/sshd_config
    • PermitTunnel yes
    • PermitRootLogin without-password
on the remote machine (venet0 is my connection to the LAN):
  • echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
  • sudo iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
  • sudo iptables -A FORWARD -i venet0 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  • sudo iptables -A FORWARD -i tap0 -o venet0 -j ACCEPT
  • sudo ifconfig tap0 192.168.0.1 netmask 255.255.255.0 up

on the host:
  • ssh -C2qTnN -D 8082 nqzero.com
  • sudo ssh -i ~/.ssh/id_rsa -o Tunnel=ethernet -f -N -w 1:0 root@nqzero.com
  • sudo ssh -i ~/.ssh/id_rsa -o Tunnel=ethernet -f -N -w 0:2 root@localhost

  • sudo brctl addbr br0
  • sudo brctl addif br0 tap2
  • sudo brctl addif br0 tap1
  • sudo iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 8888
  • sudo iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 8888

  • proxychains mitmproxy -p 8887
  • proxychains mitmproxy -T --host -p 8888

  • sudo ifconfig tap0 0.0.0.0 up
  • sudo ifconfig tap1 0.0.0.0 up promisc
  • sudo ifconfig tap2 0.0.0.0 up
  • sudo ifconfig br0 192.168.0.5 netmask 255.255.255.0 up
virtualbox:
  • adapter 1: unchanged (host-only, vboxnet0)
  • adapter 2: bridged adapter, tap0
~/.proxychains/proxychains.conf: socks5 127.0.0.1 8082

genymotion.android.settings.wireless.proxy: 192.168.56.1, 8887

my intuition was i could have virtualbox bridge directly to br0 (and omit the local tunnel entirely). packets got sent to the remote tunnel correctly, but i couldn't get iptables to redirect them, so i added the local tunnel. at that point, iptables was pulling the packets from the bridge, but not routing them anywhere, they just silently disappeared. to fix that, i added the bridge IP and zeroed out the tunnel endpoint IPs, and everything worked (i read this advice several places, but don't understand why it works)

i use 2 proxies, both of which pass data over the ssh connection to port 8082
  • 8887 port uses the proxy mechanism provided by android
  • 8888 is a transparent proxy to catch anything else (i'm trying to document an api)
non-http/https stuff is passed thru the tap1 tunnel
  • monitor with: sudo tcpdump -vvvnni tap1
  • nothing should leak out thru the local network
Notes:
  • must be 1 (ubuntu default): /proc/sys/net/bridge/bridge-nf-call-*
over the bridge and through the two tunnels
to genymotion's house we go
iptables knows the way to proxy the packets
thru the virtual and private network



Sunday, June 8, 2014

java apidocs for websockets

working thru the websocket examples in tomcat 8, and realize that i don't have javadocs for the javax.websocket stuff. this is a chronic annoyance with java - you're using interfaces that are pretty "standard", and they turn out to live in javaEE. and the apidocs are licensed in a way that platforms that implement the standard can't include the apidocs. so you're left with a lobotomized IDE with zero javadocs. it's dumb

for tomcat 8, netbeans 8 and the websocket and servlet stuff:

oracle is evil ...
  • apidocs for standards should be liberally licensed
    • this is "embrace, extend and extinguish" in all it's glory
  • websockets and servlets don't belong in javaEE, they're standard web technologies

Wednesday, June 4, 2014

netbeans "package does not exist" error -- maven considered harmful

upgraded to netbeans 8 and found a bunch of cryptic errors in my projects:
package XXXXX does not exist
in this case XXXXX was a package provided by another netbeans project. it does indeed exist, the jar is being built properly and compiling the "broken" project succeeds and the application runs. so this is purely a problem with netbeans parser / indexer. i tried removing the dependency and re-adding it, cleaning and rebuilding, and exiting netbeans, removing the cache and restarting. nothing helped

looking thru messages.log, i see
WARNING [org.netbeans.modules.java.source.indexing.JavaIndex]: Ignoring root with no ClassPath: /home/YYYYY/working/nq0/XXXXX/XXXXX.git/src
didn't find much mention of that warning on the interwebs. looking at the "project properties" page for the project i realized i'd seen this problem before and started fiddling

the problem is that buried in the XXXXX directory, there's a pom.xml. netbeans detects this and somehow modifies how the project is managed. it's a "project with existing sources", not a maven project. but somehow netbeans fails to honor that when it finds a pom.xml

my solution was to deactivate the maven plugin (why that gets installed in the first place is beyond me). which eliminates the issue (i reactivated it temporarily to verify that that was actually the problem). this happened when i upgraded to netbeans 7, and i'm sure this will happen again when i upgrade to 8

maven is terrible, and the plugin makes it worse. it's the wrong metaphor for managing dependencies

Ivy Bridge integrated graphics corruption, small groups of braille-like dots, giving a snow-like appearance

for the last 10 years i've used AMD-based computers that i "built" myself, replacing the mb/processor/mem a bunch of times. for my last upgrade, i switched to intel. i've got 2 similar systems, both with core i3s, one 2105 and the other 3220, both using the integrated "Intel HD Graphics". i run ubuntu linux. after 6 months, the 3220 system started to display a visual glitch. i described it first here: i'd get a shifting pattern of dots overlayed on top of the windows. the dots show up in a screenshot, suggesting that the problem is with the cpu/mb/mem

at first, the problem was manageable - the dots rarely obscured what i was reading and the machine never crashed. i wasn't sure if the problem was hardware or something that ubuntu was doing, so i lived with it and in some ways even liked it, in a "ghost in the machine" sort of way. but over the next year the problem got somewhat worse and at this point the problem had persisted thru several ubuntu versions (including a clean reinstall that i'd done for the sake of seeing if some configuration change i'd made was part of the problem), so i was forced to track down the cause


i "live chatted" with intel support and they told me to run the intel processor diagnostic tool. the standard tool is windows-only, but they include a link to a fedora15-based liveUSB version. the instructions seemed cryptic to me, the utilities were ".exe"s, possibly directed to windows users (though why they wouldn't just use the standard tool ???) and the intel support team stated:
Alberto: the thing is that we are not that familiar with Linux

so they were useless. tl;dr - it took me (much) longer than it should have to run the tool. but eventually i got it running, the "snow" still appeared (ie, the fedora15 system exhibited the glitch), but the tool reported that all tests passed, ie the tool was useless (it didn't verify that the generated images matched the desired values). fwiw, here's the easiest way i found to use the tool:
  • download the iso (eg, this one)
    • i'll call it ipdt.iso for simplicity
  • insert a usb drive (i'll call this /dev/sdX)
    • we're going to overwrite the drive, so *all data* on it will be lost
    • if it automounts, unmount it
    • in my case, it was recognized as /dev/sdd
  • dd bs=4M if=ipdt.iso of=/dev/sdX
  • insert the usb drive into the target computer and boot from it
    • most modern systems support boot-from-usb. if yours doesn't, maybe you could burn a cdrom ???
  • fedora should boot up
  • open up a terminal and type (for a 64bit system)
    • install64
    • click the "ipdt" icon on the desktop
next, intel suggested i swap CPUs between the 2 systems. i did this and the problem (ie the "snow") followed the 3220. the 2105 CPU showed zero symptoms in either machine. at this point, intel agreed that the CPU was probably faulty and they've presented me with two warranty options

  • Standard Warranty Replacement: This is when you send the processor first to us, and then once we receive it, it takes 5-8 business days for you to receive the replacement processor.
  • Advance Warranty Replacement: This is when we send you the processor first, and then, once you receive it you just need to send your defective processor back to us. There is a fee on this option, $25, not refundable, that covers the overnight shipment of the processor to you, and also it covers the shipping for you to send the defective processor back to us. And also for security reasons, we are going to charge the price of the processor to your credit card, just in the meantime, as soon as we get your defective processor we will do a refund for that amount.
those are both pretty horrible options. this is *intel's* poor workmanship resulting in me living with a minor annoyance for over a year, ultimately forcing me to spend 2 work days tracking down the problem, their diagnostic tool failed to detect *any problem*, and now they want me to pay $25 to replace it or else live without a working computer for on the order of 2 weeks. pretty ridiculous

grrr intel. but whatever. they're a monopoly and i don't have much choice. maybe next upgrade cycle i'll go back to AMD (if intel hasn't driven them to bankruptcy yet). i submitted the serial number they requested and am waiting on shipping info






Friday, March 14, 2014

books to read next 2014 edition

note to self ... keep a list of books to read (or reread) here the bell jar frankenstein

Monday, March 3, 2014

ubuntu 13.10 + unity + libreoffice mnemonics == FAIL

ever since ubuntu switched to unity, mnemonics (eg, alt-f to open the File menu) have been a disaster. 13.10 and LibreOffice are perhaps the worst offenders ... mnemonics don't work *at all*

This ubuntu bug report has been open for 3 years with no progress. At various times, mnemonics have worked briefly with some magic ever changing invocation, perhaps installing lo-menubar or some specific version of LO not in the repository. The bug report is labeled "High Priority", but is Unassigned (does that mean "high priority to no-one"). With 13.10 i don't believe that there is any way to make the unity integrated menus work correctly. There is some chatter online that 14.04 will bring menu bar sanity, but i haven't seen anything explicitly mentioning mnemonics

The LibreOffice bug report is closed as NOTOUTBUG, because someone once heard that someone else thought it was a generic Gnome problem. no link to another bug report, roadmap to a fix, no comment from the 2nd hand source, nothing. way to take responsibility. though in general, i'm all for blaming Gnome because *fuck those guys* for forcing gnome-shell on us and it probably is their fault

The workarounds that are proposed are



I haven't tried the first option - it seems pretty drastic since unity is the *recommended* way to use Ubuntu. I'm more inclined to switch to Mint, but that too seems pretty drastic. The second option is completely unusable (and i've tried multiple versions and sources of LO). My current approach is to purge libreoffice and install openoffice (untar and dpkg -i *.deb). OpenOffice seems usable

Evince and some other apps have shown similar issues, but so far i've managed to live with them. Maybe one of them will eventually force me to Mint or to uninstall Unity

tl;dr
As shipped, Ubuntu 13.10 doesn't have a usable office suite, which is one of their key features. I can understand Free Software being buggy, but the false advertisement of claiming things are working is bullshit

Get things done

We understand how important your computer is for day-to-day tasks. Whether it's finding information online, sending emails to colleagues and friends, or creating and sharing documents, Ubuntu has everything you need to get things done. Fast.



I guess they don't mention "use a keyboard". Assholes




Friday, January 31, 2014

ubuntu 13.10 libreoffice menubar lossage

it's 2014 and ubuntu still doesn't have a usable libreoffice package - out of the box, the menubar shortcuts (or mnemonics) don't work. pressing "alt-f" has no effect, the file menu fails to activate, nothing. this is *the* office suite on linux, the most critical package for a business user, lacking perhaps the oldest and most-used metaphor for interacting with a gui

freedesktop calls it "NOTABUG", ubuntu doesn't seem interested in fixing it (no-one is assigned after almost 3 years), and anyone that posts on askubuntu gets closed as "offtopic" with a snarky comment. for now, the options available are:
  • uninstall libreoffice-gnome, leaving an ugly interface that doesn't maximize correctly
  • uninstall libreoffice entirely using apt and install the package from freedesktop.org (or maybe from a ppa) ... i haven't verified that this works, but there are some reports that it does
in 2010 when ubuntu introduced unity i understood that it was a new endeavor and expected some rough edges. but even then, this bug seemed egregious ... we're now up to ubuntu 13.10, unity is no longer new, and we still don't have usable shortcuts for libreoffice menus

Tuesday, January 14, 2014

books to read

just keeping a running list here for my own sake wharton watershed down

Monday, October 21, 2013

lightdm invalid session - screen blanks and greeter restarts

in the process of reinstalling ubuntu raring 13.04 (or possibly during the initial upgrade to 13.04 from 12.10) lightdm got confused. it would display the greeter, i'd provide my password and then it would attempt to start my session, ie the screen would go momentarily black. but instead of starting unity, it would fail and restart the greeter. i don't have any of the old logs, but i believe the message was to the effect of "invalid session: xterm". (i believe that i set this session fucking around with settings, but it could also have been an valid session that has since been deleted - when i reinstalled i omitted many packages)

the greeter didn't give an option to choose a session, so i had to talk to dbus directly (which may very well be how i got in trouble in the first place:)

# list the sessions (ignore the .desktop suffix) # note: they might not all be valid, eg because the software hasn't been installed ls /usr/share/xsessions # get the dbus name for the current user user=$(dbus-send --print-reply=literal --system --dest=org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.FindUserById int64:$(id -u)) # set the session (replace ubuntu with another valid session if desired) sudo dbus-send --print-reply --system --dest=org.freedesktop.Accounts $user org.freedesktop.Accounts.User.SetXSession string:'ubuntu' lightdm should really provide a means to select your profile. by default, it doesn't if there's only one valid session. however, the session that it uses is the "current session", ie the one that it gets from dbus, which might not be the valid session. little bit of catch-22. in theory, i should submit a bug report. in reality, canonical will sit on it for 7 years regardless, so fuck em

Friday, September 20, 2013

clone root partition via rsync (to handle 512 vs 4k sector size)

my root partition is failing, giving random io errors during boot. it's a 5 year old 180G hdd using 512 byte sectors. the modern replacement is a 1TB hdd with 4096 byte sectors. so a straight up dd isn't an option. need to do a file by file copy instead mount /dev/sdc1 /mnt # -x limits rsync to a single partition rsync -avxHSAX / /mnt/ for ii in /dev /dev/pts /proc /sys /run; do sudo mount -B $ii /mnt$ii; done sudo chroot /mnt grub-install --recheck /dev/sdc update-grub # label the partition for use in fstab e2label /dev/sdc1 mylabel blkid -c /dev/null gedit /mnt/etc/fstab the error messages are somewhat cryptic. from syslog: ata2.00: exception Emask 0x0 SAct 0x4 SErr 0x0 action 0x0 ata2.00: irq_stat 0x40000008 ata2.00: failed command: READ FPDMA QUEUED ata2.00: cmd 60/08:10:d7:00:19/00:00:0b:00:00/40 tag 2 ncq 4096 in res 51/40:08:d7:00:19/00:00:0b:00:00/40 Emask 0x409 (media error) ata2.00: status: { DRDY ERR } ata2.00: error: { UNC } ata2.00: configured for UDMA/133 sd 1:0:0:0: [sda] Unhandled sense code sd 1:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE sd 1:0:0:0: [sda] Sense Key : Medium Error [current] [descriptor] Descriptor sense data with sense descriptors (in hex): 72 03 11 04 00 00 00 0c 00 0a 80 00 00 00 00 00 0b 19 00 d7 sd 1:0:0:0: [sda] Add. Sense: Unrecovered read error - auto reallocate failed sd 1:0:0:0: [sda] CDB: Read(10): 28 00 0b 19 00 d7 00 00 08 00 end_request: I/O error, dev sda, sector 186187991 ata2: EH complete and fsck shows some errors, eg "Attempt to read block from filesystem resulted in short read" and some unattached inodes
using rsync to clone
installing grub via chroot

Friday, April 12, 2013

MapDB (aka jdbm3++) first look

took a quick look at mapdb today (which is jdbm3++)

looks promising, but not the holy grail

CONS: appears to require a max size on keys. kind of a pain to setup. examples and benchmarks appear very simple. believe it's using mmap (which is fundamentally limited). appears to be a single thread for writes and a thread per read ???

PROS: appache2 license, java interface

i didn't investigate the internals much, in particular the mvcc


Thursday, April 4, 2013

ubuntu 12.10 unity ivy bridge visual glitch

have been running ubuntu 12.10 on ivy bridge for months. last night i started getting weird visual artifacts - looks like a braille patterns superimposed on the screen ...



anyone seen anything similar ?


update: if i leave glxgears running in the background the patter disappears and doesn't come back. also found an *old* post about something similar

Monday, March 18, 2013

webstorm 6 lossage

still experimenting with webstorm and it seems that the underlying javascript language model is pretty good, but the interface is failing to expose some important aspects, crippling the IDE. hoping that things will improve in the 7.0 cycle

the best indication that the language model is working is that for a js file that's been properly jsdoc'd

  • for prototype methods, webstorm displays up and down arrows in the left margin which list (and navigate to) the super and subclass method implementations
  • for most method calls, 'go to declaration' navigates to the correct method (as defined by the jsdoc comments)
taken together this shows that webstorm is modeling the underlying javascript quite well. based on this knowledge, it should be able to implement the standard navigation that IDEs provide for java. however, the UI fails to expose these features
  • 'find usages' and 'rename'
    • list method calls in any object with the same method name
      • should filter by reverse mapping (ie, the one that 'go to declaration' uses)
    • don't have the option to sort by order in the file - iterating the list results in a non-monotonic walk of the documents
    • ignore method implementations with the same name in sub and super classes, ie methods that are overridden or override
      • should find (or have the option to find)
      • rename *must* rename all implementations and causes hard to track down issues when it doesn't, ie it loses the relationships that the model had established prior to the rename (thank god for git)
  • 'go to super method' does nothing (same mapping that is used to provide the up arrow in the margin should be used)
in spite of great promise, the refactoring capabilities are hobbled - i find myself reading in webstorm and switching back to netbeans to do renames since the webstorm versions are destructive and simple text based replacement is superior in many cases

a few other failings
  • no easy way to type unicode characters (in most apps on ubuntu, control+shift+u captures a unicode hex value, eg ᵩ is u+1d69)
  • display of unicode characters using a monospace font aren't monospaced, eg:
  • macros suck, eg scrolling up or down 10 lines is very slow and problematic
planning on buying 6.0 in the hopes that things will improve during the 7.0 cycle (licenses include updates for 1 year)

Thursday, March 14, 2013

the genius of unicode in javascript identifiers

intellisense for javascript sucks !

i've used recent versions of webstorm (jetbrains javascript IDE) and netbeans, and older versions of eclipse and a few others. and i've googled and read extensively - as far as i can tell webstorm has the best support for javascript code understanding (netbeans used to be a close 2nd, but the latest nb7.3 version has been a step backwards and ws6 is a step forwards - leaving a gap)

but even in webstorm it sucks. for the most part 'find usages' just does a text search - it can't distinguish between 2 methods with the same name in unrelated prototypes, even in the simplest cases with enough jsdoc annotations to make it unambiguous. 'go to declaration' works some of the time, but still fails often in cases where plenty of information is available

i spent some time submitting bug reports, trying new IDEs, annotating extensively with jsdoc, refactoring my code to be easier to parse, etc. to little effect and i've ultimately accepted that the only way to be able to reliably navigate in javascript code is by using unique indentifiers

i tried a number of schemes

  • long java-style names, eg setDayOfWeek
  • various prefix schemes using the same prefix for all methods in a prototype, eg for the ViewDiary prototype i might have vdSet and vdMerge or vd_set and vd_merge
  • various suffix schemes similar to the prefixes
long names are ugly, harder to read, and didn't really provide much uniqueness. prefixes are ugly and make code completion a pain ... typing 'set<tab>' didn't provide any options, i needed to remember the prototype prefix to get anything useful. underscore-based suffixes worked the best - they're ugly, but don't harm code completion

taking the suffix idea to the 'logical' extreme, i switched from _XX suffixes to unicode suffixes. a single unobtrusive character (i mostly use subscripts) that a human hardly notices when reading, but allows the IDE to keep everything unique
/** * state representation of a nu.FoodList * @constructor * @augments nu.Stateᵧ */ nu.Stateᵧ.Listᵧ = function() { this.replyᵧ = null; this.termᵧ = null; this.startᵧ = 0; this.kfoodᵧ = 0; this.derivedᵧ = false; this.jumpEndᵧ = false; }; nu.Stateᵧ.Listᵧ.prototype = { setᵧ: function(term,start,kfood) { this.termᵧ = term; this.startᵧ = +start || 0; this.kfoodᵧ = +kfood || 0; return this; } }; they're easy to read, compatible with completion, and easy to keep unique. both webstorm and nb7.2 handle them elegantly - find usages and go to declaration work great. the downside is that they're a pain to type without completion (i copy/paste)

unfortunately, chrome devtools won't do completion with object properties that contain non-ascii characters. firebug works fine

Note: not all unicode characters are valid in javascript identifiers, here is one validator

update - bash support

by default my inputrc (ubuntu 12.10 with gnome classic) doesn't appear to support unicode copy or paste, ie bash doesn't work !!! i needed to enable support for meta characters ... echo " set input-meta on set output-meta on set convert-meta off " >> ~/.inputrc bind -f ~/.inputrc most of the ubuntu apps, eg gnome-terminal and gedit, appear to support typing unicode characters with shift+control+u followed by the hex value of the character and space or enter. unfortunately, neither webstorm nor netbeans support this interface, meaning you need to copy and paste the character from some program that does support them, eg the gnome character map

for a full list of the unicode characters, install the ubuntu unicode-data package or download the raw list

Tuesday, February 12, 2013

stormvz virtual private server

purchased my first VPS today from stormvz.com. lowendbox promo - 3G memory for $7. figured it was worth trying out

purchase and the initial setup were painless. but actually getting anything done has been challenging. it comes with ubuntu 12.04 and runs openvz. the base install seems mildly broken. out of the box, sudo doesn't work, maybe i'm just supposed to use root for everything ?


NOTE: replace XXXXXX, YYYYY.YYY and ZZZZZ with the password, domain name and username respectively
as root on the VPS: useradd admin useradd -m -s /bin/bash ZZZZZ usermod -a -G admin ZZZZZ chmod u+s /usr/bin/sudo passwd ZZZZZ apt-get update apt-get dist-upgrade apt-get install mysql-server mysql -p --user=root # GRANT ALL ON *.* TO ZZZZZ@localhost IDENTIFIED BY 'XXXXXXX' locale-gen en_US.UTF-8 update-locale LANG=en_US.UTF-8 from my normal machine: scp .ssh/id_dsa.pub YYYYY.YYY: scp -r .bashrc .bash_profile .bash_logout YYYYY.YYY: scp hackpath hackpath-setup interactive-shell path-setup YYYYY.YYY:.bash as ZZZZZ on VPS: mkdir .bash mkdir -p .ssh/keys cat id_dsa.pub >> .ssh/authorized_keys mv id_dsa.pub .ssh/keys/takashi.pub sudo apt-get install tomcat6 nano tomcat6-admin sudo apt-get install openjdk-7-jdk sudo update-alternatives --config java sudo nano /etc/tomcat6/tomcat-users.xml # # # sudo nano /etc/defaults/tomcat6 # JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 i wanted a recent java and had trouble installing - the download required cookies and javascript, couldn't figure out how to make lynx work with it (text mode only on the server). so got the download link in the chrome developer tool on my desktop and used wget on the server (obv the auth param isn't good any more) wget "http://download.oracle.com/otn-pub/java/jdk/7u13-b20/jdk-7u13-linux-x64.tar.gz?AuthParam=1360726523_769def7b8d2a7f7025ec36b0075716ec"

Friday, February 8, 2013

sunshine on the north coast

what is the lowest angle of the sun at which the body can produce vitamin D ? production requires UVB radiation, which is filtered by the atmosphere (most solar radiation is UVA which doesn't help), so it's reduced during the winter

  • this "dr" says 50 degree altitude angle
  • this link suggests that you can make vitamin D in atlanta (34 degrees north latitude) during the dead of winter
  • this page (sketchy sounding url but with legit sounding citations) says 34 degrees north (ie, atlanta-ish again)
this page converts latitude and time to the angle of the sun. 34 degrees latitude maps to an altitude angle of 32.6 degrees at solar noon on the winter solstice. the southern tip of lake erie is 41.38 latitude. the first solar noon that reaches the 34 degree equivalent is feb 5th (33 degree altitude angle)

note: if the 50 degree altitude angle is correct (no citations provided) then march 23 is the critical point





Thursday, January 31, 2013

webstorm at 2 weeks

i've been using jetbrains webstorm for 2 weeks now. i'm coming from netbeans so most of my comments are relative to the netbeans 7.2 (or 7.3 beta) baseline
  • supports JsDoc @augments tag - netbeans doesn't
    • this is primarily useful for javascript that simulates inheritance
    • it may also support @lends, but i didn't need the feature and couldn't get it to work in the few minutes i played with it
  • "Go To Declaration" almost always works (if you've given the code enough JsDoc comments so that it is unambiguous - can't ask for more than that), appears to be model based
  • "Find Usages" isn't great or terrible - seems to be primarily based on string matching, eg methods with the same name in different classes are jumbled all together - http://youtrack.jetbrains.com/issue/WEB-6360
    • no way to limit the search to subclasses
    • jetbrains claims that 6360 is fixed in the next beta !!! that only took 11 days ... impressive
  • fails to detect file changes on disk that happen in symlinked directories - http://youtrack.jetbrains.com/issue/WEB-6438. this is a major failing, likely to result in lost work
    • WORKAROUND: using the settings dialog, add multiple content roots. i've just converted to this arrangement - will have to wait to see if this solves the "file changed on disk" errors
  • macros are so slow as to be useless - my favorite netbeans macro is "move up/down 10 lines and recenter the screen" which provides emacs-style scrolling. in netbeans this macro can scroll 400 lines per second. in webstorm, it's maybe 10 per second, can't key-repeat, and if you land on a line with a hint it activates the hint instead of the macro. ie, it's worthless
  • changing files in webstorm is somewhat faster and "smoother" than in netbeans
  • "go to super method" doesn't work
    • it does, but the cursor has to be inside the definition, not on the prototype method name
  • many features just don't work - i've googled and tried everything i found but i haven't submitted bug reports. if anyone knows a solution i'm all ears
    • method hierarchy - either grayed out or does nothing
    • call hierarchy - either grayed out or does nothing
    • super method - does nothing (clicking the arrows in the margin works)
    • the "Structure Tool" is somewhat broken - there's no easy way so select the file to show the structure of. WORKAROUND - have the file that you want active in the editor, "Navigate.Select In" and chose "Structure" (i've got it bound to Alt-4, 4)
  • the interface for editing settings is much more responsive than in netbeans (possibly limited to linux ???). this made getting started with webstorm less painful than expected (had many shortcuts to set) but long term doesn't help much
  • visual glitches
    • when iterating thru "find usages", keyboard focus has a tendency to get lost - closing, reopening, and closing the "find tool" seems to bring the focus back
webstorm definitely has some nice features, but also feels amateurish in too many ways. doubt that i'll be using it (or IDEA, the full java IDE - $200) as my main editor, but still on the fence about buying a copy - the $50 might be worth it just as a tool for code understanding of inheritance-based javascript (the only significant area that it's better than netbeans). netbeans is a better editor, has excellent java code understanding (and decent javascript support, eg code completion is good), is free and Free Software, and feels more professional


UPDATE: i'm pleased with the quick response (ie the workaround) on the symlink issue. will keep an open mind for the next 2 weeks (title changed as well)

UPDATE: jetbrains claims that 6360 is fixed in the next beta. it's really a feature enhancement - i was impressed they didn't outright reject it, doubly impressed that they actually worked on it


tl;dr - overall, webstorm is a good editor. webstorm's big wins so far are better support for javascript that simulates inheritance and excellent responses to bug reports

Thursday, January 24, 2013

"git stash save --patch" considered harmful

so you've been editing and it's been a few minutes or hours since your last git commit. you run your test case and bam, it fails !!! your working tree changes touch multiple systems ... you want to isolate the changes to see which one broke things before you commit. the obvious answer seems to be git stash -p (aka git stash save --patch). you mark all the changes that you want to stash and try your test case again. you make a few changes and want to pop the stash nqzero> git stash save -p nqzero> git stash pop error: Your local changes to the following files would be overwritten by merge: nutrweb/web/js/diary.js Please, commit your changes or stash them before you can merge. Aborting nqzero> git add -u nqzero> git stash pop # hard to recover if there are conflicts if there aren't any conflicts this is the bee's knees. but if there are conflicts, there's no obvious way to undo the merge (ie un-pop the stash) - the index has been corrupted. any suggestions ? without this, git stash save --patch considered harmful, ie it's very easy to lose changes

WORKAROUND

git stash create a backup before popping the stash. maybe git should do this for any merge with a dirty tree nqzero> tmp=$(git stash create) nqzero> git stash pop Auto-merging nutrweb/web/js/diary.js CONFLICT (content): Merge conflict in nutrweb/web/js/diary.js nqzero> git reset --hard nqzero> git checkout $tmp -- .

Wednesday, January 16, 2013

jetbrains webstorm first thoughts

i'm back to working on javascript after a year of java, and missing the excellent navigation and code understanding features that netbeans provides for java. netbeans javascript support is decent, but they just switched to a new language model and parser and it's one step forward, one step back ... in particular, jsdoc support for superclass info is limited. hoping that this improves - the guys working on it seem sharp and responsive

but in the meantime i've decided to try jetbrains webstorm, $50 for an individual license or a free 30 day trial. the code understanding seems better, especially the jsdoc support. still getting it configured, especially the keymap. documenting issues here


  • multiple shortcuts - the actions only appear to support a single shortcut. for some actions, i want more than one ... eg, for end of line i use ctrl-E (i'm an emacs guy), but i also want the "End" key to work SOLVED, in the settings.keymap page, just add another shortcut (i was trying to use the "add 2nd stroke" which creates a compound keystroke instead, emacs-style)
  • jetbrains sells themselves as shortcut friendly. and in general, the support seems pretty good. but the ultimate irony of webstorm is that the keymap settings are totally dependent on the mouse. you can't set shortcuts, delete shortcuts, search actions or search shortcuts using just the keyboard ... it's a clickfest. netbeans is much better in this regard (though at the price of the settings interface being slower and less responsive)
  • the "Structure tool" should be super useful. in fact, this is pretty much my reason for trying webstorm. but i can't get it to change files ... ie, it always shows me the structure for classes defined in one file, but i can't change that file. the navigation bar reverts to the that file whenever i switch to the tool. bizarre
    • WORKAROUND: Navigate.Select In.File Structure ... for me this is the compound keystroke [Alt-F1, 4] and i don't see any way to get there directly, ie with a single keystroke
  • absolutely amazing feature find ... Column Selection Mode. allows deleting a rectangular region - been wanting this for forever !!! i've got to play around and see if you can do anything meaningful other than deletions
    • and now that i know what it's called, it looks like netbeans supports it too (Toggle Rectangular Selection, or the rectangular selection toolbar button)
    • emacs too ... string-insert-rectangle, delete-rectangle
  • as best as i can tell, there is no way to tell if files have been saved or have outstanding changes ... yikes !!!
  • tried to create a macro for emacs-style scrolling (ie, jump a number of lines and recenter the cursor - in my case i want 10 lines). the macro fails completely ... it's slow to replay and if there's a code hint on the line it activates the hint. total lossage !!! netbeans is much better in this regard
  • type inference is pretty weak. if you jsdoc everything, webstorm is pretty good about keeping track of the types, but if you assign a known type to a local variable, it can't infer that the local is the same type. pretty weak. hoping that netbeans improves and can handle this logic
  • lossage - [Navigate.Super Method] doesn't work. clicking on the override symbol works





Saturday, August 18, 2012

more voip notes

tues i realized i couldn't make a sip call from my google nexus s (used to work)
thurs slashdot had an article on Groove IP (a softphone that bridges to google talk)

so today i spent a bunch of time investigating voip again. good news - things have improved. bad news - not that much. notes are mostly just for my own memory

anveo

  • this is my sip provider for outgoing calls
  • there's a new option (unless i missed it before) to use localized dialing. i choose this option and set it to USA with 0 for the international dialing prefix. now i can dial from my contacts without having to prepend 0111
  • i'm using a pay per minute account, and believe it only supports pcmu and gsm audio codecs
sflphone on ubuntu linux, amd64
  • still not really working - i can make calls and the callee can hear me, but i can't hear them
  • hostname - sip.anveo.com:5010
  • proxy      - sip.anveo.com:5010
  • audio: pcmu, gsm
csipsimple on google nexus s
  • would register with anveo, but couldn't make calls
  • deleted the old account (inside csipsimple)
  • created a new account using the basic wizard
  • copied and pasted the username and password
  • server - sip.anveo.com:5010
  • works, and audio quality seems better than i remember it (haven't tested much)
sipdroid on google nexus s
  • installed this app
  • couldn't get google voice integration working (didn't want it to use my primary google apps account and couldn't get it to recognize my gmail account)
  • set it up to work with anveo
  • server or proxy - sip.anveo.com
  • port - 5010
  • works, and audio quality seems ok (haven't tested much)
GrooVe IP Lite
  • mentioned in the slashdot article
  • uses jingle to forward the call to google voice (instead of to anveo)
  • i used my gmail account (instead of my primary google apps account) because i wasn't comfortable giving them access to my primary account
  • i enabled 2-step authentication so that i didn't have to give them my password (not sure how much this buys me)
  • it works, and call quality seemed similar to what the gmail phone widget achieves
  • this is a big deal
  • the only downside is that it can't be registered at the same time as the gmail widget (so i have to choose which one to have active prior to receiving a call)
  • haven't tested call quality much, but if it ends up being decent, i'll buy the "Pro" version for $5
incoming calls to sip - google voice forwarded to ipkall to callcentric
  • this still seems to work
  • call quality has always been marginal


the holy grail is to be able to run something like the gmail phone widget on both my desktop and my phone and to be able to answer from either (and even move the call from one to the other). still a long way from there - but this is a big step

Monday, July 23, 2012

the damp knight rises

at times a pretty movie, but overall terrible

  • not enough civilians on the streets of gotham - place was deserted
  • bruce's despair over rachel's death and hunt's betrayle wasn't convincing
  • talia was an f'ng mess - in love with bruce and bane and rambling about fulfilling Ra's destiny
  • talia and bane preach revolution and class warfare - victims in the pit of the entitled. they run the tribunal, which actually does off some of the corrupt rulers of gotham. and then, "oh by the way, we're gonna blow the city up". which they could have done on day one. f'ng nonsense
  • bane and talia put batman in the pit *knowing* that he's gonna rise up and escape. they want him to, need him to, aren't at all surprised when he does ... so what the fuck for ?
  • bruce can't tell that talia is *talia* ??? even after he's heard the stories in the pit ... he, the protector of orphans never asks "what happened to the child's protector". ftloc
  • nobody has a plan for anything in the movie, there's no game of chess, no strategy
  • pre-revolution, gotham is corrupt with the rulers dividing the spoils and everyone save kyle seems oblivious to it
  • the police force has been pussified
  • why the fuck don't bane and talia kill kyle. or fall in love with her. or at f'ng least realize that she exists
  • one schoolbus of orphans is all blake, our hero-in-waiting, can muster to the bridge

a few good moments
  • crane is awesome at the tribunal ... "death by exile !!!"
ok, make that one good moment. some of the stunts were fun, the cops-vs-thugs battle at the end had a nice buildup, bane and kyle were decent (if inconsistent) characters, bane's voice was awesome. in hindsight, i now realize that the only thing that saved "the dark knight" was ledger - he took a grenade for that film and paid the ultimate price - killed by nolan's tunnel vision

Wednesday, May 16, 2012

"upgraded" to ubuntu precise pangolin

well, i skipped oneiric (11.10) all together, so straight to precise (12.04) from natty (11.04). calling it an upgrade is a huge misnomer. in a lot of ways it's good, but it's like switching from a nice car to a nice boat. or a giraffe ... i'm a programmer and spend most of my time in netbeans, gnome terminal, chrome, and i run a command line internet radio app and use google voice as my phone. i run everything full screen and start it all from the command line

so for me, all i really need the UI to do is show me what's happening with the computer and easily control it. i want to see cpu frequencies, load and temp; pulse audio volume and routing (speakers vs usb headset); switch between windows and workspaces; open a terminal with a keystroke and maximize windows (avoid the mouse as much as possible)

this isn't a review or even a rant. just need to keep track of some of the things that i used with natty that i haven't found good substitutes for yet. the big change with (oneiric and) precise is unity. i'm still not sure if it's a window manager or what exactly. but gnome-panel no longer works which was everything i needed in a UI. they've replaced it with some hybrid menubar / indicator area. which saves a bit of vertical - would be cool if i wasn't running my 1900x1200 in profile, ie rotated :)

ported from panel:
- indicator-multiload -- shows graphs of cpu, memory, net and disk usage in the notification area
    apt-get install, run it, add it to the "startup applications"

- indicator-cpufreq -- displays and allows control of cpu scaling and governor
    actually better than the gnome panel applet (sets freq for all cores, not just one)
    doesn't include the cpufreq-selector, which allowed (easy) command line control of the cpus


missing:
- pulse audio mixer applet (allows easy routing of pa sources and sinks)
    pavucontrol seems like the only "easy" way to control audio routing, but it's not even close to pama
- indicator-sysmonitor (available for 11.10 but not 12.04)
    https://launchpad.net/indicator-sysmonitor/
    some hack to make it work in 12.04 (not sure what that script is doing)

subpixel ordering:
  gsettings list-keys org.gnome.settings-daemon.plugins.xsettings

  gsettings range org.gnome.settings-daemon.plugins.xsettings rgba-order

  gsettings set org.gnome.settings-daemon.plugins.xsettings rgba-order rgba

workspace switcher applet
my folks like to be able to switch workspaces using the mouse. in gnome2 you could do this in one click with the workspaces applet. unity requires 4 actions, ie bring up the launcher, click the workspaces icon, click on the workspace that you want to switch to, and (if that workspace has multiple windows open) click on the window that you want. ridiculous. and the zoom effect makes me nauseous too boot


can no longer control the arrangement of workspaces. i used to use 3 in a single row. not possible anymore. to control the number of workspaces use:
  gconftool-2 -s /apps/metacity/general/num_workspaces --type int 4
which will give you 4, in a 2x2 grid. i think it always uses 2 rows
http://askubuntu.com/questions/66701/how-configure-workspaces-on-unity-2d

one of my machines my parents use and they like it to automatically log them in. this seems to be broken with lightdm - if i enabled automatic login then i was unable to shutdown or restart with any of the graphical controls ("shutdown -h now" still worked). to work around this, i switched to gdm and used the "timedLogin" option. note: gdm used to have an "automaticLogin" and that appears to be broken and cause gdm to terminate silently (only took me 6 hours to track that down)

machine with an asus m2a-vm-hdmi mainboard had problems with mouse jerkiness. seems to be that the driver is constantly probing for a monitor, gets back garbage cause there's nothing there and spams the syslog, which somehow triggers all sorts of issues. it's a radeon x1200 (or x1250, not sure) integrated video card and i'm using the radeon open source driver. adding "radeon.modeset=0" to the kernel command line options seems to have corrected that problem


one thing that is a real pain with unity is that it's not obvious what anything is. with gnome, you could for the most part right click on anything and get an about dialog or see the path of the program the icon represented (ie ran). for the most part, the unity UI is a black box. it does stuff, but you can't easily see the mappings. in the panel you could click on an indicator and move it, remove it, add a new indicator. not so in unity (that i've found so far)

in spite of all that, i'm pretty impressed with canonicals execution with unity. it's a major change, and for the most part, things "just worked". my laptop has seen a significant decrease in power usage. the HUD notifications are improved. dash is bizarre but looks cool. pulseaudio still works. i think they're on the wrong track in terms of trying to simplify things at the cost of configurability. instead they should be working towards making existing things more consistent, and make it straight forward to discover what is going on. but given the path they chose, they've executed reasonably well


interesting ... the netbeans editor seems to be *much* faster after the upgrade. have only used it for a few minutes, but it seems dramatic. more testing / using tomorrow






Wednesday, April 25, 2012

lenovo x60 battery REPAIRED

3 years ago i forced lenovo to send me an replacement for my x60 battery that failed just before the warranty expired. the replacement has now failed - one day it had 2 hours of runtime, the next 5 minutes, which doesn't match my model of how li-ion ages. my gut is that lenovo is artificially shutting them down on a timer (guessing they make $100 profit per replacement battery). or maybe it's a legitimate "bug". who can know. lenovo has to a degree acknowledged that it's a problem (my fru isn't listed, but it's the same symptom):

http://download.lenovo.com/lenovo/content/batt/082009/LandingPage.html

that page describes an issue with the battery controller that causes premature reports of failure, ie before the cells have died. by premature, they mean in the first year ... but really, any time the battery controller is the cause of death (and not a cell failing) it's premature. so pretty clear to me that it's *intentional* on lenovo's part, but not much that we can do about this. after all, the anti-trust division of the doj is preoccupied with it's witch-hunt against google - no way they can waste time on something as mundane as actual fraud

so i'm working under the assumption that it's a software/controller problem. some other's seem to be on the same page (http://www.levien.com/tp600-battery.html). so the deal is that if you can trick a lenovo battery into fully discharging, it will reset the controller and take a full (well, as much as the cells will accept) charge and you're back in business

but no pinout for the x60 battery, so i can't use the exact method that javier valero suggests. but i found a *simpler* workaround. while running on battery i put the machine into suspend and left it there, which drains the battery slowly. while suspended, the crescent moon led is solid green. after about 30 hours, the battery was really dead, the machine shut off and the crescent moon led went out

plugged in the ac adapter, started the machine. after a few minutes it told me the battery was 100% (even though i now know it's almost totally discharged). removed the ac adapter and waited a few minutes until the "critically low battery" warning came up and plugged it back in. the battery charged to full (24000mwh - the battery is *somewhat* old after all :) and has behaved normally since

note: during the long suspend, the machine woke up once (presumably because the battery told it that it didn't have enough juice to keep it in suspend for much longer). i plugged it in for a second, clicked "ok" (ie suspend again) and then removed the ac as soon as it went back to suspend. not sure if the ac was needed or not

  • lenovo x60, stock other than 4G ram that i installed
  • ubuntu 11.10 as the primary OS, windows xp still installed and occasionally used
  • battery: FRU P/N 42T4631, ASM P/N 92P1170. fewer than 50 charge cycles (the x60 is usually plugged in). this battery was supplied by lenovo under warranty 3 years ago, but my original battery had a similar failure mode
symptom: one day the battery was fine, with runtimes of approximately 2 hours. the next time i tried it (could have been a month or 2 later) the runtime was 5 or 10 minutes. and the battery would report capacity of 30000mwh slowly decreasing to say 29000, and then suddenly drop to 1000mwh, causing the machine to suspend (in both ubuntu and windows xp). from the lenovo bulletin:

  • Irreparable damage or battery cannot be charged error message from Power Manager or Message Center, or
  • Low battery capacity, as indicated by short battery run time or sudden drops in the battery fuel gauge


tl;dr -- my lenovo x60 laptop battery failed prematurely (running ubuntu). i repaired it by leaving the machine in sleep till it shut down (crescent moon led went out), charging till "full" (only took a few minutes), discharging till "critical" (again, just a couple of minutes), and then everything worked normal, battery would hold 24000mwh


Saturday, April 21, 2012

sflphone 1.0.2 on natty

had a bunch of trouble getting 1.0.2 to build and run on natty (ubuntu 11.04). thought this info might be helpful to anyone else that's trying to avoid unity for a little bit longer

sudo apt-get install:
  libdbus-c++-dev 
  libgtk-3-dev
  libwebkitgtk-3.0-dev
  libnotify4-dev


at first i used libnotify-dev, and got a confusing error
Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
  ldd indicated that libgtk-x11-2.0.so.0 was used
  use libnotify4-dev instead (doesn't link against gtk directly)

config file (sflphoned.yml) wasn't automatically being created
  copied my 0.9.2 file and it worked fine
  might have missed it, but didn't see a basic starting point for generating one
  believe this is already fixed in version control

starting the client failed with a segmentation fault - appears that it was failing to get codecs
  may be related to 0.9.2 still being installed
  corrected this problem by starting the daemon explicitly first