Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Afshin Hoseini afshin-hoseini

🎯
Focusing
Block or report user

Report or block afshin-hoseini

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@afshin-hoseini
afshin-hoseini / SegmentedControlTab.js
Created Dec 28, 2018
React native segmented tabbar + render custom items
View SegmentedControlTab.js
import React, { Component } from 'react';
import {
View,
ViewPropTypes,
TouchableOpacity,
StyleSheet,
Text
} from 'react-native';
import PropTypes from 'prop-types';
View react-native-paper.d.ts
// tslint:disable:max-classes-per-file
declare module 'react-native-paper' {
import { Component, ReactNode } from 'react';
import {
StyleProp,
TextProps,
TextStyle,
TouchableHighlightProps,
TouchableNativeFeedbackProps,
ViewProps,
@afshin-hoseini
afshin-hoseini / FMDB pof file
Created Nov 21, 2017
FMDB pof file config for swift 3
View FMDB pof file
pod 'FMDB'#, :git => 'https://github.com/ccgus/fmdb.git', :commit => '1b346b527179f8869d6e8332917c80ac83337ee8'
post_install do |installer|
Dir['Pods/*/**/*.h'].each { |file|
search_text = %q["sqlite3.h"]
replace_text = '<SQLCipher/sqlite3.h>'
oldFile = File.read(file)
if oldFile.include? search_text
@afshin-hoseini
afshin-hoseini / Swizzeling main bundle.swift
Created Nov 20, 2017
Forcing change localization for first iOS application run
View Swizzeling main bundle.swift
//First, define a custom bundle class as like as below
import Foundation
//A key used for exchanging associated object
var _BUNDLE_KEY = 0
class BundleEx : Bundle {
override func localizedString(forKey key: String, value: String?, table tableName: String?) -> String {
@afshin-hoseini
afshin-hoseini / KeyboardBehaviorController.swift
Created Jun 20, 2017
Swift keyboard frame change behavior controller
View KeyboardBehaviorController.swift
//
// KeyboardBehaviorController.swift
// Spot
//
// Created by Afshin on 6/20/17.
// Copyright © 2017 AFE. All rights reserved.
//
import Foundation
import UIKit
@afshin-hoseini
afshin-hoseini / CeoCalc.swift
Last active May 30, 2017
Geometry calculations
View CeoCalc.swift
///Polygon decoder
public func decodePoly(encoded: String) -> [Location]? {
var poly = [Location]()
var index = 0
let len = encoded.length
var lat = 0.0, lng = 0.0
var encodedData = encoded.unicodeScalars
@afshin-hoseini
afshin-hoseini / Module_level_build.gradle
Created Feb 23, 2017
Change android output files in module level build gradle file
View Module_level_build.gradle
//Put this in android block
libraryVariants.all { variant ->
variant.outputs.each { output ->
println("---> Variant name: " + variant.getName())
println("---> Variant base name: " + variant.getBaseName())
println("---> Variant Assemble: " + variant.getAssemble())
@afshin-hoseini
afshin-hoseini / LibLevel_build.gradle
Created Feb 23, 2017
How to enable lambda in Android library
View LibLevel_build.gradle
// Java8 not fully supported in library projects yet, https://code.google.com/p/android/issues/detail?id=211386
// this is a temporary workaround to get at least lambdas compiling
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"
}
}
View DatabaseManager.java
/**
*This method searchs for classes of type DatabaseManager and then checks if they have any public static method annotated
*with @createTables. If exists this will invoke them to make tables database.
*/
protected boolean createTables(SQLiteDatabase db, DatabaseType databaseType)
{
boolean success = true;
if(databaseType == DatabaseType.AppDb) {
View Geometry.java
/*
* (C) 2004 - Geotechnical Software Services
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
You can’t perform that action at this time.