Skip to content

Instantly share code, notes, and snippets.

View lailo's full-sized avatar
😀
happy coding

Lailo lailo

😀
happy coding
View GitHub Profile
@lailo
lailo / machine.js
Last active August 14, 2019 11:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@lailo
lailo / requiredParam.js
Last active June 2, 2017 01:53
Require function param with ES6 object destruction
function isRequired(param) {
throw new Error(`Missing param "${param}" is required.`)
}
function myFunc(
{
optionalParam,
paramWithDefaultVaue = 'my default value',
requiredParam = isRequired('requiredParam'),
} = {}
@lailo
lailo / index.html
Last active April 30, 2017 08:06
HTML headers for social sharing
<head>
<title>%PAGE_TITLE%</title>
<meta name="title" content="%PAGE_TITLE%">
<meta name="description" content="%DESCRIPTION%">
<meta property="fb:app_id" content="%FACEBOOK_APP_ID%">
<meta name="twitter:card" content="summary_large_image">
@lailo
lailo / iOSKeyboardHeight
Last active November 16, 2017 16:07
Keyboard height for iOS in Swift
// Add this to viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "keyboardShown:", name: UIKeyboardDidShowNotification, object: nil)
// This function handles notification
func keyboardShown(notification: NSNotification) {
let info = notification.userInfo!
let value: AnyObject = info[UIKeyboardFrameEndUserInfoKey]!
let rawFrame = value.CGRectValue()