Skip to content

Instantly share code, notes, and snippets.

View drodriguez's full-sized avatar

Daniel Rodríguez Troitiño drodriguez

View GitHub Profile
@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
#! /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}"
}
// 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;
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())
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
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".