Skip to content

Instantly share code, notes, and snippets.

View CaliosD's full-sized avatar
🎯
Focusing

Calios CaliosD

🎯
Focusing
  • Ubuntu
View GitHub Profile
@CaliosD
CaliosD / gist:844fde801d7d3bafa11ad1c2f2d68c7c
Created July 8, 2021 06:39 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@CaliosD
CaliosD / debounce-throttle.swift
Created January 19, 2018 02:54 — forked from simme/debounce-throttle.swift
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@CaliosD
CaliosD / CapturedImageSampler.swift
Created November 8, 2017 09:45 — forked from JoshuaSullivan/CapturedImageSampler.swift
The source code for an object that helps you sample RGB values from ARFrames. Save for later use.
//
// CapturedImageSampler.swift
// ARKitTest
//
// Created by Joshua Sullivan on 9/22/17.
// Copyright © 2017 Joshua Sullivan. All rights reserved.
//
import UIKit
import ARKit
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
@CaliosD
CaliosD / gist:1a53796fb4f19cd79cc001058d0b44e5
Created December 2, 2016 03:59 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@CaliosD
CaliosD / PSPDFUIKitMainThreadGuard.m
Created August 12, 2016 09:07 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@CaliosD
CaliosD / iOS-UploadImage.h
Created May 10, 2016 07:22 — forked from mombrea/iOS-UploadImage.h
example of a multi-part form post in objective-c
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
[request setTimeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"unique-consistent-string";
@CaliosD
CaliosD / collectionViewScroll
Created March 29, 2016 08:51 — forked from genedelisa/collectionViewScroll
UICollectionView scroll to make section header visible
/**
Scroll to make the the given section header visible.
The function scrollToItemAtIndexPath will scroll to the item and hide the section header.
*/
func scrollToSection(section:Int) {
if let cv = self.collectionView {
let indexPath = NSIndexPath(forItem: 1, inSection: section)
if let attributes = cv.layoutAttributesForSupplementaryElementOfKind(UICollectionElementKindSectionHeader, atIndexPath: indexPath) {
let topOfHeader = CGPointMake(0, attributes.frame.origin.y - cv.contentInset.top)
@CaliosD
CaliosD / 0_reuse_code.js
Created February 3, 2016 08:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@CaliosD
CaliosD / DateFlowLayout.h
Created December 8, 2015 08:26 — forked from vigorouscoding/DateFlowLayout.h
UICollectionView with sticky headers which works for horizontal as well as vertical scrolling
#import <UIKit/UIKit.h>
@interface DateFlowLayout : UICollectionViewFlowLayout
@end