This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| enum Either<A, B> { | |
| case Left(@auto_closure () -> A) | |
| case Right(@auto_closure () -> B) | |
| func fold<X>(fa: A -> X, fb: B -> X) -> X { | |
| switch self { | |
| case let .Left(a): return fa(a()) | |
| case let .Right(b): return fb(b()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass { | |
| var enabled: Bool? { | |
| didSet { | |
| if let v = enabled? { | |
| self.enabled = v ? true : nil | |
| } | |
| } | |
| } | |
| init(enabled: Bool) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You can have a recursive function | |
| func fact(n: Int) -> Int { | |
| if n < 2 { return 1 } | |
| return n * fact(n - 1) | |
| } | |
| // But you cannot have a recursive closure | |
| // let fact2: Int -> Int = { n in | |
| // if n < 2 { return 1 } | |
| // return n * fact2(n - 1) // ERROR: Variable used within its own initial value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "Kiwi.h" | |
| #define KWPasteX(x, y) x ## y | |
| #define KWPaste(x, y) KWPasteX(x, y) | |
| #define KWMetaMacro(...) \ | |
| if (0) \ | |
| KWPaste(finished, __LINE__): ; \ | |
| else \ | |
| for (KWVoidBlock KWPaste(block, __LINE__) = nil;;) \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol TestProtocol { | |
| } | |
| class TestClass : TestProtocol { | |
| } | |
| class TestClass2 { | |
| } | |
| struct Test { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| int test1(int32_t (*array)[10]) { | |
| return 1; | |
| } | |
| int test2(int32_t (*array)[5]) { | |
| return 2; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; |
OlderNewer