Skip to content

Instantly share code, notes, and snippets.

View sag333ar's full-sized avatar

sagar kothari sag333ar

View GitHub Profile
@sag333ar
sag333ar / how_to_setup_fastlane.md
Created July 24, 2022 06:19
How to setup up fastlane on your new iOS project.

Step 1:

bundle init

Step 2:

vi Gemfile

source "https://rubygems.org"
@sag333ar
sag333ar / custom_circle_avatar.dart
Created January 25, 2022 03:54
Custom Circle Avatar
import 'package:flutter/material.dart';
class CustomCircleAvatar extends StatelessWidget {
const CustomCircleAvatar(
{Key? key, required this.height, required this.width, required this.url})
: super(key: key);
final double height;
final double width;
final String url;
@sag333ar
sag333ar / form_factor.dart
Created January 25, 2022 03:53
Flutter - Dart - Get the type of the device based on device width.
import 'package:flutter/material.dart';
enum ScreenType {
desktop,
tablet,
handset,
watch,
}
class FormFactor {
@sag333ar
sag333ar / flutter_seconds_to_duration.dart
Created January 25, 2022 03:52
Flutter - Seconds to Duration
// 4515 seconds to
// (60 * 60 * 1) + (15 * 60) + (15)
// 01:15:15
class Utilities {
static String formatTime(int seconds) {
return '${(Duration(seconds: seconds))}'
.split('.')[0]
.padLeft(8, '0');
}
}
@sag333ar
sag333ar / DeleteSlackUploads.py
Created September 19, 2016 06:55
Delete slack uploads older than 30 days.
import requests
import json
import calendar
from datetime import datetime, timedelta
_token = "your token here"
_domain = "your domain here"
if __name__ == '__main__':
while 1:
@sag333ar
sag333ar / script_1x2x3x.sh
Last active July 26, 2022 12:27
Generate 1x 2x 3x images from supplied 3x assets. Following shell-script can be used for iOS Asset catalogue.
for f in *.png
do
# Process to get File Name & 2x, 3x file names
xNAME=`echo "$f" | cut -d'.' -f1`
cp "$f" "$xNAME@3x.png"
cp "$f" "$xNAME@2x.png"
# Set proper resolution to original file
sips -s dpiHeight 72.0 -s dpiWidth 72.0 "$f"
@sag333ar
sag333ar / transparentNavBar.m
Created October 19, 2015 07:57
Transparent Navigation Bar
- (void)applyTransparencyToNavigationControllersBar:(UINavigationController *)nvCtr {
nvCtr.navigationBar.translucent = YES;
nvCtr.navigationBar.shadowImage = [UIImage new];
nvCtr.view.backgroundColor = [UIColor clearColor];
[nvCtr.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nvCtr.navigationBar.backgroundColor = [UIColor clearColor];
}
@sag333ar
sag333ar / ParseJSONData.swift
Last active October 10, 2015 13:01
Load Data from file & parse JSON in Swift 2
// Swift 2
// try will throw an error if there any &
// catch will directly catch with 'error'
let str:String? = NSBundle.mainBundle().pathForResource("IndiaPost", ofType: "json")
let data:NSData? = NSData(contentsOfFile: str!)
do {
let jsonData:AnyObject? = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments)
@sag333ar
sag333ar / GenerateAppIcons.sh
Last active October 8, 2016 12:14
Generate all Icons in single shot by providing 1024x1024.png as an input.
cp 1024x1024.png AppIcon-20.png
sips -Z 20 AppIcon-20.png
cp 1024x1024.png AppIcon-20@2x.png
sips -Z 40 AppIcon-20@2x.png
cp 1024x1024.png AppIcon-20@3x.png
sips -Z 60 AppIcon-20@3x.png
cp 1024x1024.png AppIcon-29.png
@sag333ar
sag333ar / Exercise3.swift
Last active August 29, 2015 14:27
Exercise3 : Declaring / modifying / displaying an array. Declaring / modifying / displaying key-valued array. Creating empty array & key-valued empty array.
//: Playground - noun: a place where people can play
// The Swift Programming Language
// Basics of Array & key-valued array
import UIKit
var str = "Hello, playground"
// creating / declaring an array
var shoppingList = ["catfish", "water", "tulips", "blue paint"]