Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Get DataDir location
DATA_DIR="/data"
case "$(ubnt-device-info firmware || true)" in
1*)
DATA_DIR="/mnt/data"
;;
2*)
DATA_DIR="/data"
/usr/share/zoneinfo
├── +VERSION
├── Africa
│   ├── Abidjan
│   ├── Accra
│   ├── Addis_Ababa
│   ├── Algiers
│   ├── Asmara
│   ├── Asmera
│   ├── Bamako
@fireblue
fireblue / ocserv-cent-os-7.sh
Created September 28, 2014 08:46
ocserv(Cisco AnyConnect 兼容服务端) 一键安装脚本 for CentOS 7
#!/bin/bash
####################################################
# #
# This is a ocserv installation for CentOS 7 #
# Version: 1.1.1 20140803 #
# Author: Travis Lee #
# Website: http://www.stunnel.info #
# #
####################################################
@fireblue
fireblue / NSData + UTF8Detect
Last active December 17, 2015 19:29
Detect whether the content of a NSData object is UTF8 encoded or not.
- (BOOL)isUTF8
{
const char *string = (const char *)self.bytes;
const unsigned char * bytes = (const unsigned char *)string;
while(*bytes)
{
if( (// ASCII
// use bytes[0] <= 0x7F to allow ASCII control characters
bytes[0] == 0x09 ||
bytes[0] == 0x0A ||
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder
@fireblue
fireblue / UIWebView+Screenshot.m
Last active November 1, 2016 02:28
Find a certain element in UIWebView and make a screenshot. :)
-(UIImage *)screenShot
{
CGRect originalFrame = self.frame;
CGPoint originalOffset = self.scrollView.contentOffset;
CGSize entireSize = [self sizeThatFits:CGSizeZero];
[self setFrame: CGRectMake(0, 0, entireSize.width, entireSize.height)];
CGRect rect = [self positionOfElementWithId:@"post1"];
//如果没有找到这个元素,就取整个页面
if (rect.origin.y != 0) {