This file contains 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
CGContextRef context = UIGraphicsGetCurrentContext(); | |
size_t num_locations = 2; | |
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); | |
CGFloat components[8] = {1,1,1,1, // 中心颜色(r, g, b, alpha) | |
.2,.2,.2,1 // 边缘颜色}; | |
CGFloat locations[2] = {0,1}; | |
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, components, locations, num_locations); | |
CGColorSpaceRelease(rgb); | |
CGRect bounds = self.bounds; | |
CGPoint center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); // 中心发散渐进 |
This file contains 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
AGradientLayer *gradientLayer = [CAGradientLayer layer]; | |
gradientLayer.frame = self.view.frame; | |
gradientLayer.colors = [NSArray arrayWithObjects:(id)baseColor.CGColor, (id)barColor.CGColor, nil]; | |
[self.view.layer insertSublayer:gradientLayer atIndex:0]; |
This file contains 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 "ViewController.h" | |
#import <objc/runtime.h> | |
@interface ViewController () <UIAlertViewDelegate> | |
@end | |
static void *MyAlertViewKey = "MyAlertViewKey"; | |
@implementation ViewController |
This file contains 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 RPi.GPIO as GPIO | |
import pycurl, json | |
from StringIO import StringIO | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
GPIO.setup(25, GPIO.OUT) | |
appID = "54bc5b49a4c48a3d5bf22c4c" | |
appSecret = "a55bc3eb578bcd5d9065d24f83fa3219" |
This file contains 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
from flask import Flask, jsonify, request, render_template, url_for, send_from_directory, redirect | |
2 import temperature | |
3 import camera | |
4 app = Flask(__name__) | |
5 app.config['UPLOAD_FOLDER'] = 'static' | |
6 | |
7 @app.route("/") | |
8 def index(): pass | |
9 | |
10 @app.route("/temperature") |
This file contains 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 pygame | |
2 import pygame.camera | |
3 #from pygame.locals import * | |
4 | |
5 # initialize | |
6 pygame.init() | |
7 pygame.camera.init() | |
8 | |
9 camera = pygame.camera.Camera("/dev/video0", (640, 480)) | |
10 |
This file contains 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
1 import commands | |
2 | |
3 def get_cpu_temperature(): | |
4 temperatureFile = open("/sys/class/thermal/thermal_zone0/temp") | |
5 cpu_temperature = temperatureFile.read() | |
6 temperatureFile.close() | |
7 return float(cpu_temperature)/1000 | |
8 | |
9 def get_gpu_temperature(): | |
10 gpu_temperature = commands.getoutput('/opt/vc/bin/vcgencmd measure_temp').replace('temp=', '').replace('\'C', '') |
This file contains 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
func p_setupTextLayer(text: String) -> CAShapeLayer { | |
var letters = CGPathCreateMutable() | |
let font = CTFontCreateWithName("Helvetica-Bold", 72, nil) | |
let attrs = [kCTFontAttributeName: font] | |
var attrString = NSAttributedString(string: text, attributes: attrs) | |
let line = CTLineCreateWithAttributedString(attrString) | |
let runArray = CTLineGetGlyphRuns(line) | |
This file contains 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 <CoreTelephony/CTTelephonyNetworkInfo.h> | |
typedef enum : NSInteger { | |
NotReachable = 0, | |
ReachableViaWiFi, | |
ReachableVia2G, | |
ReachableVia3G, | |
ReachableVia4G, | |
ReachableViaWWAN | |
} NetworkStatus; |
This file contains 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
// | |
// MJGImageLoader.h | |
// MJGFoundation | |
// | |
// Created by Matt Galloway on 18/01/2012. | |
// Copyright 2012 Matt Galloway. All rights reserved. | |
// | |
/** | |
* Example usage: |
OlderNewer