Skip to content

Instantly share code, notes, and snippets.

View paprikka's full-sized avatar

Rafal Pastuszak paprikka

View GitHub Profile
App = ->
$debug = $ '#debug'
log = (t)-> $debug.html t
W = 400
H = 300
VIEW_ANGLE = 45
ASPECT = W / H
NEAR = .1
@paprikka
paprikka / Preferences.sublime-settings
Created September 27, 2013 11:39
A generic ST config for Mac & Windows. Don't forget to install Package Control and feed this baby with plugins!
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
@paprikka
paprikka / preloadGUI.cs
Created December 6, 2016 17:16
Poor man's prefabs
public class GUIScreenLoader
{
private Transform container;
private MainNavGUIConfig config; // a ScriptableObject with a list of easily editable components
// it also contains a GUI Scene reference, for more control over
// resource loading.
public GUIScreenLoader(MainNavGUIConfig config, Transform container)
{
this.config = config;
$ npm i -g lana-cli
# or
$ yarn global add lana-cli
@paprikka
paprikka / import.json
Created April 23, 2017 18:56
ES import with better autocomplete
// Add this to your VSCode snippets
"import": {
"prefix": "imm",
"description": "ES module import",
"body": [
"import ${2:scope} from '${1:moduleName}'",
"${3}"
]
},
@paprikka
paprikka / sharedRouter.js
Created October 16, 2017 12:39
Shared router event subscriptions in Next.js
// usage:
// 1. import in your page/component/layout
// 2. subscribe in componentDidMount
// 3. make sure you unsubscribe in componentWillUnmount
import Router from 'next/router'
import { Observable } from 'rxjs'
console.log('route: initialising router')
export const routeChangeStart$ = Observable.create(
@paprikka
paprikka / createRequestHandler.ts
Created December 7, 2017 15:48
Handle Restify endpoints as Observables using RxJS
import { Observable, Subscription } from 'rxjs'
import {
Request,
Response,
Next
} from 'restify'
export interface RequestContext {
req: Request,
res: Response,
@paprikka
paprikka / route.js
Created October 27, 2018 08:56
Hapi route example
import Joi from 'joi';
import Events from '../events';
const route = {
handler: ({params: {props}}, reply) => {
let parsedData;
try {
parsedData = JSON.parse(decodeURIComponent(props));
} catch (err) {
import { useEffect } from 'react'
export const useRainbowBg = () =>
useEffect(() => {
const cb = () => {
const viewportHeight = window.innerHeight
const contentHeight = document.body.getBoundingClientRect().height
const viewportsPerRotation = Math.min(
3,
contentHeight / viewportHeight
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.