Skip to content

Instantly share code, notes, and snippets.

@moallemi
moallemi / API.kt
Created June 1, 2023 07:25
Grid Challenge API Helper for Android
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
suspend fun fetchPhotos(): List<Photo> = withContext(Dispatchers.IO){
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api.unsplash.com/photos?order_by=popular&orientation=squarish&per_page=40")
@moallemi
moallemi / API.swift
Created June 1, 2023 07:20
Grid Challenge API Helpers
func fetchPhotos() async throws -> [Photo] {
let url = URL(string: "https://api.unsplash.com/photos?order_by=popular&orientation=squarish&per_page=40")!
var request = URLRequest(url: url)
request.addValue("Client-ID REPLACE_WITH_ACCESS_KEY", forHTTPHeaderField: "Authorization")
let (data, _) = try await URLSession.shared.data(for: request)
let photos = try JSONDecoder().decode([Photo].self, from: data)
return photos
}
@moallemi
moallemi / git-change-author.sh
Last active May 21, 2021 07:18
Change git commit author for multiple commits
git filter-branch --env-filter '
WRONG_EMAIL="OLD_EMAIL"
NEW_NAME="NEW_NAME"
NEW_EMAIL="NEW_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@moallemi
moallemi / Shop.kt
Last active November 7, 2020 07:57
data class Shop(val name: String, val customers: List<Customer>)
data class Customer(val name: String, val city: City, val orders: List<Order>)
data class Order(val products: List<Product>, val isDelivered: Boolean)
data class Product(val name: String, val price: Double)
data class City(val name: String)
body,
#container {
font-family: 'Segoe UI', 'Verdana', 'Arial', 'iransans', sans-serif;
}
textarea,
p {
font-family: "Droid Sans", "iranian sans", iransans !important;
line-height: 25px;
}
@moallemi
moallemi / delete-likes-from-twitter.md
Created September 25, 2020 07:01 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }
@moallemi
moallemi / Auto Budget Script
Last active March 29, 2020 14:45
Google app script for Auto Budget Android app
We couldn’t find that file to show.
@moallemi
moallemi / alias.gitconfig
Last active March 5, 2020 09:13
A collection of most useful git commands aliases
[alias]
st = status
d = diff
dh = diff HEAD
co = checkout
sp = submodule foreach git pull
ci = commit
mq = merge --squash
amend = commit --amend --no-edit
### Keybase proof
I hereby claim:
* I am moallemi on github.
* I am moallemi (https://keybase.io/moallemi) on keybase.
* I have a public key whose fingerprint is AF2E 72F5 82B0 5D4D EECC 0D5F C81F 1C03 33D1 3238
To claim this, I am signing this object: