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
#!/usr/bin/env python | |
import random | |
import sys | |
def d6(): | |
return random.randrange(1, 7) | |
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 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 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 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 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 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 |
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 System.Console.GetOpt (ArgOrder(..), getOpt) | |
import System.Environment (getArgs, getProgName) | |
data BloodPressureCategory = Normal | |
| Prehypertension | |
| Hypertension1 | |
| Hypertension2 | |
| HypertensiveCrisis |
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 System.Console.GetOpt (ArgOrder(..), getOpt) | |
import System.Environment (getArgs) | |
offset = (flip mod) 12 | |
animal 4 = "Rat" | |
animal 5 = "Ox" | |
animal 6 = "Tiger" | |
animal 7 = "Rabbit" | |
animal 8 = "Dragon" |
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 sys | |
from functools import wraps | |
from types import FunctionType | |
def is_python3(): | |
return sys.version_info >= (3, 0) | |
def more_vars(**extras): |
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
# This totally works, even though `i` isn't passed into the | |
# lambda, nor is it defined prior to the lambda declaration. | |
calculate_efp = lambda v: v - i | |
[calculate_efp(v) for i, v in enumerate([10,100,1000])] |
NewerOlder