Skip to content

Instantly share code, notes, and snippets.

View sag333ar's full-sized avatar

sagar kothari sag333ar

View GitHub Profile
@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 / 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 / getIPAddress.m
Last active June 23, 2017 14:12
Put this method into your class & you can obtain the IP address of current device.
// get the IP address of current-device
- (NSString *)getIPAddress {
NSString *address = @"error";
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
// retrieve the current interfaces - returns 0 on success
success = getifaddrs(&interfaces);
if (success == 0) {
// Loop through linked list of interfaces
@sag333ar
sag333ar / iOSMacAddress.m
Last active June 23, 2017 14:12
Get iOS MAC address
/* Original source code courtesy John from iOSDeveloperTips.com */
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
+ (NSString *)getMacAddress
{
int mgmtInfoBase[6];
@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 / 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 / CreateMenu
Last active September 14, 2016 12:02
Create Menu with MenuItemFont in Cocos2d-x
void HelloWorld::createMenuFunction()
{
// set the font for menu with text
MenuItemFont::setFontSize(20);
// create first menu item
auto menuItemFirst = MenuItemFont::create("First menu item", CC_CALLBACK_1(HelloWorld::firstMenuButtonTapped, this));
// CC_CALLBACK_1 is a macro which helps to indicate function pointer. Here, on click menu,
// 'firstMenuButtonTapped' method will get invoked