Skip to content

Instantly share code, notes, and snippets.

@t2mahesh
t2mahesh / makeswap.sh
Created September 19, 2019 01:19
Create swap manually
#!/bin/bash
echo "Please wait. It can take a while..."
fallocate -l 1G /swapfile
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
mount -a
echo
@t2mahesh
t2mahesh / saytime.py
Created May 20, 2018 21:09
Say the time every minute
import datetime
import os
import time
while True:
now = datetime.datetime.now()
print now.hour, now.minute
sayit = 'say %d:%d' % (now.hour, now.minute)
os.system(sayit)
time.sleep(60)
@t2mahesh
t2mahesh / gist:48e191d4a5c7d8b525d3bd25fc64e080
Created June 7, 2017 21:29
Android Check if Service is Running
public static boolean isServiceRunning(Context context, String className) {
ActivityManager manager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){
if(className.equals(service.service.getClassName())) {
return true;
}
}
return false;
}