Skip to content

Instantly share code, notes, and snippets.

View drodriguez's full-sized avatar

Daniel Rodríguez Troitiño drodriguez

View GitHub Profile
This script and build target will take the revision number from a Subversion repository (or a Git
repository using git-svn) and substitute the last dotted component of the CFBundleVersion in your
Info.plist file (you can put something like "1.0.0.xx" for your first run).
Instructions:
- Save update_build_number.rb into ${PROJECT_DIR}/Scripts (or wherever you want, but remember to
change the paths accordigly in the build phase).
- Add a new target to your project (I named mines as "Update FooBar Build Number"). In new target
dialog choose from "Other" category "Shell Script Target".
def month_names_between
# No hay necesidad de convertir en string para comparar
return [I18n.l(fecini, :format => '%B')] if fecini.month == fecfin.month && fecini.year == fecfin.year
# De nuevo, no hay necesidad de convertir en string y luego en entero.
# Además utilizo nombres más descriptivos.
anio_inicio = fecini.year
anio_final = fecfin.year
mes_inicio = fecini.month
mes_final = fecfin.month
diff -urN -x 'Makefile*' -x '*comp.sh' -x libtool -x x-to-1 -x stamp-h1 -x POTFILES -x gettext.sh -x '*config*' gettext-0.17/gettext-runtime/gnulib-lib/setenv.c gettext-0.17-mine/gettext-runtime/gnulib-lib/setenv.c
--- gettext-0.17/gettext-runtime/gnulib-lib/setenv.c 2007-10-07 22:28:16.000000000 +0200
+++ gettext-0.17-mine/gettext-runtime/gnulib-lib/setenv.c 2009-09-13 20:11:21.000000000 +0200
@@ -39,7 +39,8 @@
#if !_LIBC
# define __environ environ
# ifndef HAVE_ENVIRON_DECL
-extern char **environ;
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron())
// Reachability Objective-C minimal version
// I'm new so memory leaks are possible on this code
// Extracted from:
// http://www.idevapps.com/forum/archive/index.php/t-3329.html
// (look for an imported_kelvin's post)
//
+ (BOOL)networkAvailable{
SCNetworkReachabilityRef netreach;
SCNetworkConnectionFlags flags;
#! /bin/bash
EXPIRATION_IN_SECONDS=5000
ERROR_ICON=gtk-dialog-error
SUCCESS_ICON=gtk-dialog-info
function notify ()
{
notify-send -t $((EXPIRATION_IN_SECONDS*1000)) -i $3 "${1}" "${2}"
}
@drodriguez
drodriguez / test.mm
Created December 22, 2010 22:18
Objective-C++ NSString wrapper example
// $ g++ -o test -framework Foundation -Wall test.mm
// $ ./test
// The string length is 12
// The string third char value is 108
// The string is Hello World!
#include <iostream>
#import <Foundation/Foundation.h>
class MyCppNSStringWrapper
@drodriguez
drodriguez / Questions
Created August 8, 2011 22:14
Frozen Rails Give-away
Day job: Mobile Engineer at Tuenti (http://tuenti.com)
Your Rails contributions (if any): Yes, of course http://contributors.rubyonrails.org/contributors/daniel-rodriguez-troitino/commits (and some old plugins)
What's your Ruby/Rail experience?: I have been using Rails for pet projects since it was a 0.x (end of 2006), and profesionally for a year or so in a previous job.
How do you use GitHub?: Now mainly for personal projects and open source contributions, and to keep track of interesting projects. I have used GitHub at work, but not anymore (now my shared repositories are self-hosted).
@drodriguez
drodriguez / Questions
Created September 6, 2011 21:42
GOTO Amsterdam
Day job:
Mobile Application Developer at Tuenti <http://tuenti.com>.
What is your language of choice:
My main language will be Objective-C, helped by Ruby for almost anything else.
Open Source contributions:
Several contributions to Rails and other Ruby open source libraries (SQLite-Ruby, FeedTools). Contributions in some Objective-C/Cocoa projects (Wordpress.app, SQLPersistentObjects, Adium, AppReviews, NuZip, Twitterfon). A lot of small contributions in different open source projects (Scour, Zenphoto, Sproutcore, K2, Trac, Gtk#, RadRails). Some released open source personal projects (video5 Chrome extension, globradio, reversegeocoding, Custer).
How do you use GitHub:
@drodriguez
drodriguez / partial_consecutive_sum.rb
Created May 3, 2012 16:38
Find partial consecutive sum
def find_partial_sum(array, goal)
istart, iend, sum = 0, 0, 0
while iend < array.length
while iend < array.length && sum < goal
sum += array[iend]
iend += 1
end
while istart < iend && sum > goal
sum -= array[istart]
# This document specifies exceptions to the backup
# To specify an EXCLUSION, put "- " (a minus and a space) before the entry
# To specify an INCLUSION, put "+ " (a plus and a space) before the entry
# Rules are applied IN ORDER
#
# These rules allow backing up of the iTunes Music Library files,
# but not the other contents of ~/Music or ~/Music/iTunes/
+ iTunes/
+ .localized
- iTunes Music/