Skip to content

Instantly share code, notes, and snippets.

View romy-aikon's full-sized avatar

romy-aikon

  • Nokia Bell Labs
  • Sunnyvale
View GitHub Profile
@romy-aikon
romy-aikon / Dangerfile
Last active August 24, 2018 22:08 — forked from candostdagdeviren/Dangerfile
Dangerfiles to like
# PR is a work in progress and shouldn't be merged yet
warn "PR is classed as Work in Progress" if github.pr_title.include? "[WIP]"
# Warn when there is a big PR
warn "Big PR, consider splitting into smaller" if git.lines_of_code > 500
# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ }
fail "Please rebase to get rid of the merge commits in this PR"
end
@romy-aikon
romy-aikon / remove-big-file.sh
Created July 25, 2018 00:20 — forked from BrunoGrandePhD/remove-big-file.sh
Remove a large committed file from your Git repository.
# The commands below are a guide to remove a large file that has been
# accidentally committed to a Git repository's history. If the file is
# larger than 100 MB, GitHub will prevent you from pushing your latest
# commits. The annotated steps below should help you remove the large
# file from your commit history, even if you've made new commit since.
# Some Git users advise against rebasing. You can safely use it here
# because you haven't published your changes yet.
# So, you first need to rebase your current branch onto the point that
@romy-aikon
romy-aikon / Hairline.swift
Created January 31, 2018 21:41 — forked from jemmons/Hairline.swift
Draws a `singlePixelLine` line above or below the given point, depending on `topBias`.
import UIKit
func singlePixelLine(at y: CGFloat, in rect: CGRect, topBias: Bool = true) {
let offset = pixelUnit/2.0
let adjustedY = round(from: y - offset, fraction: pixelUnit, down: topBias) + offset
let line = makeLine(at: adjustedY, in: rect)
strokePath(line, width: pixelUnit)
}
@romy-aikon
romy-aikon / reconfigureVisibleCells.m
Created January 25, 2018 20:06 — forked from kristopherjohnson/reconfigureVisibleCells.m
Update visible cells from a UITableViewController without calling -[UITableView reloadData]
- (void)reconfigureVisibleCells
{
NSInteger sectionCount = [self numberOfSectionsInTableView:self.tableView];
for (NSInteger section = 0; section < sectionCount; ++section) {
NSInteger rowCount = [self tableView:self.tableView numberOfRowsInSection:section];
for (NSInteger row = 0; row < rowCount; ++row) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
@romy-aikon
romy-aikon / DrawAntiRoundedCornerImage.md
Created January 9, 2018 19:59 — forked from seedante/DrawAntiRoundedCornerImage.md
Draw a mask image with Core Graphics API in Swift

MaskImage

Draw a mask image like Left-3 to blend a rounded corner:

func UIGraphicsDrawAntiRoundedCornerImageWithRadius(radius: CGFloat, outerSize: CGSize, innerSize: CGSize, fillColor: UIColor) -> UIImage{  
    UIGraphicsBeginImageContextWithOptions(outerSize, false, UIScreen.mainScreen().scale)
    let currentContext = UIGraphicsGetCurrentContext()

let bezierPath = UIBezierPath()

@romy-aikon
romy-aikon / SKImage.swift
Created January 9, 2018 00:42 — forked from jakelazaroff/SKImage.swift
A simple class that draws a PaintCode StyleKit "Image Method" image centered inside a UIView
// SKImage
// A simple class that draws a PaintCode StyleKit "Image Method" image centered inside a UIView
// - installation: add to project and replace STYLEKIT_NAME comment with name of StyleKit class
// - instantiation: SKImage(image: "NameOfImage")
// - instantiation (with custom size): SKImage(image: "NameOfImage", size: CGRectMake(0, 0, 16, 16))
import UIKit
class SKImage: UIView {
@romy-aikon
romy-aikon / Arbitrary rotation of a CGImage
Created January 8, 2018 23:53 — forked from mjarvis/Arbitrary rotation of a CGImage
Grayscale for CGContextClipToMask
- (CGImageRef)CGImageRotatedByAngle:(CGImageRef)imgRef angle:(CGFloat)angle
{
CGFloat angleInRadians = angle * (M_PI / 180);
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect imgRect = CGRectMake(0, 0, width, height);
CGAffineTransform transform = CGAffineTransformMakeRotation(angleInRadians);
CGRect rotatedRect = CGRectApplyAffineTransform(imgRect, transform);
@romy-aikon
romy-aikon / Demo.c
Created December 16, 2017 00:54 — forked from mikeando/Demo.c
Example of using C++ from C.
#include "HMyClass.h"
#include <stdio.h>
void my_eh( const char * error_message, void * unused)
{
printf("my_eh: %s\n", error_message);
}
int main()
{
@romy-aikon
romy-aikon / imagerequest.m
Created December 12, 2017 22:47 — forked from boaerosuke/imagerequest.m
Perform a VNCoreMLRequest with VNImageRequestHandler
NSDictionary *options_dict = [[NSDictionary alloc] init];
NSArray *request_array = @[request];
VNImageRequestHandler *handler = [[VNImageRequestHandler alloc] initWithCIImage:self.imageToDetect options:options_dict];
dispatch_queue_t myCustomQueue;
myCustomQueue = dispatch_queue_create("com.aname.VNImageRequestHandlerQueue", NULL);
self.resultLabel.text = @"Predicting...";
dispatch_sync(myCustomQueue, ^{
[handler performRequests:request_array error:nil];
@romy-aikon
romy-aikon / BitShift.txt
Created September 18, 2017 17:39 — forked from unitycoder/BitShift.txt
Bitshift CheatSheet
// TODO
// MULTIPLY
a=1
a << 1 == a*2 [ a=2 ]
a << 2 == a*4 [ a=4 ]
a << 3 == a*8 [ a=8 ]
x/255 == (x+1+((x+1)>>8))>>8 // integer div 255 for [0..65790)