Skip to content

Instantly share code, notes, and snippets.

Avatar

Ahmed Shendy devahmedshendy

  • Egypt
View GitHub Profile
View SwiftRobot-0.1.0.md

SwiftRobot

Tell your Mac what to do, declaratively

What is SwiftRobot?

It is the declarative Layer for RobotKit. It provides several tasks of type RobotTask that helps client define their required tasks in declarative way.

Robot Tasks

  • MouseRobotTask: A Robot task for mouse capability
View UnitsViewModel.swift
final class UnitsViewModel {
// MARK: - Public Members/Methods
let onLoadingMoreUnits = PassthroughSubject<Bool, Never>()
let onInitialResult = PassthroughSubject<[UnitDto], Never>()
let onError = PassthroughSubject<HighLevelError.Reason, Never>()
var moreUnitsToLoad: Bool {
unitsQueue.isNotEmpty
@devahmedshendy
devahmedshendy / DetailFlagImageView.swift
Created September 29, 2021 18:40
Custom ImageView for Country Flags, Each flag should be rounded maintaining its original width & height ratio. So we make subclass of ImageView to update ration constraint for current image, then subclass it to set rounded feature for the current ImageView
View DetailFlagImageView.swift
final class DetailFlagImageView: RatioConstrainedImageView {
//MARK: - Init Methods
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
@devahmedshendy
devahmedshendy / AndroidManifest.xml
Last active September 25, 2020 12:51
Hilt, The DI Library For Android – Part1: Getting To Know
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="learn.shendy.learnhilt">
<application
android:name=".LearnHiltApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
@devahmedshendy
devahmedshendy / MainActivity.kt
Last active August 31, 2020 11:08
USE CASE: Transition Background of Selected Item From Previous Selected Item (Sample: https://youtu.be/2c9Hjo211yE , Demo: https://youtu.be/xrGats2_rBc)
View MainActivity.kt
class MainActivity : AppCompatActivity() {
companion object {
private const val TAG = "MainActivity"
}
private lateinit var mBinding: ActivityMainBinding
private lateinit var mNamesAdapter: NamesAdapter
// MARK: Lifecycle Methods
@devahmedshendy
devahmedshendy / random.md
Last active July 10, 2020 06:48
Secure random values (in Node.js)
View random.md

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@devahmedshendy
devahmedshendy / .gitignore
Last active February 18, 2019 10:51
Common gitignore entries
View .gitignore
# Reference: https://github.com/github/gitignore
target/
infrastrucure/development/database
!.mvn/wrapper/maven-wrapper.jar
# Project #
node_modules/
@devahmedshendy
devahmedshendy / download-m3u8-video-using-ffmpeg.txt
Last active June 30, 2021 22:39
Download M3U8 Video with FFmpeg
View download-m3u8-video-using-ffmpeg.txt
1. To start off, download and install FFmpeg if you haven't already.
2. Next, go to the streaming site from where you want to download and grab the M3U8 video URL
3. Open the command line tool, and type:
ffmpeg -i "http://example.com/video_url.m3u8" -c copy -bsf:a aac_adtstoasc "output.mp4"
reference: https://windowsloop.com/download-m3u8-video-with-ffmpeg