Skip to content

Instantly share code, notes, and snippets.

View lamprosg's full-sized avatar

Lampros Giampouras lamprosg

  • Athens, Greece
View GitHub Profile
@lamprosg
lamprosg / xibInsteadOfStoryboard.swift
Created June 14, 2018 18:04
(iOS) Root XIB instead of storyboard
//Delete main storyboard
//Delete it from target - General - Deployment info - Main interface
//Delete derived data
// In appDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let homeViewController = ViewController()
window!.rootViewController = homeViewController
window!.makeKeyAndVisible()
//To create a new project with CocoaPods, follow these simple steps:
//Create a new project in Xcode as you would normally.
//Open a terminal window, and $ cd into your project directory.
/Create a Podfile. This can be done by running $ pod init.
pod init
//In podfile
@lamprosg
lamprosg / FileManager.mm
Last active July 18, 2017 11:07
(iOS) Secure file saving
#define FILE_PASSWORD_BYTES_LENGTH 16
NSString *const MAIN_ENCRYPTION_SERVICE_NAME = @"com.yourDomain.Keychain.MainEncryption";
#pragma mark - Stored files
- (NSString *)writeDataToEncryptedFile:(NSData *)theData withName:(NSString *)theName forAccount:(NSString*)account {
NSData *readyToStoreData = [self encryptData:theData withPassword:[self getPasswordForAccount:account]];
@lamprosg
lamprosg / NSObject+Swizzling.h
Last active March 31, 2016 08:37
(iOS) Swizzling Image Example
#import <Foundation/Foundation.h>
@interface NSObject (Swizzling)
+ (void)swizzleInstanceSelector:(SEL)originalSelector
withNewSelector:(SEL)newSelector;
@lamprosg
lamprosg / c-mask.mm
Last active May 26, 2022 15:29
(iOS) Image masking Objective-C / Swift
//http://www.innofied.com/implementing-image-masking-in-ios/
- (UIImage*) maskImage:(UIImage *) image withMask:(UIImage *) mask
{
CGImageRef imageReference = image.CGImage;
CGImageRef maskReference = mask.CGImage;
CGImageRef imageMask = CGImageMaskCreate(CGImageGetWidth(maskReference),
CGImageGetHeight(maskReference),
CGImageGetBitsPerComponent(maskReference),
@lamprosg
lamprosg / JSONSnippets.mm
Last active February 27, 2016 13:04
(iOS) - JSON parsing snippets
//Init a class model from a NSDictionary
- (id)initWithDictionary:(NSDictionary*)dictionary {
if(!dictionary || [dictionary isKindOfClass:[NSNull class]]) {
return nil;
}
self = [super init];
if(self) {
@lamprosg
lamprosg / TableviewwithCustomCIBCell.mm
Last active June 20, 2018 06:33
(iOS) Reusable cell with separate xib
/************************/
//Optional Reference link
//https://medium.com/@musawiralishah/creating-custom-uitableviewcell-using-nib-xib-files-in-xcode-9bee5824e722
/************************/
//Add an empty view to your project
//New file -> iOS / User Interface -> Empty
//Drag a UITableViewCell onto it and fix it how you want
//Make a custom UITableViewCell class
Το καλύτερο είναι πάντα το tutorials point
http://www.tutorialspoint.com/csharp/
Μάλλον δείτε καλύτερα το menu “C# Advanced Tutorial” αφού τα άλλα τα ξέρετε.
Αν δεν καταλάβετε τα events (αν χρειαστούν) δείτε εδώ:
http://www.codeproject.com/Articles/11541/The-Simplest-C-Events-Example-Imaginable
Για τα xml (serialisation/deserialisation):
http://www.codeproject.com/Articles/483055/XML-Serialization-and-Deserialization-Part
@lamprosg
lamprosg / dpkeyboard.mm
Created June 10, 2015 08:22
(iOS) - DatePicker as keyboard
- (void) initializeTextFieldInputView {
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectZero];
datePicker.datePickerMode = UIDatePickerModeDate;
datePicker.minuteInterval = 5;
datePicker.backgroundColor = [UIColor whiteColor];
[datePicker addTarget:self action:@selector(dateUpdated:) forControlEvents:UIControlEventValueChanged];
self.textField.inputView = datePicker;
//Add done button
@lamprosg
lamprosg / objects.js
Last active August 29, 2015 14:21
(Javascript) - Creating objects with inheritance
function Employee() {
this.name = "";
this.dept = "general";
}
function WorkerBee() {
Employee.call(this);
this.projects = [];