Showing posts with label computer. Show all posts
Showing posts with label computer. Show all posts

Wednesday, November 18, 2020

an applescript to remind you of the sunset

I wanted to find a way to be reminded of when sunset was coming up, and couldn't find anything useful anywhere. So I wrote up my own AppleScript that displays a notification an hour ahead of sunset, and another when sunset happens. This script relies on LocationHelper and JSONHelper to function properly.

Without further ado, here it is:

-- get current location
tell application "Location Helper"
	-- Fetch the Google Map API information for the current location
	set current_location to get location coordinates
	set latitude to item 1 of current_location
	set longitude to item 2 of current_location
end tell

-- parse result
tell application "JSON Helper"
	set json to fetch JSON from "https://api.sunrise-sunset.org/json?lat=" & latitude & "&lng=" & longitude
	set json_parsed to json's items
	set json_data to json_parsed's first item
	set sunset to sunset of json_data
end tell

-- change hour to 24h (getting sunset in 12h format)
set sunset_time to date sunset
set sunset_time_24h to sunset_time + 12 * hours
set sunset_time to (time string of sunset_time_24h)

-- set reminder to hour before
set hour_before to sunset_time_24h - 1 * hours
set hour_before to (time string of hour_before)

-- get current time in UTC
set UTC to (current date) - (time to GMT)
set current_time to (time string of UTC)

-- now time
set time_now to current date
set time_now to text 1 thru 5 of time string of time_now

-- strip to hour and minutes
set sunset_time to (text 1 thru 5) of sunset_time
set hour_before_sunset to (text 1 thru 5) of hour_before
set current_time to (text 1 thru 5) of current_time

if current_time = hour_before_sunset then
	display notification "Sunset is in an hour!" with title "Sunset coming up" sound name "Submarine"
	delay 1
else if current_time = sunset_time then
	display notification "Sunset is now! (" & time_now & ")" sound name "Submarine"
	delay 1
end if

I have saved this script as an app in a folder under ~/Documents/SunsetReminder folder, and created the following plist file under ~/Library/LaunchAgents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>local.sunsetreminder.notify</string>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/sh</string>
		<string>-c</string>
		<string>/usr/bin/osascript ~/Documents/SunsetReminder/SunsetReminder.app</string>
	</array>
	<key>StartInterval</key>
	<integer>60</integer>
</dict>
</plist>

Finally, you want to run launchctl load -w /LaunchAgents/local.sunsetreminder.notify.plist from your terminal to load it. Good luck, and I hope it serves you well!

Sunday, September 21, 2014

Bahá'í Prayers on your Windows 8 laptop/tablet

After working on this project for more than two years, I have finally been able to release a Bahá'í Prayer book app for Windows 8. This app contains all the prayers in the prayer book, with pictures from the Holy Places in Israel and elsewhere chosen specifically for each category. A screenshot of the start page:


In addition there is a search functionality which makes it easier to find the prayer you are looking for. It is sufficient to remember a word from it and you can find it. You can download the app here!

Thursday, February 28, 2013

outlook.com calendar subscription...

... is pretty much an outright lie. it doesn't seem to really be a subscription as much as a one-time import. checking the status of my calendar import from google, it says that the latest refresh was at: Tuesday, February 26, 2013 10:08. the time now? Thursday, February 28, 2013 11:24. it's been more than 48 hours, and nothing has been updated. if microsoft wants people to move from gmail to outlook.com, they need to make things work.

that's my rant of the day.

Friday, January 04, 2013

is your screen too blue at night? try flux!

there is research indicating that lights from screens are guilty of keeping us awake at night. not just because we're having a hard time putting our laptops, tablets and phones away, but also because they suppress the production of the hormone melatonin, which helps regulate our sleeping patterns. see here, here and here.

I recently heard about a new software, f.lux, which is supposed to help alleviate this problem. how does it work? like this:

[f.lux] makes the color of your computer's display adapt to the time of day, warm at night and like sunlight during the day.

f.lux makes your computer screen look like the room you're in, all the time. When the sun sets, it makes your computer look like your indoor lights. In the morning, it makes things look like sunlight again.

Tell f.lux what kind of lighting you have, and where you live. Then forget about it. f.lux will do the rest, automatically.

I've been trying it out for about a week, and I clearly notice how the screen color goes a bit more towards red as the sun sets. does it help? I don't know. is it annoying? not really. is it worth trying out? I think so.

all you need to do is set up your latitude and longitude (which you get help with), specify your kind of lighting, and then it runs in the background and takes care of everything else. when I temporarily disable it, I definitely notice a difference, so I think it might be worth checking out. my recommendation: download flux now!

Tuesday, October 23, 2012

excel: last index of

assuming that text is in cell A1, and we are looking for "\" character, this works: =SEARCH("@",SUBSTITUTE(A1,"\","@",LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))

from here.

Wednesday, October 17, 2012

note to self

don't code while on the phone.

Monday, October 08, 2012

excel: lovely keyboard shortcuts

very simple, but oh so useful:
  • shift-space: select row
  • control-space: select column
time savers!

Sunday, September 02, 2012

Tuesday, August 21, 2012

stop-motion excel

this is seriously amazing.


Saturday, July 21, 2012

technology tips

I was having a conversation with a friend last night, and showed her some of the (computer) tools, applications and methods I was using to keep myself and various notes organized. she was very impressed and stated something along the lines of wishing to know more about what exists and thus be able to use them herself. with that in mind, I will start writing some of my usages and experiences with various software, and how I use them. hopefully it will be useful for other people too!

Tuesday, June 26, 2012

evernote 2 and windows 8

there's a lot of people who prefer evernote 2 to the latest version 4. installing it on windows 8 turned out to be troublesome at first, but running the installer in compatibility mode for win xp sp3 made sure the installer worked. it's now running perfectly fine, and I can go back to tagging in peace!

update: just to be clear, you have to run the application in compatibility mode as well.

Monday, January 23, 2012

could slow typing be good?

I am wondering if it could be beneficial to be a slow typer - otherwise there might be the risk of typing faster than the thought can be formulated, which can either cause total nonsense to come out, or, in the worst case, a not-so-well-thought-out statement. obviously there needs to be a balance as being too slow might cause you to lose your train of thought. is there perhaps an optimal words per minute to thought ratio? that would be interesting to investigate...

Monday, December 19, 2011

winding down

it seems that with people spending their last hours and minutes awake in front of the computer, skyping or chatting with friends, that there is very little to no time to wind down before going to sleep. how do you sort out your impressions and experiences of the day, if you are not allowing yourself some silent moments and time for reflection before sleeping? I think the last 30 minutes awake should be spent away from new impressions - TV, computer, etc. - and spent instead on prayer, meditation and reflection.

Monday, October 31, 2011

great relief

unsubscribing from stuff in google reader... ahhh, feels good!

Friday, June 17, 2011

fill right/down

anyone who's had a lot of tedious work filling out excel sheets is going to love this! filling out cells with adjacent data, done so easily:
  • ctrl-r: fill right

  • ctrl-d: fill down


  • can't believe I didn't know about it until now!

    Monday, June 07, 2010

    quick design

    this is how you do it:


    no need to make it anymore complicated than necessary. it got the point across to my flatmate, and we both knew what we were going to do.

    Saturday, May 15, 2010

    got my laptop sleeve!

    so I wrote a while ago about using your old t-shirt to get a laptop sleeve and make a good deed while you're at it (the money goes to helping sex trafficking victims). well, I just got mine, and I really like it:

    read here again about how you can get yours :)

    Wednesday, March 03, 2010

    note to self

    in css files, don't put any space between the number and unit. 24px and 24 px are vastly different. one works, the other doesn't. there goes an hour of my evening...

    Thursday, February 11, 2010

    take a t-shirt, turn it into a laptop sleeve!

    following up on yesterday's post on brilliant ideas, here's another one. and I really like it.

    take an old t-shirt, send it to hello rewind, and for $49 they'll turn it into your very own personalized laptop sleeve!


    and you know what the best part of it is? on top of you getting your personal sleeve, the money goes to helping sex trafficking survivors in NYC to re-establish themselves.

    unfortunately they're currently only making them for apple's laptops, but if yours fits (check the dimensions on their page), it's well worth it!

    Wednesday, May 06, 2009

    and it's finally done!

    it's been more than a year since I first announced the creation of my website, theaqdas.org, and now it is time again.

    after having papers like this:

    and my friend looking like this:

    we are finally done. the new version of theaqdas.org is online, and I must say that I am quite excited about this. besides studying everything again and reconnecting the synopsis to the verses, questions and answers and notes, there are some site design improvements, and added functionality: admonitions, concordance and paragraph summary.

    it's been an amazing journey, learning a lot of code and programming techniques, and also all the studying that's been done. I can only hope that other people get some sort of benefit from this, for me it's been absolutely amazing. hoping to do more in the future... :)