Skip to content

Instantly share code, notes, and snippets.

@lloydsheng
lloydsheng / clean.sh
Last active July 9, 2019 03:00
Clean macOS Cache
# Prequirements
brew install coreutils
# Get size
du -sh $HOME/* | gsort -h
# iOS simulators cache
rm -rf "$HOME/Library/Developer/CoreSimulator/Devices/*"
# Wechat cache
rm -rf "$HOME/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/d41d8cd98f00b204e9800998ecf8427e/Message/MessageTemp/*"
[
[214.0,291.0],
[290.0,426.0],
[130.0,234.0],
[41.0,192.0],
[273.0,393.0],
[53.0,50.0],
[61.0,337.0],
[251.0,296.0],
[264.0,232.0],
import UIKit
import Mapbox
class CustomPointAnnotation : MGLPointAnnotation {
}
class IconAnnotationView: MGLAnnotationView {
var iconView = UIImageView(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
- (MKMapRect)visibleMapRect {
MGLCoordinateBounds bounds = self.mapboxMapView.visibleCoordinateBounds;
MKMapPoint sw = MKMapPointForCoordinate(bounds.sw);
MKMapPoint ne = MKMapPointForCoordinate(bounds.ne);
double x = sw.x;
double y = ne.y;
double width = ne.x - sw.x;
double height = sw.y - ne.y;
UIGraphicsBeginImageContextWithOptions(snapshotView.bounds.size, true, 0.0)
snapshotView.drawHierarchy(in: snapshotView.bounds, afterScreenUpdates: true)
let snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
print("\(snapshotImage.debugDescription)")
let centerLocation = CLLocationCoordinate2D(latitude: 0, longitude: 66)
let styleURL = URL(string: "mapbox://styles/lloydsheng/cjdjzspzq5b4b2sobtqxeooll")
let camera = MGLMapCamera(lookingAtCenter: centerLocation, fromDistance: 100, pitch: 0, heading: 0)
let options = MGLMapSnapshotOptions(styleURL: styleURL, camera: camera, size: CGSize(width: 300, height: 300))
let snapShooter = MGLMapSnapshotter(options: options)
snapShooter.start { (shooter, error) in
let image = shooter?.image;
print("\(image)")
}
@lloydsheng
lloydsheng / gist:10440385
Created April 11, 2014 04:07
monit snmp with snmpwalk
import os
import time
import datetime
command = 'snmpwalk -v3 -l NoAuthNoPriv -u cisco 192.168.1.1 "ifInOctets.10"'
r = os.popen(command).read()
last_octes = r.replace("\n", "").split(" ")[-1]
last_octes = int(last_octes)
per = 3
while (True):
@lloydsheng
lloydsheng / ipin.py
Created February 11, 2014 14:58 — forked from urielka/ipin.py
#---
# iPIN - iPhone PNG Images Normalizer v1.0
# Copyright (C) 2007
#
# Author:
# Axel E. Brzostowski
# http://www.axelbrz.com.ar/
# [email protected]
#
# References:
@lloydsheng
lloydsheng / Python-Timestamp.py
Last active March 19, 2018 08:16
python date to timestamp
import time
import datetime
now = datetime.datetime.now()
time.mktime(now.timetuple())
@lloydsheng
lloydsheng / iOS-Custom-Tabbar.m
Last active March 19, 2018 08:13
一端iOS5.0以上订制UITabbar的代码
[self.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"tab-bar_highlighted.png"]];
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
RGB(187, 187, 187), UITextAttributeTextColor,
[UIFont systemFontOfSize:10], UITextAttributeFont,
nil]
forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
RGB(153, 210, 249), UITextAttributeTextColor,