日時: | 2021-01-29 |
---|---|
作: | @voluntas |
バージョン: | 2021.2 |
url: | https://voluntas.github.io/ |
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 SwiftUI | |
extension View { | |
@MainActor | |
func pdf(size: ProposedViewSize) -> Data { | |
let renderer = ImageRenderer(content: self) | |
renderer.proposedSize = size | |
var pdfData = NSMutableData() | |
renderer.render { size, render in | |
var mediaBox = CGRect(origin: .zero, size: size) |
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
Bitmap batmapBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.batman); | |
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), batmapBitmap); | |
// option 1 h/t [Chris Banes](https://chris.banes.me/) | |
circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth()); | |
// option 2 h/t @csorgod in the comments | |
circularBitmapDrawable.setCircular(true); | |
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 "NSObject+performSelector.h" | |
@implementation NSObject (performSelector) | |
- (void)call:(NSString *)sel { | |
[self performSelector:@selector(sel)]; | |
} | |
- (id)get:(NSString *)sel { | |
return [self performSelector:@selector(sel)]; |
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
# 私が考える安全なプログラムを書くために必要なこと | |
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。 | |
- ファイルを開こうとしたらコマンドを実行できてしまったり | |
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり | |
- SELECT文を発行するつもりがDELETE文を発行できてしまったり | |
こういったときに | |
- 入力値検証をしないと危険になる |
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
// Ported from Stefan Gustavson's java implementation | |
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf | |
// Read Stefan's excellent paper for details on how this code works. | |
// | |
// Sean McCullough [email protected] | |
/** | |
* You can pass in a random number generator object if you like. | |
* It is assumed to have a random() method. | |
*/ |