Skip to content

Instantly share code, notes, and snippets.

class Integer
def prime?
if self == 1
return false
else
(2...self).each { |n|
return false if self % n == 0
}
return true
end
#!/bin/bash
TZ='America/New_York'
URL='http://weather.yahooapis.com/forecastrss?w='
l=2432214 # maui
export $(curl -s "$URL$l" | perl -ne'while(/(sunrise|sunset)="(.*?)"/g) { print "$1=$2\n" }')
if [ "$1" = "sunrise" ] ; then
TZ=$TZ date --date="TZ=\"HST\" $sunrise am"
{
"color_scheme": "Packages/MarkdownEditing/MarkdownEditor.tmTheme",
"theme": "Soda Dark.sublime-theme"
}
@lepht
lepht / markdown2evernote.rb
Created July 18, 2012 01:15 — forked from kopischke/markdown2evernote.rb
OS X service scripts
#!/usr/bin/env ruby -wKU
# Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/)
# Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/)
# Changes: – create only one Evernote note per (Multi)Markdown input passed (instead of one per line)
# – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript)
# – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script)
# – make smart typography processing optional (set SMARTY to 'false' to bypass processing;
# note smart typography cannot be disabled in MMD 3.0 and 3.0.1
# – handle both smart typography processing scripts (ie. SmartyPants.pl)
@lepht
lepht / README.md
Last active December 10, 2015 21:08
Pentadactyl command for enabling 'verbatim' mode in Google results

I find myself needing to toggle 'verbatim' mode on very often, which requires three mouse-clicks. For keyboard addicts, that's three too many.

Add this command to your Pentadactyl1 config file (usually ~/.pentadactlyrc) to make the :gv command turn on 'verbatim' mode while on a Google search results page.

@lepht
lepht / args.pl
Last active December 11, 2015 13:58
Perl named, self-documenting subroutine arguments with default values
# Perl named, self-documenting subroutine arguments with default values
sub foo {
my %args = (
# Set your defaults/doc your accepted args here
arg1 => 'default'
arg2 => undef,
somelist => [qw( some stuff )],
@_ # Passed-in args replace your defaults
@lepht
lepht / gmail-notify.rb
Created June 27, 2013 14:27 — forked from danchoi/barebones gmail notifier
Barebones gmail notifier
require 'rubygems'
require 'net/imap'
require 'tmail'
require 'parsedate'
# NOTE: Set these values before you run the script
# Your gmail username
USERNAME = "YOUR_USERNAME"
# Your gmail password
@lepht
lepht / git_diff_commit_alias.sh
Created August 16, 2013 20:25
adds an alias for `git diffc [refspec]` that will show the changes made by a particular commit.
git config alias.diffc "log -u -1"
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the present tense: "Fix bug" and not "Fixed
@lepht
lepht / unicode_pain.txt
Created October 1, 2013 07:20
Unicode string that crashes OS X 10.8 and iOS 6
سمَـَّوُوُحخ ̷̴̐خ ̷̴̐خ ̷̴̐خ امارتيخ ̷̴̐خ