Skip to content

Instantly share code, notes, and snippets.

View cesalberca's full-sized avatar

César Alberca cesalberca

View GitHub Profile
@snorpey
snorpey / circle rotated rectangle collision.js
Last active March 1, 2024 13:43
Calculate collision between circle and rotated rectangle
// Ported to JavaScript from
// http://www.migapro.com/circle-and-rotated-rectangle-collision-detection/
//
// An example:
// var circle: { x: 20, y: 10, radius: 20 };
// var rect: { x: 30, y: 30, width: 100, height: 100, rotation: Math.PI / 2 };
// collideCircleWithRotatedRectangle( circle, rect );
// // returns true.
//
//
@JavierSA
JavierSA / init.lua
Last active November 22, 2022 18:06
Hammerspoon configuration
local MASH = {"cmd", "alt", "ctrl"}
local MASH_SHIFT = {"cmd", "alt", "ctrl", "shift"}
local focusedWindow
local focusedWindowFrame
local screenFrame
hs.grid.MARGINX = 0
hs.grid.MARGINY = 0
@heyimalex
heyimalex / example.js
Created September 21, 2016 16:15
Using mock-fs with jest
// __tests__/example.js
jest.mock('fs');
it('should serve as a nice example', () => {
const fs = require('fs')
// fs can be set up at any point by calling __configureFs.
fs.__configureFs({
'/test': {
@simenbrekken
simenbrekken / schema.js
Created December 21, 2016 14:06
Firebase backed GraphQL schema
import firebase from 'firebase'
import { filter, map } from 'lodash'
import { makeExecutableSchema } from 'graphql-tools'
firebase.initializeApp({
databaseURL: 'https://grafire-b1b6e.firebaseio.com',
})
const mapSnapshotToEntity = snapshot => ({ id: snapshot.key, ...snapshot.val() })
const mapSnapshotToEntities = snapshot => map(snapshot.val(), (value, id) => ({ id, ...value }))
@cesalberca
cesalberca / .editorconfig
Created March 23, 2017 10:56
Opinionated .editorconfig
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
@dalezak
dalezak / README.md
Last active September 11, 2023 09:51
Ionic Capacitor Resources Generator
  1. Run npm install cordova-res --save-dev
  2. Create 1024x1024px icon at resources/icon.png
  3. Create 2732x2732px splash at resources/splash.png
  4. Add "resources": "cordova-res ios && cordova-res android && node scripts/resources.js" to scripts in package.json
  5. Copy resources.js file to scripts/resources.js
  6. Run sudo chmod -R 777 scripts/resources.js
  7. Run npm run resources
@rrlevy
rrlevy / CORDOVA_RESOURCES_GENERATOR.md
Last active November 9, 2021 10:53 — forked from dalezak/README.md
Ionic Capacitor Resources Generator
  1. Run npm install cordova-res --save-dev
  2. Create 1024x1024px icon at resources/icon.png
  3. Create 2732x2732px splash at resources/splash.png
  4. Add "resources": "cordova-res ios && cordova-res android && node scripts/resources.js" to scripts in package.json
  5. Copy resources.js file to scripts/resources.js
  6. Run sudo chmod -R 777 scripts/resources.js
  7. Run npm run resources