?

Log in

The Enigma That I Am [entries|archive|friends|userinfo]
Frederic Barthelemy

[ website | fbartho.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Applescript to open Mail.app and attach a zip of some files [Nov. 21st, 2011|12:01 pm]
Frederic Barthelemy
[Tags|, , , ]

Every once in a while, while you're working on something, you find that all the available solutions to a task are horrendously out of date. After bashing my head against the problem, I eventually figured out the recipe that made things work, so I thought I'd post the solution here.

I was attempting to streamline the process of iterating on localization files. Being a member of the Engineering team, we wanted to make this as turn-key as possible on our end. The Localization team actually coordinates between several external contractors, who don't have access to our git repositories. 

I knew I could construct a mailto: URL but that didn't have a clear way to attach files to the body of the e-mail. Being that our primary development computers are all running Mac OSX I figured Applescript would be the solution. I scoured the internet for solutions and it turned out that no sample code out there actually still worked for the problem at hand. Eventually I glued things together based on sample code from Apple and bits of several hints around the internet.

Most of the other e-mail applescripts I've seen fail to work on Leopard and all failed to fully work on Lion, so here is my sample code:

#!/bin/bash

target_address="example@example.com"
subject_stub="Daily Zip for files"

cwd=`pwd`
folderToZip="relative/path/from/here"
pathToZip= "build/DailyZip_"

/usr/bin/osascript <<-EOT

set cwd to "$cwd"

set {year:y, month:m, day:d} to (current date)
set datestr to y &"-" & (m*1) &"-" & d

set zipPath to cwd &"/$pathToZip" & datestr & ".zip"
log zipPath
set targetFilesPath to cwd & "/$folderToZip"
do shell script "zip -r -j " & zipPath & " " & targetFilesPath & ""

set att to POSIX file zipPath as alias
--set att to choose file
using terms from application "Mail"
tell application "Mail"
set m to make new outgoing message with properties {subject:"$subject_stub" & datestr, visible:true}
tell m
make new to recipient at end of to recipients with properties {address:"$target_address"}
end tell
tell content of m
make new attachment with properties {file name:att} at before first paragraph
end tell
(* Commented out so it doesn't auto-send the e-mail
tell m to send
*)
activate
end tell
end using terms from
"Done!"
EOT

Mirrored from fbartho.com.

Link

The Collective [Sep. 10th, 2010|01:46 pm]
Frederic Barthelemy

This is a draft idea that I wrote about a while ago, and I figured I might as well publish it since I don't have much time to flesh it out these days.

What is the Collective?

The collective is a distributed trust system for giving/receiving/trading access to shareable resources such as on-the-go wireless access. Businesses will be able to provide an integrated Collective node instead of or in addition to standard Wifi. People will be able to roam and instantly have their devices pick the most appropriate collective node to communicate with. The Collective would punish poorly performing service providers and each location's trust metric would rise and fall as clients are happy or unhappy with them. The better a particular client's ratio, the higher priority it's requests are and the lower latency it has. There would be queues for several buckets of users depending on the capacity of the device, and the accessing client would be tossed into the bucket most appropriate to their respect level. If you have an industrial accesspoint then you might have 10 buckets of users with their own priority, while a home wifi network might only need 2 buckets. Every human user would have the ability to link multiple devices and have them all access through their account, some of these devices would also be providers and not just consumers. Your car's computer might get licensed under your account, and you could set it to only contact the web through your providers, or you could set it to get the web through any available access points while billing its access against your overall trust level. 
 

How does it work?

In provider mode, your laptop might be set to rebroadcast unauthenticated web access under your own collective account. Say 4 users are plugged in to wired internet in a room. Their laptops would all broadcast they are providing "collective" service. A 5th user would walk into the room and with a pod style device (no cellphone internet) and the 5th user would try to get online. Their pod device would listen to the collective broadcast beacon. This would be a shared service provided by all the laptops, and each laptop would take turns broadcasting the main part of the beacon message. This beacon message would attempt to inform the pod device of all local collective providers. Each provider would also broadcast a ping containing an NTP timestamp immediately after they receive the beacon message. This would allow the pod device to make a decision as to it's proximity to each provider. The timestamp would allow the pod to separate the distance between provider B and beacon broadcaster (provider A) from the distance between the pod and broadcaster B. It would then attempt to satisfy its own internet request through the collective in order of proximity. Each provider that succeeds would get credit on a sliding scale based on the latency of the whole request, and the amount of data of the request. Each client would be *charged* a certain amount of credit. This both encourages the user to broadcast Collective access points when they can, and it helps give priority access to users who use less sparingly. Every day a user would automatically gain a small amount of credit. Additionally users would be able to subscribe to the Collective and the amount of their subscription would increase their daily allotment. Providers could be jointly owned between multiple users (example: shared wifi in an apartment). Every provider in an apartment building would be a shared web zone and any device could roam among all the Collective providers.

Mirrored from fbartho.com.

Link

redirect_canonical [Jul. 10th, 2010|05:46 pm]
Frederic Barthelemy
[Tags|, , ]

redirect_canonical

Turns out I had to do some further tweaking for my subdomain plugin. Unfortunately, my subdomain code didn't originally handle the redirect_canonical filter provided by WordPress. This was originally no big problem, until I tried to create a subdomain for all posts tagged with a particular tag. (In this case dev.fbartho.com which presents all posts tagged with "Development").

Implementing the redirect_canonical filter hook in my plugin was a little tricky because by the time it is called I had already destroyed the original request URI and thus my ability to detect what the unmodified page url was at that time. Thankfully, all it took once I understood the problem was to store that in a global before I modified it, and then read that global back at the appropriate time in redirect_canonical

CKEditor

Today I also added the CKEditor plugin for WordPress. My first impressions of it are that it works very well. In most situations it seems pretty polished. It has a good number of toolbar buttons, without them being overly crowded, and you get to customize their appearance. Minor niggle: there isn't a <code> button, but I think I'll be able to add that with a quick little change.

Screenshot of CKEditor in WordPress in a Fluid Site Specific BrowserTwo features I recommend you use: there's a "Fullscreen" button and a "Show Blocks" button. The show blocks button gives you little grey rectangles around the major semantic elements and that lets you get a good feel for where your insertion point is located and what the editor is actually doing under the hood.  As for the fullscreen option, obviously that's self explanatory, but if you put that together with a Fluid-generated site specific browser for your blog, and the experience you get is that of a dedicated word-processor for your blog entries.

My one caveat is that, to my supreme disappointment, CKEditor completely fails to load on iPad. I have no idea why yet, but the editor simply flickers out of existence and you're left with the simplest and dumbest of editor experience. (It doesn't even let WordPress' original editor reappear)

I'll see how things go, but moving forwards, for desktop publishing, I may primarily use CKEditor within my Fluid Journal app. However, I really wish I had a more mobile editor that works well. Any recommendations?

Mirrored from fbartho.com.

Link

Triumph at last! WordPress & subdomains do go together [Jun. 20th, 2010|05:11 am]
Frederic Barthelemy
[Tags|, , ]

I finally decided to do something about the abysmal visual quality of my site in recent times, but I definitely didn't want to compromise on complexity. Sometime in college, I started taking to heart the idea that it is rarely worth doing something, unless you plan to do it well. There is a modifier on that however: you need to define what *well* means for yourself. I had always held the opinion that my website was primarily for experimenting with new technologies or learning new things; having a visually interesting website was of distinct lesser importance. After I was in the job market this last I was informed — to my surprise — that my resume had been found via my own website more than through any other means. I cringed when I heard. Apparently, the visual effect of my site has become more important to me.

Back in the day I setup a WordPress and a Movable Type blog just to see how they worked, and over the past year I noticed enough respectable WordPress blogs that I decided to go with that option. Bringing back the point about needing my endeavors to be technically interesting, I decided to put a twist on my setup: I would attempt to integrate my full control of subdomains into the same WP installation. Little did I know quite how challenging that would prove to be.

The first obstacle I ran into was that WordPress 3.0 had just landed, and that meant that many plugins, and a few of the themes I tried weren't fully compatible. Not a big deal, I dove right in and started learning about the WP API and the types of things that broke from 2.8; A couple patches here and there and next thing you know the core pieces were working.

The basics resolved, I attempted to find a plugin that would do what I wished for subdomain management. No dice, though one plugin did stand out as being from the same family, and I was able to learn a bit from how it was structured.

Obvious next step? Start to a custom plugin to do what I wanted.

Key things I ended up learning much about:

  • Use 302 redirects instead of 301 while debugging.
    I lost some time attempting various (still flawed) solutions just to find that my webbrowsers had cached the 301 as the Permanent redirect that it is.
  • add_action()/add_filter()

    Crucially important, these are how your plugin gets the ability to override and inject data throughout the WP data flow. Basically there are a ton of keywords that WordPress broadcasts to at certain steps in it's life. This is effectively an observer pattern. In many cases WordPress will pass in its initialized array of data, and then ask all observers if they think it's correct. These observers include components across the system many of which might be plugins. These plugins have the option to remove or inject data based on their own logic, before the results are passed along to the next observer in the chain. Finally the potentially modified data is handed back to WordPress which then uses it.

  • Permalinks and URL rewriting

    I spent much too long learning how WordPress works in this case. Basically, there is exactly one initial entrance point to WP for everything of relevance to normal operation. The URL rewriting rules in the .htaccess just reformat the URL such that it passes data into index.php Further URL matching also happens at runtime in WP_Rewrite. I tried and I tried to figure out supplemental mod_rewrite rules to help create the subdomain effect I wished and had absolutely no luck. I tried to hook in to the additional rewrite rules and those were even more of a headache than mod_rewrite!

  • K.I.S.S.

    As usual, this principle seems to be a good guide. With every attempt frustrating and each subsequent attempt becoming more and more convoluted I eventually spent some serious time examining the flow of data in WordPress. I finally determined that the crucial datasource used to disambiguate which page to load is $_SERVER['REQUEST_URI']. And with that realization came final success. Discarding the evolutionarily created mess and substituting one quick little method added in the plugin's startup, and Tahdah! Pretty permalink urls with subdomains in use, for every subdomain I care to map in my standard WP admin console.

After spending over a day frustrated on this problem, I'm elated to have solved it and I needed to write my first post. From my iPad no less!

PS. WordPress for iPad (the app) is extremely flaky, I typed my whole post in it and then it completely fails to actually submit the post (no error message) Additionally, until reboot, copy paste was broken in it so it looked like this post would be lost. Eventually, extracted, this post was published via the web admin console's raw HTML editor. Any recommendations for a better client? For the desktop it looks like I'll be using ScribeFire embedded in Safari unless someone has something better?

Mirrored from fbartho.com.

Link

Packrats get old and face a choice [Apr. 22nd, 2010|12:42 pm]
Frederic Barthelemy
[Tags|, , , , ]
[Current Location |San Francisco - South Bay]
[Current Mood |determineddetermined]

I've made a decision. My experience on my Solar Car Team significantly reinforced the packrat-ish types of behaviors in all of us. Even further was that generally the geekier/techier the person, the more they had innate tech-hoarding tendencies. Finally, most college students I know are loath to get rid of anything, just on the premise that they had to pay to get it in the first place and they don't have an unlimited budget, and what if the might need it in the future?

Anyway, my roommate had his birthday the other day, and mine is at the end of the summer and this year we're turning 25. A quarter of a century was kind of the age to make me realize that I'm a respectable adult. Then I started analyzing my living style and possessions and noticed a couple details that don't quite line up with that image.

With respect to spring cleaning, on the non-tech side of things I have a 2 bookcases, but roughly one could be considered to be full of "childish" books including a ton of stuff I read back in highschool. On the tech side of things, I have 3 large rubbermaid bins full of computer parts / cables / and other assorted related items. Not including the gaming computer and 5TB server and my miscellaneous networking hardware, I additionally have 1 CRT monitor, and 1 LCD, and finally I have two computers that I haven't used in > 10 months. I planned to convert them into servers and use them for projects like home automation, but I had a wakeup call and realized that for a very small amount of cash I could get a box no bigger than a DVD player that does more, better, quieter, cooler, and less power hungry than these old computers. These guys are large and bulky and ugly in comparison to the sleekness of anything you can buy these days.

End result: massive spring cleaning for me this year. And a resolution to buy nothing tech except the iPad until I clean out my apartment.

(-- see? I'm growing up!)
Link13 comments|Leave a comment

GRRR - Facebook Friend Details - Social Timeline - RIP [Mar. 17th, 2010|11:32 am]
Frederic Barthelemy
[Tags|, , ]
[Current Mood |annoyedannoyed]

I know this happened over the course of the past year, but I've finally bothered searching to verify that my experience was true. Facebook removed the "Friend Details" feature. They had already removed the social timeline a while back, but I know many people didn't know it existed. The feature didn't have to die as a whole though! I'd settle for the details being private notes I made about particular users. I forget people's names all the time. Many times friend photos are of random poses or even unrelated objects, and people just look a bit different over time. My memories of people are based on *who* they are, and the experiences we shared together. I really wish I still had access to that data. They said that they expected friend lists to supplant that feature, but why didn't they make an effort to convert that data to friend lists???
LinkLeave a comment

Git -- People say it's better... but is it really? [Feb. 8th, 2010|09:23 pm]
Frederic Barthelemy
[Tags|, , , , , ]
[Current Location |United States, California, San Mateo]
[Current Mood |annoyedannoyed]

Recently a friend of mine has been trying to convince me to start using git instead of svn. Since he was the administrator for a server that he and I are working on a project together with (grammar?), I've made an effort to really understand why people like it.

While googling about the subject I ran across http://whygitisbetterthanx.com/ On this site, they have several bullet points that they posit as reasons why git is better than other source code control solutions. I just don't see that the benefits outweigh the pain as compared to subversion.

  • Cheap Local Branching
    I'll grant that that could be useful, but for the most part I don't have a problem with that with svn.
  • Everything is Local
    I guess potentially this could be useful, but not for me, I own the repository that I primarily connect to, and it is local, so git doesn't add value in my use case.
  • Git is Fast
    they imply it's faster than svn, but they don't show the numbers for that only versus hg and bzr. In any case svn isn't slow in my experience, for the normal use cases I run through.
  • Git is Small
    This might be relevant if I ever had size problems with subversion.
  • The Staging Area
    I'll grant that if your workflow requires that maybe it's useful. In my experience however I'd rather not partially commit my directory modifications, in the case where I do want to only check-in certain files I can always do so by listing them with svn. Thankfully there's "git commit -a" so the staging area seems irrelevant to me, but not actually a negative.
  • Distributed
    This part is pretty cool, except for the part where I don't need it. I already backup my repository in a couple locations, however admittedly that took a little work to setup initially.
  • Any Workflow
    this would be great except that I don't care about other workflows right now, so ... yeah.
  • GitHub
    As cool as github is, I don't believe it's a reason to change one's private coding habits. I does make things more convenient, but GitHub could easily be run with a different source code control backend, it's a community.
  • Easy to learn
    It's great how they have this point, but don't mention that it is not easier to learn than cvs or svn, sure it might be equally easy to learn git as it is HG or Bazaar, but yeah, not a reason to leave svn

End Result? I'm going to keep trying git on my friend's server, however, really, I don't see the value for my personal code projects right now. If anyone wants to share anecdotes of why they like git or wants to try to convert me, I'd love to hear it. I want to be cutting edge, and use all the best tools, but Git is simply not computing for me.

LinkLeave a comment

Australia Trip [Oct. 9th, 2009|04:50 pm]
Frederic Barthelemy
[Tags|]
[Current Location |United States, San Mateo]
[Current Mood |excitedexcited]

Who do I know in or near Australia who wants to travel / have a visitor at the end of the month?

I've been potentially given the opportunity to go join http://www.umsolar.com/ for the World Solar Challenge -- as part of the video crew. I need to figure out what I'm going to do before and after the race. And how do I get there?

I'm thinking of hitting up Youth Hostels and the like most of the time, but it's always more fun to do with a group. Who want's to go??

What should I do?

Advice? Suggestions? Free plane tickets?
LinkLeave a comment

It's been a long time... [Aug. 24th, 2009|11:15 pm]
Frederic Barthelemy
[Tags|]
[Current Location |United States, California, Oakland]
[Current Mood |curiouscurious]

Wow, nearly a full year. Instead of apologizing I think I'll just try to kick this back into gear over the next few weeks.
LinkLeave a comment

Sobriety over time [Oct. 25th, 2008|12:21 am]
Frederic Barthelemy

If I ever had trouble with any organ, it wouldn't be my new best friend, my liver.



Posted by ShoZu

Link5 comments|Leave a comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]