Skip to content

Instantly share code, notes, and snippets.

View crmne's full-sized avatar
👋

Carmine Paolino crmne

👋
View GitHub Profile
@crmne
crmne / iTunes - Current Track.scpt
Created May 11, 2014 14:56
Gets the name, artist and album of the current playing track in iTunes and passes it to Launchbar. Very useful to search the current track in Google, Discogs, and the likes.
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
set myTrack to ""
@crmne
crmne / Convert Currency.scpt
Last active April 13, 2018 10:47
Converts currencies using Google Finance. Created specifically for LaunchBar, just put it in `~/Library/Application Support/LaunchBar/Actions`. It accepts input in this form: `<amount> <from currency> […] <to currency>`. So for example all of those strings will result in the same conversion: "60 gbp to eur" "60 gbp in eur" "60 gbp eur". It will …
on parse_input_string(theString)
set AppleScript's text item delimiters to " "
set theFromAmount to text item 1 of theString as text
if length of text items of theString is greater than 1 then
set theFromCurrency to text item 2 of theString as text
set theToCurrency to text item -1 of theString as text
set currenciesGiven to true
else
set theFromCurrency to "USD"
set theToCurrency to "EUR"
@crmne
crmne / Google Translate.scpt
Last active May 15, 2018 18:06
UPDATE: I made a LaunchBar 6 action that you can find here: http://static.paolino.me/GoogleTranslate.lbaction.zip. Make sure to enable Accessibility for LaunchBar, and "Allow Javascript from Apple Events" in Safari's Develop menu. -- Translates text using Google Translate in Safari. It gracefully handles large text, which is impossible with just…
on safari_is_ready(docNum, interval)
repeat
tell application "Safari"
try
do JavaScript "document.readyState" in document docNum
set readyState to result
set finishedLoading to (source of document docNum contains "</html>")
if finishedLoading and readyState is "Complete" then exit repeat
end try
end tell
# Script to process background data (.ibs files) generated by the Optotrak 3020 system
# Carmine Paolino <[email protected]>
require 'csv'
num_pattern = /[+-]?\d*\.?\d+/
allowed_frenquencies = [ 1, 2.5, 4 ]
trials = []
class ListableAccessors
@crmne
crmne / emacs23_3-xcode4.patch
Created June 7, 2011 16:28
Fixes Emacs 23.3 compilation bug when using Xcode 4
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index df4c0da..e5254de 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -822,6 +822,7 @@ copy_data_segment (struct load_command *lc)
}
else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
|| strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
+ || strncmp (sectp->sectname, "__got", 16) == 0
|| strncmp (sectp->sectname, "__la_sym_ptr2", 16) == 0
@crmne
crmne / emacs-colors.patch
Created May 30, 2011 15:29
Fixes Emacs colors on Mac OS X
diff --git a/src/nsterm.m b/src/nsterm.m
index 025486d..bb362a6 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1414,7 +1414,7 @@ ns_get_color (const char *name, NSColor **col)
if (r >= 0.0)
{
- *col = [NSColor colorWithCalibratedRed: r green: g blue: b alpha: 1.0];
+ *col = [NSColor colorWithDeviceRed: r green: g blue: b alpha: 1.0];
@crmne
crmne / snap-graph_warning.patch
Created May 26, 2011 08:22
Fix for invalid preprocessor directive #warn in snap-graph.sf.net
Index: src/graph_partitioning/internal-timer.h
===================================================================
--- src/graph_partitioning/internal-timer.h (revision 187)
+++ src/graph_partitioning/internal-timer.h (working copy)
@@ -30,7 +30,7 @@
static struct timespec tic_ts;
#define USE_CLOCK_GETTIME
#else
-#warn "Falling back to gettimeofday ()."
+#warning "Falling back to gettimeofday ()."
@crmne
crmne / .gitignore
Created January 13, 2011 09:31
Create directory hard links on Mac OS X
hlink.o
hlink
@crmne
crmne / view_generated_source_in_textmate.scpt
Created October 26, 2010 17:11
Opens the generated source of the current Safari page in TextMate. Javascript trick thanks to @dpkendal http://gist.github.com/646570
(*
Opens the generated source of the current Safari page in TextMate.
To make it a System Service (with keyboard shorcuts!), visit:
http://iflipbits.com/post/880085979/view-source-in-textmate-for-safari
*)
tell application "Safari"
if not (exists front document) then
display alert "An error as occurred" message "You need to open a web site first!" as warning
@crmne
crmne / unique_insert_with_ids.cpp
Created October 16, 2010 22:32
This is how you can insert elements in a container, without repetition, and obtaining unique ids. Useful for inserting vertexes in Boost.Graph. See http://stackoverflow.com/questions/3950841
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main (int argc, char const *argv[])
{
string array[] = { "zero", "one", "one", "zero", "two", "three", "zero" };