Skip to content

Instantly share code, notes, and snippets.

View Amosel's full-sized avatar

Amos Elmaliah Amosel

View GitHub Profile
/*
Copyright (c) 2009 Remy Demarest
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
/*
in the place where you init the navigationController:
fixer = [[AENavigationControllerDelegate alloc] init];
navigationController.delegate = fixer;
*/
@interface AENavigationControllerDelegate : NSObject <UINavigationControllerDelegate>
/*
iOS5 UIViewControllers introduced API changes with the parentViewController.
I'm not 100% clear why this needs to be break existing code:
calling parentViewController the second time on a UINavigationController returns nil.
For instance to insert controllers to a bottom navigationtion stack.
So instead simply call presentingViewController to get the bottom UINavigationController.
*/
if ([self respondsToSelector:@selector(presentingViewController)])
{
@implementation UIImage (AmosAddtions)
+(UIImage*) imageWithFirstRowOfImageNamed:(NSString*)imageName
{
UIImage* firstImage = [UIImage imageNamed:imageName];
UIImage* newImage = nil;
if (firstImage)
{
UIGraphicsBeginImageContext(CGSizeMake(1, firstImage.size.height));
[firstImage drawAtPoint:CGPointMake(0, 0)];
newImage = UIGraphicsGetImageFromCurrentImageContext();
import Foundation
public protocol KeyValueIdentifier
{
associatedtype ValueType
var key : String { get }
}
public struct ValueIdentifier <T> : KeyValueIdentifier
{
@Amosel
Amosel / Podfile
Created July 24, 2016 01:35
Disable Mixpanel's AB Testing.
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'Mixpanel'
target.build_configurations.each do |config|
puts " Pods-Mixpanel #{config.name} before: #{config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].inspect}"
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'DISABLE_MIXPANEL_AB_DESIGNER=1'
puts " Pods-Mixpanel #{config.name} after: #{config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].inspect}"
end
end
extension Array {
func toDictioary<K: Hashable, V>(transform: @escaping (_ element:Element) -> (key: K, value: V)? ) -> [K : V] {
var result : [K : V] = [:]
forEach {
if let (key, value) = transform($0) {
result[key] = value
}
}
return result
}
Scanning folders for symlinks in react-native-fiber-1.0.0/node_modules (14ms)
15:29:33: Starting packager...
***ERROR STARTING PACKAGER***
Warning: You are using npm version 5.5.1. There may be bugs in this version, use it at your own risk. We recommend version 4.6.1.
Starting React Native packager...
Scanning folders for symlinks in react-native-fiber-1.0.0/node_modules (55ms)
Loading dependency graph.
@Amosel
Amosel / index.js
Created August 27, 2019 21:42
hr.gs/mob-frontend
const { writeFile } = require('fs')
const fetchUsers = () =>
new Promise(r => {
setTimeout(() => {
r([
{
name: "amos",
id: "amos"
},
@Amosel
Amosel / machine.js
Created January 7, 2020 19:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions