Skip to content

Instantly share code, notes, and snippets.

View WahdanZ's full-sized avatar
🐧
Bazinga!!

Ahmed Wahdan WahdanZ

🐧
Bazinga!!
View GitHub Profile
@WahdanZ
WahdanZ / timeago.swift
Created December 2, 2017 17:39 — forked from minorbug/timeago.swift
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C)
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"
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")
<?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
@WahdanZ
WahdanZ / Api.java
Created February 17, 2018 16:02 — forked from imminent/Api.java
Call retrying with Retrofit 2.0
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 {
@WahdanZ
WahdanZ / ColoredText.kt
Last active July 6, 2018 18:43
Extension Functions Help You To Color your text easily, multi Color TextView more info https://github.com/WahdanZ/ColoredText
import android.os.Build
import android.text.Html
import android.widget.Button
import android.widget.TextView
/**
* Created by ahmedwahdan
*/
var TextView.coloredText: String
get() {
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) {
@WahdanZ
WahdanZ / mail.js
Last active May 15, 2019 21:25
mail adapter for parse server
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',
void main() {
final Get get = Get();
print(get.get);
}
class Get {
String get get => "Hello Get";
}
@WahdanZ
WahdanZ / main.dart
Last active June 24, 2020 22:55
Extension Iterable
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 ");
@WahdanZ
WahdanZ / ImageCompres.dart
Created May 8, 2021 01:29
compres image flutter dart
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')