A simple memo to draw a matrix on a view, based on view size.
Read MoreC++, tokenize a string
I need a cpp function (without using boost, obv) that split a string in parts using an other string as token.
Example input:
[code lang=”cpp” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]Center: (8.37, 9.86); Radius: 18.13; Point: (17.83, 6.51)[/code]
iOS version?
Just a simple memo!
[code autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”][[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch][/code]
[code autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)[/code]
[code autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]if ( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") )
{
// do something cool
}[/code]
Stupid trick, but useful!
[Python] “Happy 2014!” Without numbers…
Happy 2014!
open terminal, run python and copy/paste:
[code autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]print "Happy " + str(sum(map(ord,’Happy new year to you!’))) + "!"[/code]
have a good year.
2015 version:
[code autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]print "Happy " + str(sum(map(ord,’Happy new year To you!!’))) + "!"[/code]
ref: codegolf
[Objc] Dijkstra algorithm
A simple implementation of Dijkstra algorithm using ATM Metro of Milan to find the best route.
[Objc] Calcolo codice fiscale
Il codice fiscale in Italia è un codice alfanumerico a lunghezza fissa di 16 caratteri, ispirato dall’uso biblioteconomico, che serve a identificare in modo univoco ai fini fiscali e amministrativi i cittadini, le associazioni non riconosciute, i contribuenti e gli stranieri nati e domiciliati nel territorio italiano.
http://it.wikipedia.org/wiki/Codice_fiscale
Nota: questo post è in Italiano, visto che il codice fiscale… è italiano!
Objc – Draw text along UIImage
The NSTextContainer class defines a region in which text is laid out. An NSLayoutManager object uses one or more NSTextContainer objects to determine where to break lines, lay out portions of text, and so on. An NSTextContainer object defines rectangular regions, and you can define exclusion paths inside the text container’s bounding rectangle so that text flows around the exclusion path as it is laid out. You can create subclasses that define regions of nonrectangular shapes, such as circular regions.
Objc – Simple UIImage fade
Implementation of kCATransitionFade to fade an array of images.
Very easy using CATransition animation:
Objc – Digital clock using IBOutletCollection
Today, a simple snippet to learn how to use IBOutletCollection and image spritesin your applications.
IBOutletCollection are introduced with iOS4 as you can see on Apple iOS diff guide ( http://goo.gl/C8NRZz ) and are a collection of IBOutlets.
Maverick & multiple displays
This is the best feature on the new OSX, Maverick (10.9)!