Skip to content

Instantly share code, notes, and snippets.

@numo16
numo16 / MemoryMonito.cs
Created Feb 14, 2013
Windows Phone Memory Monitor utility class
View MemoryMonito.cs
public sealed class MemoryMonitor : IDisposable
{
#region Private members
private bool _isEnabled;
private bool _showVisualization;
private bool _isInitialized;
private bool _currentWarningExceeded;
private bool _currentCriticalExceeded;
private DispatcherTimer _timer;
private Popup _popup = new Popup();
@numo16
numo16 / PropertyChangedViewModel.cs
Created Jan 17, 2013
INotifyPropertyChanged Implementation
View PropertyChangedViewModel.cs
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged<T>(Expression<Func<T>> propertyEvaluator)
{
var lambda = propertyEvaluator as LambdaExpression;
var member = lambda.Body as MemberExpression;
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(member.Member.Name));
@numo16
numo16 / CCUtils.cs
Created Dec 12, 2012
Helper methods for Cocos2d-xna
View CCUtils.cs
public class CCUtils
{
public static CCRect CCRectIntersection(CCRect r1, CCRect r2)
{
CCRect intersection = new CCRect(Math.Max(CCRect.CCRectGetMinX(r1), CCRect.CCRectGetMinX(r2)), Math.Max(CCRect.CCRectGetMinY(r1), CCRect.CCRectGetMinY(r2)), 0, 0);
intersection.size.width = Math.Min(CCRect.CCRectGetMaxX(r1), CCRect.CCRectGetMaxX(r2)) -
CCRect.CCRectGetMinX(intersection);
intersection.size.height = Math.Min(CCRect.CCRectGetMaxY(r1), CCRect.CCRectGetMaxY(r2)) -
CCRect.CCRectGetMinY(intersection);
return intersection;
@numo16
numo16 / Macros.h
Created Aug 20, 2012
Some useful iOS/Objective-C Macros
View Macros.h
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
You can’t perform that action at this time.