This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
let calendar = NSCalendar.currentCalendar() | |
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond | |
let now = NSDate() | |
let earliest = now.earlierDate(date) | |
let latest = (earliest == now) ? date : now | |
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil) | |
if (components.year >= 2) { | |
return "\(components.year) years ago" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String getJwtToken(String simId, String uid, String secret) { | |
HashMap<String, Object> hashMap = new HashMap<>(); | |
hashMap.put("sim", simId); | |
hashMap.put("uid", uid); | |
hashMap.put("provider", "CRD"); | |
long initDate = System.currentTimeMillis() / 1000L; | |
long expDate = initDate + 1000 + 60 + 60; | |
return Jwts.builder() | |
.setHeaderParam("typ", "JWT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<data> | |
<messages> | |
<ccp_dialog_title translation="اختار دولة"/> | |
<ccp_dialog_search_hint_message translation="بحث"/> | |
<ccp_dialog_no_result_ack_message translation=" لا يوجد نتائج"/> | |
</messages> | |
<countries> | |
<country |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.api; | |
import java.util.Map; | |
import retrofit.Call; | |
import retrofit.http.Body; | |
import retrofit.http.GET; | |
import retrofit.http.POST; | |
public interface Api { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Build | |
import android.text.Html | |
import android.widget.Button | |
import android.widget.TextView | |
/** | |
* Created by ahmedwahdan | |
*/ | |
var TextView.coloredText: String | |
get() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PhoneUtils { | |
public static final String TAG = "PhoneUtils"; | |
private static PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); | |
public static Phonenumber.PhoneNumber getValidPhoneNumber(String countryCode, String phoneNumberStr) { | |
return getValidPhoneNumber(countryCode.concat(phoneNumberStr)); | |
} | |
public static String getValidPhoneNumberStr(String countryCode, String phoneNumberStr) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sendmail = require('sendmail')({ silent: true }); | |
const nodemailer = require('nodemailer'); | |
class Mail { | |
constructor(options) { | |
this.transporter = null; | |
this.options = Object.assign({ | |
smtp: null, | |
verificationSubject: 'Please activate your email address', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final Get get = Get(); | |
print(get.get); | |
} | |
class Get { | |
String get get => "Hello Get"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final list = ['a', 'b', 'c']; | |
list.mapIndex((i, index) { | |
print("item $i inddex $index "); | |
}).toList(); | |
print("==============="); | |
list.forEachIndex((i, index) { | |
print("item $i inddex $index "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:image/image.dart' as Im; | |
import 'package:path_provider/path_provider.dart' show getTemporaryDirectory; | |
Future<File> imageCompress(File file,{int maxFileSize = 3}) async { | |
Im.Image image = Im.decodeImage( file.readAsBytesSync()); | |
Im.Image smallerImage = Im.copyResize(image, width: image.width ~/ 2); | |
final appPath = await getTemporaryDirectory(); | |
file = File('${appPath.path}/img_c${DateTime.now().millisecondsSinceEpoch}.jpg') |
OlderNewer