Skip to content

Instantly share code, notes, and snippets.

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

Ahmed Wahdan WahdanZ

🐧
Bazinga!!
View GitHub Profile
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")
@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"