Skip to content

Instantly share code, notes, and snippets.

View erfanium's full-sized avatar
👋
Never been too big, to not want to learn.

Erfan Safari erfanium

👋
Never been too big, to not want to learn.
View GitHub Profile
mFirebaseAnalytics!!.appInstanceId.addOnCompleteListener { task ->
if (task.isSuccessful) {
Ext.logD("mFirebaseAnalytics:appInstanceId", task.result ?: "appInstanceId is null")
} else {
Ext.logD("mFirebaseAnalytics:appInstanceId", "Failed to get appInstanceId: ${task.exception?.message}")
}
}
mFirebaseAnalytics!!.sessionId.addOnCompleteListener { task ->
if (task.isSuccessful) {
@erfanium
erfanium / mount.sh
Created July 6, 2024 22:35
mount Liara bucket in Linux
export AWSACCESSKEYID=KEY_ID
export AWSSECRETACCESSKEY=SECRET
s3fs private-space /mnt/cloud -o use_path_request_style -o url=https://storage.c2.liara.space:443 -o uid=1000 -o gid=1000 -o umask=0002 -o allow_other
@erfanium
erfanium / bucket.ts
Created July 2, 2024 10:02
bucket url pattern
import {
BucketItem,
BucketStream,
Client,
ItemBucketMetadata,
RemoveOptions,
UploadedObjectInfo,
} from 'minio';
import pino from 'pino';
import { Readable } from 'stream';
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
# The line below is changed.
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
@erfanium
erfanium / README.md
Created May 31, 2024 12:15
systemd config file for warp-plus

Alright, let's make that happen with systemd on Ubuntu 22.04. Follow these steps:

  1. Create a systemd service file: Open a terminal and create a new service file for your command.

    sudo nano /etc/systemd/system/warp-plus.service
  2. Add the service configuration:

@erfanium
erfanium / tabby_bench.sh
Created November 15, 2023 19:19
Simple benchmark script for tabby
npx autocannon \
-m POST \
--header 'Content-Type: application/json' \
-c 5 \
--duration 60 \
--body '{"language":"python","segments":{"prefix":"def binarySearch(arr, left, right, x):\\n mid = (left +", "suffix": ""}}' \
http://localhost:8080/v1/completions
@erfanium
erfanium / worker.js
Last active January 25, 2024 23:34
sentry tunnel via cloudflare workers
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Max-Age": "86400",
};
// Set known project IDs for the Sentry projects you want to accept through this proxy
const knownProjectIds = []; // TODO: fill this
@erfanium
erfanium / new-background.sh
Created January 7, 2023 23:15
randomly change ubuntu background
# Generate the query string by concatenating the arguments with commas
QUERY=$(printf ',%s' "$@")
QUERY=${QUERY:1} # remove leading comma
# Use xrandr to get the screen resolution
SCREEN_RES=$(xrandr --current | grep '*' | uniq | awk '{print $1}')
# Download the wallpaper and set it as the background
wget -O /tmp/wallpaper.jpg "https://source.unsplash.com/$SCREEN_RES/?$QUERY"
gsettings set org.gnome.desktop.background picture-uri file:///tmp/wallpaper.jpg
@erfanium
erfanium / gist:f63fa33a393ab66d935240d0c531c5ba
Created September 21, 2021 13:02
Fix android 11 canLaunch always false bug
https://github.com/flutter/flutter/issues/63727
@erfanium
erfanium / lifecycle.xml
Last active April 13, 2021 13:19
S3 expire all objects in bucket after X days
<LifecycleConfiguration>
<Rule>
<ID>expire</ID>
<Filter>
<Prefix></Prefix>
</Filter>
<Status>Enabled</Status>
<Expiration>
<Days>X</Days>
</Expiration>