Skip to content

Instantly share code, notes, and snippets.

View otbe's full-sized avatar

Benjamin Otto otbe

View GitHub Profile
import java.lang.management.*;
import java.util.List;
public class JavaEnvironment {
public static void main(String args[]) {
System.out.println(
"Number of available processors: " + Runtime.getRuntime().availableProcessors());
System.out.println("GCs:");
ManagementFactory
@otbe
otbe / bucket-policy-artifacts.json
Last active April 5, 2019 08:33
Gitlab CI + CodePipeline Integration
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::<id1>:root",
"arn:aws:iam::<id2>:root",
"arn:aws:iam::<id3>:root"
@otbe
otbe / Pipeline.yml
Last active May 4, 2018 09:29
Multiregion Deployment Pipeline
Pipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Ref 'AWS::StackName'
RoleArn: !GetAtt CodePipelineServiceRole.Arn
ArtifactStore:
Type: S3
Location: !Ref ArtifactBucket
Stages:
- Name: Source
interface Cookies {
read(name: string): string;
write(name: string, value: string, options?: CookieOptions);
}
interface SetStatus {
(code: number): void;
}
@ApiController('/users')
@Get('/download/:id')
async downloadFile(@Param('id') id: string): Promise<FileResult> {
await queryDbForFileOrSo();
// content type will be inferred or explicit specified
return new FileResult(stream | buffer | string [, 'application/pdf' ]);
// or
return new StreamResult(stream);
// or
return new BufferedResult(buffer);
import { map } from 'mobx/lib/mobx';
interface Todo {
id: string;
name: string;
active: boolean;
}
export class MyTodoStore {
todos = map<Todo>();
@otbe
otbe / Todo.tsx
Last active April 26, 2016 17:24
import React, { Component } from 'react';
import { observer } from 'mobx-react/index';
import { observable } from 'mobx/lib/mobx';
@observer
export class Todo extends Component<{todoId: string}, {}> {
@observable
private todo: Todo;