This file contains hidden or 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
| /** | |
| * Abstract representation of success or failure. | |
| * | |
| * @remarks | |
| * Provides a fluid interface for chaining and working with errors that | |
| * is easier to read than long chains of null and undefined checks. | |
| */ | |
| export abstract class Result<T, E> { | |
| /** @return a new result representing a successful calculation. */ | |
| static ok<T, E = never>(value: T): Result<T, E> { |
This file contains hidden or 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 <stdio.h> | |
| #import <sys/sysctl.h> | |
| #import <unistd.h> | |
| #import <Foundation/Foundation.h> | |
| #import <CoreGraphics/CoreGraphics.h> | |
| /* Returns the parent of any arbitrary process, more flexible than | |
| * getpid() and getppid(). | |
| */ |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <CoreGraphics/CoreGraphics.h> | |
| // clang -framework CoreGraphics -o screen-size-cg -arch x86_64 -arch arm64 screen-size.c | |
| static void ShowDisplay(CGDirectDisplayID id) | |
| { | |
| CGRect frame = CGDisplayBounds(id); | |
| CGSize resolution = frame.size; |
This file contains hidden or 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 <stdio.h> | |
| #import <AppKit/AppKit.h> | |
| /* Compilation: clang -framework AppKit -o screen-size -arch x86_64 -arch arm64 main.m */ | |
| /* The main issue is that when run from the command line, there is no window | |
| * context, so AppKit doesn't know what the active window is, and thus | |
| * doesn't know what the "main screen" is, so I think it always returns the | |
| * first one. Is there a way to get the window that launched the process | |
| * and return the screen it is on? |
This file contains hidden or 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
| #!/usr/bin/env python | |
| import random | |
| import sys | |
| def d6(): | |
| return random.randrange(1, 7) | |
This file contains hidden or 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 alpine:3.9 AS checkout | |
| RUN apk add --update git | |
| RUN git clone https://github.com/jimmylee/space-web.git /app | |
| FROM alpine:3.9 | |
| RUN apk add --update npm |
This file contains hidden or 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
| class Singleton(type): | |
| def __init__(cls, name, bases, dict): | |
| super(Singleton, cls).__init__(name, bases, dict) | |
| cls.instance = None | |
| def __call__(cls, *args, **kwargs): | |
| if cls.instance is None: | |
| cls.instance = super(Singleton, cls).__call__(*args, **kwargs) | |
| return cls.instance |
This file contains hidden or 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
| #include <stdio.h> | |
| int main(int argc, char **argv) | |
| { | |
| int i = 0; | |
| int g = 0; | |
| unsigned char ch; | |
| if (argc > 1) { |
This file contains hidden or 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 random | |
| class TreeNode(object): | |
| def __init__(self, value, left=None, right=None): | |
| self.value = value | |
| self.left = left | |
| self.right = right | |
| def __hash__(self): |
This file contains hidden or 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 <Foundation/Foundation.h> | |
| #include <grp.h> | |
| #include <string.h> | |
| #include <sys/stat.h> | |
| @interface FileOwnerManager : NSObject | |
| - (BOOL)isWheelPresent:(NSString *)path; | |
| @end | |
| @implementation FileOwnerManager |
NewerOlder