Skip to content

Instantly share code, notes, and snippets.

View ltebean's full-sized avatar

Leo ltebean

  • Shanghai, China
View GitHub Profile
//
// GPUImageTextureInput+CIImage.h
// GPUImage
//
// Created by Sam Soffes on 3/4/14.
// Copyright (c) 2014 Sam Soffes. All rights reserved.
//
#import "GPUImageTextureInput.h"
CREATE TABLE if NOT EXISTS users (
user_id SERIAL PRIMARY KEY,
app_user_id TEXT NOT NULL DEFAULT '',
push_id TEXT NOT NULL DEFAULT '',
device_id TEXT NOT NULL DEFAULT '',
sys_properties JSONB NOT NULL DEFAULT '{}',
user_properties JSONB NOT NULL DEFAULT '{}',
time_created TIMESTAMPTZ NOT NULL DEFAULT now(),
time_updated TIMESTAMPTZ NOT NULL DEFAULT now()
);
INSERT INTO users(app_user_id) SELECT user_id FROM generate_series(1,1000000) user_id;
INSERT INTO events(user_id, event_name, event_time, event_properties)
SELECT trunc(random() * 900000 + 1), trunc(random() * 10 + 1)::text
,NOW() - '1 hour'::INTERVAL * (random() * 1000 + 1), '{"age": 80}'
FROM generate_series(1,10000000) id;
SELECT count(*) FROM events
CREATE STREAM kafka_event_stream(message json);
CREATE STREAM event_stream(app_id text, user_id INT, event_name text, event_time timestamp)
CREATE CONTINUOUS TRANSFORM t AS
SELECT
app_id::text AS app_id,
cast(event::json ->> 'userId' AS int) AS user_id,
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>f2e/node_modules/**</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=false
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self load];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
@ltebean
ltebean / gist:943c5549214729e196e3
Created March 10, 2016 09:18
mask layer animation
let rect = CGRectMake(10, 10, 30, 30)
let extremePoint = CGPoint(x: CGRectGetWidth(view.bounds), y: CGRectGetHeight(view.bounds))
let circleMaskPathInitial = UIBezierPath(ovalInRect: CGRectMake(10, 10, 30, 30))
let radius = sqrt((extremePoint.x * extremePoint.x) + (extremePoint.y * extremePoint.y))
let circleMaskPathFinal = UIBezierPath(ovalInRect: CGRectInset(rect, -radius, -radius))
let maskLayer = CAShapeLayer()
maskLayer.path = circleMaskPathInitial.CGPath
view.layer.mask = maskLayer
@ltebean
ltebean / gist:1b15535f3f1892dd76a5
Last active October 12, 2016 07:00
animate window.rootViewController
class AppCoordinator: NSObject {
var window: UIWindow!
static let shared = AppCoordinator()
func goToHome() {
let target = R.storyboard.home.home()!
animateTo(vc: target)
}

iOS and Objective-C snippets

Move content from underneath the navigationBar (iOS 7)

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    [self setEdgesForExtendedLayout:UIRectEdgeRight|UIRectEdgeBottom|UIRectEdgeLeft];
}

Change the color of the back arrow in navigationBar (iOS 7)