Skip to content

Instantly share code, notes, and snippets.

View bberak's full-sized avatar

Boris Berak bberak

  • Sydney, Australia
View GitHub Profile
@bberak
bberak / Bunny.js
Created October 18, 2017 12:34
How to use regl in React or React Native
import React, { PureComponent } from "react";
import { StyleSheet } from "react-native";
import ReglView from "./ReglView";
import mat4 from "gl-mat4";
import bunny from "bunny";
export default class Bunny extends PureComponent {
drawCommand = regl => {
return regl({
vert: `
@bberak
bberak / entities.js
Created April 8, 2018 03:09
React Native Donkey Kong - Level 1
import React from "react";
import { Dimensions } from "react-native";
import Matter from "matter-js";
import Platform from "./platform";
import Mario from "./mario";
//-- Overriding this function because the original references HTMLElement
//-- which will throw an error when running in a React Native context
Matter.Common.isElement = () => false;
@bberak
bberak / platform.js
Created April 8, 2018 03:12
React Native Donkey Kong - Platform
import React, { PureComponent } from "react";
import Matter from "matter-js";
import PlatformImage from "./platform.png"; //-- You can get the images from our repo.
import Tile from "./tile"; //-- This is just a helper component
import { collisionCategories } from "./constants";
export class Renderer extends PureComponent {
render() {
return (
<Tile
@bberak
bberak / App.js
Created April 8, 2018 03:15
React Native Donkey Kong - App.js
import React, { PureComponent } from "react";
import { StyleSheet, StatusBar } from "react-native";
import { GameEngine } from "react-native-game-engine";
import { LevelOne } from "./entities";
export default class App extends PureComponent {
constructor(props) {
super(props);
}
@bberak
bberak / mario.js
Created April 9, 2018 00:02
React Native Donkey Kong - Basic Mario
import React, { Component } from "react";
import { StyleSheet, Image } from "react-native";
import { collisionCategories } from "./constants";
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import Matter from "matter-js";
import MarioIdling from "./mario-idling.gif";
export class Renderer extends Component {
render() {
const source = this.props.actions[this.props.action];
@bberak
bberak / constants.js
Created April 9, 2018 00:07
React Native Donkey Kong - Constants
module.exports = {
collisionCategories: {
mario: 1,
barrier: 2,
platform: 4,
ladder: 8,
barrel: 16
}
}
@bberak
bberak / aws-cli-s3-presign.sh
Created February 4, 2020 23:22
Presign a file in S3 for secure download using the AWS CLI
aws s3 presign s3://bucket-name/folder/file.ext [--profile your-aws-profile]
@bberak
bberak / create-and-launch-ios-simulator.sh
Created February 7, 2020 01:00
Create and launch new iOS simulartor
xcrun simctl list
xcrun simctl create <Your sim name> <Device id> <Runtime id>
# Eg: xcrun simctl create XS-Max-13-3 com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max com.apple.CoreSimulator.SimRuntime.iOS-13-3
xcrun simctl boot <UUID from create command>
open -a Simulator --args -CurrentDeviceUDID <UUID from create command>
@bberak
bberak / aws-s3-copy-directory.sh
Last active April 3, 2020 22:59
Copy an S3 bucket (or path) to a local directory
aws s3 cp s3://bucket-name/optional-path ./local/path --recursive
@bberak
bberak / configure-raspberry-pi.md
Last active January 27, 2024 18:07
Configure a new Raspberry PI with WiFi and SSH

Configure Raspberry PI

Setting up Image

Configuration