This file contains hidden or 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 java.util.Date; | |
| public class HumanDateUtils { | |
| public static String durationFromNow(Date startDate) { | |
| long different = System.currentTimeMillis() - startDate.getTime(); | |
| long secondsInMilli = 1000; | |
| long minutesInMilli = secondsInMilli * 60; |
This file contains hidden or 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 express = require("express") | |
| const WebSocket = require('ws') | |
| const app = express() | |
| const server = require('http').createServer(app) | |
| const wss = new WebSocket.Server({ noServer: true }) | |
| const wschandler = require('./wschandler').from(wss, server) | |
| wss.on('connection', (ws, req) => { | |
| console.log('connection', req.socket.remoteAddress, ws.data.token) |
This file contains hidden or 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
| #!/bin/bash | |
| # This script will move all the files in a directory to a folders | |
| # with the name of year and month which it gets from the file's created time. | |
| # Run: python categorizer.py /home/aslam/screenshots | |
| # It will categorize all of your files by folders as the name of year and month | |
| # Ex: 1.jpg will be moved to 2020-10_1 folder as 1.jpg created at 2020-10-15 also | |
| # the last number after underscore is the count of the directory | |
| import os |
This file contains hidden or 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
| try { | |
| String inputTime = "2020-06-19T04:18:37.636Z"; | |
| SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); | |
| inputDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); | |
| Date date = inputDateFormat.parse(inputTime); | |
| SimpleDateFormat outputDateFormat = new SimpleDateFormat("HH:mm:ss"); | |
| outputDateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Colombo")); | |
| String outputTime = outputDateFormat.format(date); |
This file contains hidden or 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.org.myapp; | |
| import androidx.appcompat.app.AppCompatActivity; | |
| import androidx.databinding.DataBindingUtil; | |
| import androidx.databinding.ViewDataBinding; | |
| public class BaseActivity<T extends ViewDataBinding> extends AppCompatActivity { | |
| private ViewDataBinding binding; |
This file contains hidden or 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 void sendLongSMS() { | |
| String ussdCode = "#456#"; | |
| Intent intent = new Intent(Intent.ACTION_CALL); | |
| intent.setData(ussdToCallableUri(ussdCode)); | |
| try { | |
| startActivity(intent); | |
| } catch (SecurityException e) { | |
| e.printStackTrace(); | |
| } | |
| } |
This file contains hidden or 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 void setDeviceName(String devName) { | |
| try { | |
| Class[] paramTypes = new Class[3]; | |
| paramTypes[0] = WifiP2pManager.Channel.class; | |
| paramTypes[1] = String.class; | |
| paramTypes[2] = WifiP2pManager.ActionListener.class; | |
| Method setDeviceName = manager.getClass().getMethod("setDeviceName", paramTypes); | |
| setDeviceName.setAccessible(true); | |
| Object arglist[] = new Object[3]; | |
| arglist[0] = channel; |
This file contains hidden or 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.app.Activity; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.graphics.Bitmap; | |
| import android.graphics.PixelFormat; | |
| import android.graphics.Point; | |
| import android.hardware.display.DisplayManager; | |
| import android.hardware.display.VirtualDisplay; | |
| import android.media.Image; | |
| import android.media.ImageReader; |
This file contains hidden or 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.app.ProgressDialog; | |
| import android.content.Context; | |
| import android.os.AsyncTask; | |
| import java.io.BufferedInputStream; | |
| import java.io.FileOutputStream; | |
| import java.io.InputStream; | |
| import java.io.OutputStream; | |
| import java.net.URL; | |
| import java.net.URLConnection; |
This file contains hidden or 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"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="de.mobilej.overlay" | |
| android:versionCode="1" | |
| android:versionName="1.0" > | |
| <uses-sdk android:minSdkVersion="14" /> | |
| <application android:label="SystemOverlay" > | |
| <activity |