Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
adrienbrault / gist:1035812
Created June 20, 2011 15:19
How to count the number of lines in a source code
find dir -exec cat {} \; | wc -l
@adrienbrault
adrienbrault / gist:1020447
Created June 11, 2011 10:42
Get the current position of an animated view with CoreAnimation
NSView *animatedView = ...;
CALayer *presentationLayer = (CALayer*)animatedView.layer.presentationLayer;
CGPoint currentPosition = presentationLayer.position;
Graphics2D graphics2D = (Graphics2D)graphics;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@interface UINavigationBar (CustomBackground)
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
@end
NSView *myView = ...;
myView.wantsLayer = YES; // The thing you must not forget.
CGPoint newPosition = CGPointMake(100.0, 200.0);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [NSValue valueWithPoint:myView.frame.origin];
animation.toValue = [NSValue valueWithPoint:newPosition];
animation.duration = 1.0;
<?php
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
@adrienbrault
adrienbrault / gist:956984
Created May 5, 2011 12:59
Java fizzbuzz
public class MyFirstProgram {
public static void main(String args[]) {
for(int i = 1; i <= 100; i++) {
boolean mod3 = i % 3 == 0;
boolean mod5 = i % 5 == 0;
boolean lineBreak = (i - 9) % 10 == 0;