Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(data)) | |
| data_size, vocab_size = len(data), len(chars) |
| protocol MyProtocol | |
| { | |
| typealias GenType | |
| func doSomething(param: GenType) | |
| } | |
| class MyObject<T> : MyProtocol | |
| { | |
| typealias GenType = T |
| for page in pages ?? [] | |
| { | |
| guard let pageNumber = page.pageNumber | |
| else { continue } | |
| if let array = pageLookup[pageNumber] | |
| { | |
| pageLookup[pageNumber] = array + [page] | |
| } | |
| else |
| #include "ofMain.h" | |
| #include "ofxTiming.h" | |
| class ofApp : public ofBaseApp { | |
| public: | |
| ofVideoGrabber grabber; | |
| DelayTimer delay; | |
| ofTrueTypeFont font; | |
| string description; | |
| root@3e4601c0-00af-4d93-c8b2-f4584487aa7c:~# dtrace -ln pid18959:main::entry | |
| ID PROVIDER MODULE FUNCTION NAME | |
| 14543 pid18959 main main entry | |
| 14693 pid18959 main _TF4main6findMeFT_Si entry | |
| 14694 pid18959 main _TF4main1bFT_Si entry | |
| 14695 pid18959 main __libc_csu_init entry | |
| 14696 pid18959 main __libc_csu_fini entry | |
| root@3e4601c0-00af-4d93-c8b2-f4584487aa7c:~# dtrace -ln pid18959:main::entry | swift-demangle | |
| ID PROVIDER MODULE FUNCTION NAME |
| import Darwin.C | |
| import Venice | |
| struct SubProcess { | |
| let path: String | |
| let arguments: [String] | |
| func run(sync sync: Bool = true) -> Int? { |
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');| import UIKit | |
| import Rswift | |
| struct NibResource: NibResourceType { | |
| let name: String | |
| let bundle: NSBundle | |
| init(name: String, bundle: NSBundle = NSBundle.mainBundle()) { | |
| self.name = name | |
| self.bundle = bundle |
| # The trick is to link the DeviceSupport folder from the beta to the stable version. | |
| # sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :) | |
| # Support iOS 15 devices (Xcode 13.0) with Xcode 12.5: | |
| sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
| # Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions | |
| # (A similar approach works for older versions too, just change the version number after DeviceSupport) |
| func emojiToImage(text: String, size: CGFloat) -> UIImage { | |
| let outputImageSize = CGSize.init(width: size, height: size) | |
| let baseSize = text.boundingRect(with: CGSize(width: 2048, height: 2048), | |
| options: .usesLineFragmentOrigin, | |
| attributes: [.font: UIFont.systemFont(ofSize: size / 2)], context: nil).size | |
| let fontSize = outputImageSize.width / max(baseSize.width, baseSize.height) * (outputImageSize.width / 2) | |
| let font = UIFont.systemFont(ofSize: fontSize) | |
| let textSize = text.boundingRect(with: CGSize(width: outputImageSize.width, height: outputImageSize.height), | |
| options: .usesLineFragmentOrigin, |