Skip to content

Instantly share code, notes, and snippets.

View afshin-hoseini's full-sized avatar
🎯
Focusing

Afshin Hoseini afshin-hoseini

🎯
Focusing
View GitHub Profile
@afshin-hoseini
afshin-hoseini / UISearchControllerWithIndicator.swift
Last active February 14, 2016 08:14
A simple UISearchController with an activity indicator at search icon.
//
// UISearchControllerWithIndicator.swift
//
// Created by Afshin Hoseini on 2/10/16.
// https://github.com/afshin-hoseini
//
import Foundation
import UIKit
@afshin-hoseini
afshin-hoseini / puller.php
Created August 18, 2016 13:52
Git web hook puller
<?php
//______________________________________________
function gitInit() {
$currentDir = getcwd();
@afshin-hoseini
afshin-hoseini / Reflection methods in Android
Last active January 7, 2017 05:43
Finding all classes available in an android application.
//To list all methods in android application
public void listAllClasses() {
try {
DexFile df = new DexFile(getPackageCodePath());
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements();) {
String classPath = iter.nextElement();
}
} catch (Exception e) {
@afshin-hoseini
afshin-hoseini / Geometry.java
Created February 7, 2017 07:26
Geometry functions
/*
* (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,
@afshin-hoseini
afshin-hoseini / DatabaseManager.java
Last active February 10, 2017 07:40
Reflection methods
/**
*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) {
@afshin-hoseini
afshin-hoseini / LibLevel_build.gradle
Created February 23, 2017 05:54
How to enable lambda in Android library
// 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"
}
}
@afshin-hoseini
afshin-hoseini / Module_level_build.gradle
Created February 23, 2017 05:56
Change android output files in module level build gradle file
//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 / CeoCalc.swift
Last active May 30, 2017 04:32
Geometry calculations
///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 / KeyboardBehaviorController.swift
Created June 20, 2017 06:56
Swift keyboard frame change behavior controller
//
// KeyboardBehaviorController.swift
// Spot
//
// Created by Afshin on 6/20/17.
// Copyright © 2017 AFE. All rights reserved.
//
import Foundation
import UIKit
@afshin-hoseini
afshin-hoseini / FMDB pof file
Created November 21, 2017 17:31
FMDB pof file config for swift 3
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