Tuesday, October 14, 2014

 

Learning AppleScript

After many trial and errors, managed to get my first AppleScript working. It moves messages from Outlook Inbox folder which belong to specific "category" to another folder, but only if these messages are more than 24 hours old.

(So the goal is that certain messages sent by various automated tools would appear in Inbox but would be automatically moved to a dedicated folder the next day)

Here it is:

tell current application
set today to current date
end tell
tell application "Microsoft Outlook"
set tainbox to mail folder "Inbox" of exchange account "Tripadvisor"
set viprbt to mail folder "VIP Robots" of exchange account "Tripadvisor"
set yesterday to today - 172800
set ctgrob to category "Robots"
set _messages to every incoming message of tainbox whose time received < yesterday
# set subjs to {}
repeat with msg in _messages
# if categories of msg contains {ctgrob} then copy msg's subject to the end of subjs
if categories of msg contains {ctgrob} then move msg to viprbt
end repeat
# subjs

end tell

The biggest issues I encountered are:

  • When using "contains", totally counter-intuitively RHS has to be a list;
  • Operator 'whose' might or might not work with specific predicate, you never know; if it does;t, you have to iterate manually, which is much slower;
  • You code might not work with complicate expressions until you'll make it simple enough by saving intermediate results using "set". E.g. the code above would't work if I tried to avoid using _messages:
repeat with msg in (every incoming message of tainbox whose time received < yesterday)




Friday, November 29, 2013

 

Using rsync

Here is how to properly invoke rsync to copy files from Windows (using Cygwin) to Unix/OS X system:

rsync -rlt --chmod=ug=rwx --chmod=o=rx source user@machine:target/


Monday, October 07, 2013

 

Brief History of my Personal Computers

It has been a while since I started giving all of my personal computers (meaning not "PC"s as opposed to Mac or Linux, but computers I owned and used personally) specifically chosen names. Below are all the names I used so far with a brief description of the corresponding machine; I'll be updating it as new computers are added or taken out

(Note that since about 1997 I have been using company-provided laptops; naturally, these machines are named by the company and not included here, even though at times I used them most of the time; neither do I include portables such as MacBook Air, somehow I consider those more like appliances (not unlike a smartphone or a tablet) and lacking their own personality)

sun   2000-2007
HP(?) computer with pre-installed Windows 98, bought around 2000; installed Windows 2000 and used along with Suse using KMV (Keyboard-Mouse-Video) switch. Rarely used it after buying new Dell in 2007 and almost not at all after moving out of Brookline house in 2009; thrown out during cleanup in 2012.

spirit  2001-2007
Cheap Dell computer (2001-2002); installed SuSe (before Novell acquisition), used it heavily till buying Dell in 2007; in the end of 2007 - beginning of 2008 gave to L.E. where it worked (under Windows XP) till March/April 2010 till hard drive gave up.

luna 2000-2007
Really old (1999?) painfully slow Compaq computer with AMD processor; bought it for P.I. and tried installing WIndows 2000, it worked but rebooted from time. Gave up, installed OpenBSD on it and used it as a local file/web server. Rarely used it after buying new Dell in 2007 and not at all after moving out of Brookline house in 2009; thrown out during cleanup in 2012.

zeus 2007-2012
Expensive new Dell Precision 390, two core, 1.86GHz, 4GB RAM, CD- and DVD- read/write (two separate bays), pre-installed 64-bit Red Hat Enterprise Linux WS v4, May 2007 (I was waiting for first suitable 64-bit Intel  processor with "EMT" architecture (that is, backward compatible with 32 bit). AMD invented this architecture a year earlier, but their machines were said to be poorly compatible with 64-bit Linux.

charon 2013-
Sort of cheap Dell laptop, give to PD at his work during summer 2012; stayed without much use till September 2013 when I decided to try it with WIndows 8.

Heibohre 2014-

Saturday, March 23, 2013

 

obj-c on debian7: success

Actually, I did try to use latest gcc version on debian 7 to compile command-line obj-c program, which I previously wrote on OS X and which makes use of certain Objective C 2 features.

This worked, with a few caveats:

  • You need to install gobjc++ and gnustep-devel packages (might be an overkill, but...)
  • If you plan to use GNUstep (that's the best way to guarantee compatibility with Apple tool chain), keep in mind that you'll need a special makefile (traditionally named GNUmakefile). Here is manual, and here is a basic example:

    include $(GNUSTEP_MAKEFILES)/common.make
    
    TOOL_NAME = rat
    
    rat_OBJC_FILES = Rational.m Expression.m main.m parser.m
    
    rat_HEADER_FILES = Rational.h Expression.h parse.h
    
    -include GNUmakefile.preamble
    
    include $(GNUSTEP_MAKEFILES)/tool.make
    
    -include GNUmakefile.postamble
    

  • For some reason, debian 7 version of GNUstep is missing definitions of TRUE and FALSE (though BOOL is defined?) and NS_REQUIRES_NIL_TERMINATION (see this recent patch). Therefore, I added this to one of the header files:

    #ifdef GNUSTEP
    #define FALSE 0
    #define TRUE 1
    #define NS_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
    #endif /* GNUSTEP */
  • Also, these makefiles as described above require some environment variables; you can use

    source /usr/share/GNUstep/Makefiles/GNUstep.sh 

    to set it up
  • There are some mysterious problems with version of libgnustep-base.so ; you'll need to somehow convince your linked executable to load system version, e.g.:
    pushd ~/GNUstep/Library/Libraries
    ln -s /usr/lib/libgnustep-base.so.1.22.1 libgnustep-base.so.1.24
  • Also, be mindful of 32/64-bit differences (since OS X is 64-bit only)

Friday, March 22, 2013

 

Submitted WebKit bug :)

https://bugs.webkit.org/show_bug.cgi?format=multiple&id=113001


Bug 113001

Summary:Some Hebrew diacritics get messed up on form submission
Product:WebKitReporter:Konstantin <ikn@hotmail.com>
Component:FormsAssignee:Nobody <webkit-unassigned@lists.webkit.org>
Status:UNCONFIRMED  
Severity:Normal  
Priority:P3  
Version:528+ (Nightly build)  
Hardware:All  
OS:All  
URL:http://zapad.org/~ignatiev/temp/w4.php
Attachments:
DescriptionFlags
Source of PHP script to reproduce the problemnone
When I submit any form which has a text field which contains Hebrew diacritics U+05BC ("dagesh") and U+05B6 ("segol"), in this order, they get submitted to the server in the *opposite* order: U+05B6, U+05BC . While Hebrew word seems "same" visually, this "fixed" order is invalid (or at least non-standard), and regardless, browser obviously shouldn't change data entered into the form on its own, under any circumstances.

To demonstrate this issue, I wrote a simple PHP script (attached, and available online at http://zapad.org/~ignatiev/temp/w4.php), which allows user to fill a text field and then upon form submission to compare user input with what was actually submitted (via simple hash sum JavaScript implementation). You can play with it and see that it works fine for almost any text in any language you can enter.

If, however, you use button "initialize", script will initialize the text field to the string '\u05d1\u05bc\u05b5' (bet-dagesh-segol), and upon form submission the comparison test will FAIL; value submitted will be '\u05d1\u05b5\u05bc' bet-segol-dagesh.

This problem is reproducible in any WebKit-based browser I tried (Chrome Windows/Mac, Safari Mac/Windows/iPhone, Debian 6 "Web browser", also on the latest "nightly build", compiled from source on Linux/GTK), while it works fine in IE, Firefox, and (Presto-based) Opera.


P.S. Here is my first and only Firefox bug report (classified as duplicate, fixed eventually)

Monday, March 04, 2013

 

@property support in gcc

It looks like from version 4.6 onward gcc supports (some?) Objective-C 2.0 language extensions, including, among other things, @property keyword.

In the meantime, latest Debian 6.0 squeeze only includes gcc 4.3 and 4.4. How long till Debian 7?

BTW, there is also a project to support GTK+ bindings for objective-c, but it does not seem to be actively supported.

Labels: , ,


Thursday, November 24, 2011

 

Why use href="#"?

Yes, I finally figured why people so often use construct

<A href="#" onclick=do something...

whereas I have always been using

<A href="javascript:foo()" ...

Let's look at this test file:
<html>
<script>
function foo(elm) {
  if (elm == window)
    alert('received Window!');
  else
    alert("received <" + elm.tagName + ">");
}
</script>
<A href="javascript:foo(this)">Click 1</A><br />
<A href="#" onclick="foo(this); return false">Click 2</A>
</html>
Second click works as "expected," passing relevant "<A>" node into Javascript function, but first one does not; instead; 'this' is resolved to it's "default" value as current document "window". Also, this behavior seems to be consistent across all major browsers.


This page is powered by Blogger. Isn't yours?