Skip to content

Instantly share code, notes, and snippets.

View osamaqarem's full-sized avatar

Osama Qarem osamaqarem

View GitHub Profile
@osamaqarem
osamaqarem / CircularProgressBar.java
Created August 20, 2023 15:23
Android: Overlay with Circle Cutout ViewGroup
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
@osamaqarem
osamaqarem / ng.fish
Last active June 19, 2024 04:43
fish functions: start ngrok and copy url to clipboard
function ng --description "ng <port>"
if test -z "$argv[1]"
set port 3000
else
set port $argv[1]
end
# Run ngrok in the background
ngrok http $port > /dev/null &
@osamaqarem
osamaqarem / Accordion.tsx
Last active August 20, 2023 17:47
Accordion.tsx
import * as React from 'react';
import { LayoutAnimation, Pressable, PressableProps } from 'react-native';
type ChildrenOrRenderProp = React.ReactNode | ((mode: Context['mode']) => React.ReactNode);
type RewriteChildren<PropsType = Record<string, unknown>> = React.FC<
Omit<PropsType, 'children'> & { children?: ChildrenOrRenderProp }
>;
interface Context {
import * as React from 'react'
import { Image, StatusBar, StyleSheet, useWindowDimensions } from 'react-native'
import {
PanGestureHandler,
PinchGestureHandler,
PinchGestureHandlerGestureEvent,
TapGestureHandler,
TapGestureHandlerGestureEvent,
} from 'react-native-gesture-handler'
import Animated, {
@osamaqarem
osamaqarem / CalculateTextureMatrix.Java
Created January 8, 2021 07:06
Android Reverse Camera Matrix
public Matrix calculateTextureMatrix(TextureView textureView, View previewView) {
Matrix matrix = new Matrix();
Camera.Size previewSize = mICamera.mCamera.getParameters().getPreviewSize();
float actualPreviewWidth = previewSize.width;
float actualPreviewHeight = previewSize.height;
float previewWidth = previewView.getWidth();
float previewHeight = previewView.getHeight();
int deviceAndCameraAngleDiff = mICamera.getCameraAngle(this);
@osamaqarem
osamaqarem / BestAspectRatio.java
Created January 7, 2021 05:40
Calculate Closest Aspect Ratio
private Camera.Size calBestPreviewSize(Camera.Parameters camPara,
final int width, final int height) {
List<Camera.Size> allSupportedSize = camPara.getSupportedPreviewSizes();
ArrayList<Camera.Size> widthLargerSize = new ArrayList<Camera.Size>();
for (Camera.Size tmpSize : allSupportedSize) {
if (tmpSize.width > tmpSize.height) {
widthLargerSize.add(tmpSize);
}
}
@osamaqarem
osamaqarem / build.sh
Created January 7, 2021 03:24
Building XCFramework
#!/bin/bash
user=$(id -un)
rm -rf ProjectName.xcframework && \
xcodebuild archive \
-workspace ProjectName.xcworkspace \
-scheme ProjectName \
-destination "generic/platform=iOS" \
-archivePath "archives/ios" \
SKIP_INSTALL=NO \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO \
@osamaqarem
osamaqarem / nginx_macos.md
Last active July 31, 2024 15:46
Nginx on MacOS

Install nginx (Homebrew)

brew install nginx

Configuration file for nginx will be at /usr/local/etc/nginx/nginx.conf

Web apps can be stored at /usr/local/var/www

Commands

Start:

@osamaqarem
osamaqarem / live_templates.md
Last active August 20, 2023 15:25
Android Java Boilerplate

inffrag

    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.$LAYOUT$, container, false);
    ButterKnife.bind(this, view);

    return view;

spinneradapt

@osamaqarem
osamaqarem / .sh
Last active April 14, 2020 10:09
ADB Remote
# Connect device over USB
# Get device IP
adb shell ip -f inet addr show wlan0
# Define port
adb tcpip 5555
# Connect
adb connect {device ip}:5555
# Disconnect USB