Skip to content

Instantly share code, notes, and snippets.

View immortalsantee's full-sized avatar

Santosh Maharjan immortalsantee

  • Cyclone Nepal Info Tech Pvt. Ltd.
  • Lagankhel, Lalitpur, Kathmandu, Nepal
View GitHub Profile
@immortalsantee
immortalsantee / api.php
Created January 25, 2014 12:05 — forked from petenelson/api.php
Force all browsers to reload on any attached browser's page reload
<?php
// just using a file, could easily be replaced by some other storage method
if (isset($_REQUEST['new']) && $_REQUEST['new'] == '1') {
$ver = new stdClass();
$ver->ver = time();
file_put_contents('ver.json', json_encode($ver));
}
else {
let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
let circleBezierPath = UIBezierPath(roundedRect: rect, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: rect.width/2, height: rect.height/2))
// 1. Get Data from BezierPath
let bezierData = circleBezierPath.smGetData()
// 2. Store bezierData in user defaults
UserDefaults.standard.set(bezierData, forKey: "com.santosh.bezierPath")
// 3. Get BezierData from userdefaults
@immortalsantee
immortalsantee / lockUnlockState.swift
Last active January 20, 2021 21:11
Device lock unlock state detection from today extension
weak var deviceUnlockedObserver: NSObjectProtocol?
weak var deviceLockedObserver: NSObjectProtocol?
var isDeviceLocked = true
private func addDeviceUnlockedObserver() {
guard deviceUnlockedObserver == nil else {return}
deviceUnlockedObserver = NotificationCenter.default.addObserver(forName: .UIApplicationProtectedDataDidBecomeAvailable, object: nil, queue: .main) { (noti) in
DispatchQueue.main.async {
self.isDeviceLocked = false
@immortalsantee
immortalsantee / move_files_folder
Created January 7, 2020 12:00
Move files and folder by terminal command.
mv -v ~/Downloads/* ~/Videos/
sudo chmod 755 folderName/