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 / braking.md
Created February 14, 2022 20:28 — forked from andrebq/braking.md
Fahrschule

Braking

Standard Braking Distance

  • DE: (Geschwindigkeit / 10) * (Geschwindigkeit / 10)
  • EN: (Speed / 10) * (Speed / 10)

Evasive (Emergency) Braking Distance

  • DE: ((Geschwindigkeit / 10) * (Geschwindigkeit / 10)) / 2
  • EN: ((Speed / 10) * (Speed / 10)) / 2
@afshin-hoseini
afshin-hoseini / SerializedAsyncTasks.js
Created July 10, 2021 15:57
How to serialize asynchronous calls to an async function in javascript
/*
*/
function serialized(fn){
let queue = Promise.resolve();
return (...args)=>{
const res = queue.then(() => fn(...args));
queue = res.catch(() => {});
return res;
@afshin-hoseini
afshin-hoseini / index.html
Created September 4, 2020 17:30
Sticky (gooey) effect using CSS SVG Filters
<div class="bubbles-wrapper bubbles-circle">
<div class="bubble">1</div>
<div class="bubble">2</div>
<div class="bubble">3</div>
<div class="bubble">4</div>
<div class="bubble">5</div>
<div class="bubble">6</div>
</div><!-- remove spaces
--><div class="bubbles-wrapper bubbles-vertical">
<div class="bubble"></div>
@afshin-hoseini
afshin-hoseini / SegmentedControlTab.js
Created December 28, 2018 10:00
React native segmented tabbar + render custom items
import React, { Component } from 'react';
import {
View,
ViewPropTypes,
TouchableOpacity,
StyleSheet,
Text
} from 'react-native';
import PropTypes from 'prop-types';
@afshin-hoseini
afshin-hoseini / react-native-paper.d.ts
Last active December 21, 2018 20:03 — forked from doomsower/react-native-paper.d.ts
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 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
@afshin-hoseini
afshin-hoseini / Swizzeling main bundle.swift
Created November 20, 2017 07:12
Forcing change localization for first iOS application run
//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 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 / 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 / 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())