Skip to content

Instantly share code, notes, and snippets.

View farshadmb's full-sized avatar
👨‍💻
Developing

Farshad Mousalou farshadmb

👨‍💻
Developing
View GitHub Profile
@opentaq
opentaq / mailserver.md
Last active June 21, 2024 09:14
Mailserver Installation

Fail2Ban

sudo install fail2ban

UFW

sudo install ufw

UFW Settings

sudu ufw default deny incomoing

sudo ufw default allow outgoins

@Nielio
Nielio / compose.yml
Last active July 1, 2024 17:17
Gitlab CE with build in Container Registry behind Traefik 2 with Letsencrypt
version: "3.6"
services:
gitlab:
image: gitlab/gitlab-ce
volumes:
- gitlab-data:/var/opt/gitlab
- gitlab-logs:/var/log/gitlab
- gitlab-config:/etc/gitlab
networks:
- traefik-public
@orgmir
orgmir / PagingDataExt.kt
Created August 26, 2020 08:19
Extract list of data from a androidx.paging.PagingData object
/**
* Extracts the list of data from a PagingData object.
* Useful for testing transformations on PagingData.
*
* flowOf(PagingData.from(listOf(model)).toList() == listOf(model)
*
* When nothing else is left, Java reflection will always be there to help us out.
*/
@Suppress("UNCHECKED_CAST")
private suspend fun <T : Any> PagingData<T>.toList(): List<T> {
@thsaravana
thsaravana / MyApplication.java
Created March 2, 2020 04:23
To know if App has gone to background or is in foreground
public class MyApplication implements LifecycleObserver {
@Override
public void onCreate() {
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
Log.d("App in foreground");
//
// DayCellView.swift
// T-Shifts
//
// Created by Roberto Esposito on 09/02/2017.
// Copyright © 2017 Roberto Esposito. All rights reserved.
//
import Foundation
import JTAppleCalendar
@sgr-ksmt
sgr-ksmt / AnyObserver+.swift
Last active September 9, 2022 10:07
MVVM + RxSwift + Property Wrapper
extension AnyObserver {
static func create<E>(_ relay: PublishRelay<E>) -> AnyObserver<E> {
return .init { event in
guard case let .next(value) = event else { return }
relay.accept(value)
}
}
static func create<E>(_ relay: BehaviorRelay<E>) -> AnyObserver<E> {
return .init { event in
@nekator
nekator / xcode-install-instructions.md
Last active August 25, 2023 14:24
install Xcode from terminal

1. Download Xcode from https://developer.apple.com/download/more/ (this requeires to Login in with an Apple Developer Account)

At the moment id don´t know how to authenticate so i have no clue to download the xip via curl/wget.
In my case i downloaded the file and copied it via scp to my mac.

eg. for Xcode 9.2 https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_9.2/Xcode_9.2.xip

2. Verify Signature of xip file

pkgutil --verbose --check-signature path/to/xip
@jlnquere
jlnquere / UICollectionViewScroll.swift
Last active June 10, 2022 14:25
XCUITests: scroll UICollectionView to find one of it's offscreen UICollectionViewCell by id
// Thanks to @MonsieurDart for the idea :)
func scroll(collectionView:XCUIElement, toFindCellWithId identifier:String) -> XCUIElement? {
guard collectionView.elementType == .collectionView else {
fatalError("XCUIElement is not a collectionView.")
}
var reachedTheEnd = false
var allVisibleElements = [String]()
while !reachedTheEnd {
@bubbobne
bubbobne / geometry_geojson.yaml
Last active November 2, 2023 19:08
A #swagger #geojson geometry description
#MIT License
#
#Copyright (c) 2017 Daniele Andreis
#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 conditions:
#
@mck-
mck- / routific-local-motion.js
Created March 22, 2016 23:30
Routific solution to Local Motion challenge
var drivingSchedule = {};
var turnNumber = 0;
var MIN_VISITS_PER_VEHICLE = 1; // to keep everyone busy
var OPTIMIZE_EVERY_X_TURNS = 5;
var turn = function(vehicles, people, buildings) {
'use strict';
if(turnNumber % OPTIMIZE_EVERY_X_TURNS === 0 && turnNumber < 1000) {
// Parse data to be suitable for Routific's API