Skip to content

Instantly share code, notes, and snippets.

Avatar

Lukasz Margielewski lukaszmargielewski

View GitHub Profile
View GenericArrayExtension.playground
protocol AProtocol {}
protocol ABProtocol: AProtocol {}
struct ABStruct: ABProtocol {}
struct Wrapper<T> {
let object: T
}
View gist:1a799cab758938e16781
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath isOffscreen:YES];
cell.bounds = CGRectMake(0.0f, 0.0f, CGRectGetWidth(tableView.bounds), 10000);
[cell updateConstraintsIfNeeded];
[cell layoutIfNeeded];
CGFloat heightText = cell.shows_lower_panel ? CGRectGetMaxY(cell.countImageView.frame) : MAX(CGRectGetMaxY(cell.circleImageView.frame), CGRectGetMaxY(ccc.titleLabel.frame));
@lukaszmargielewski
lukaszmargielewski / gist:6b64d06d2d106d110126
Last active Aug 29, 2015
iOS Metal shader searching text naive
View gist:6b64d06d2d106d110126
#include <metal_stdlib>
using namespace metal;
// Every kernel processes 1 row of the char table:
kernel void lmCharSearch(
const device char *charTable [[ buffer(0) ]],
constant uint &charsInRow [[ buffer(1) ]],
constant uint &rowCount [[ buffer(2) ]],
const device char *searchPhrase [[ buffer(3) ]],
@lukaszmargielewski
lukaszmargielewski / gist:0a3b16d4661dd7d7e00d
Last active Nov 17, 2020
iOS Metal client side code for compute pipeline
View gist:0a3b16d4661dd7d7e00d
// For stackoverflow question:
// http://stackoverflow.com/questions/30445801/ios8-metal-compute-pipeline-slower-than-cpu
// I. CODE INVOKED ONCE, AT THE INIT STAGE:
_mtlCharTable = [_mtlDevice newBufferWithBytes:_charTable->pointer length:_charTable->bytesTotal options:0];
_mtlSearchMasks = [_mtlDevice newBufferWithBytesNoCopy:_searchIndexes.mask length:_searchIndexes.bytesTotalMask options:0 deallocator:nil];
//iPhone 6: maxTotalThreadsPerThreadgroup: 512, threadExecutionWidth: 32
uint threadsPerThreadGroup = [_mtlComputePipelineState maxTotalThreadsPerThreadgroup];// / 4.0;
You can’t perform that action at this time.