Skip to content

Instantly share code, notes, and snippets.

@floscr
floscr / valet-subdir.sh
Created October 13, 2016 19:16
Valet a subdirectory
cd my-site/htdocs
# Link the current directory in ~/.valet/Sites
# Which is a default park by valet
valet link
# Rename the generated symlink to your domain
mv ~/.valet/Sites/htdocs ~/.valet/my-domain
@floscr
floscr / date.js
Created November 22, 2016 09:10
ES6 Date Destructuring
function getDate (args) {
const d = new Date()
return [d.getDate(), d.getMonth() + 1, d.getFullYear()]
}
const [day, month, year] = getDate()
@floscr
floscr / timeout.js
Created November 22, 2016 09:12
Promiseified Timeout
timeout(1000).then(() => {
console.log('done')
})
@floscr
floscr / smoothscroll.js
Created November 22, 2016 09:15
Native Smooth Scroll
// Use polyfill
// http://iamdustan.com/smoothscroll/
window.scroll({ top: 2500, left: 0, behavior: 'smooth' });
document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' });
@floscr
floscr / open-dropped-files-in-nvim.js
Last active April 3, 2018 18:09
Open dropped files in NVIM in a new TMUX window
function run (input, parameters) {
const iTerm = Application('iTerm2')
iTerm.activate()
const windows = iTerm.windows()
var window = iTerm.currentWindow()
var tab = window.currentTab()
var session = tab.currentSession()
@floscr
floscr / trace.js
Created January 7, 2017 10:17
Promise Log Helper Function Trace
const trace = message => x => {
console.log(message, x)
return x
}
Promise.resolve('foo')
.then(trace('received response')) // logs "received response foo"
.then(res => /* do something */)
@floscr
floscr / vuex-getter-with-parameters.js
Created January 7, 2017 12:01
Vuex Getter with parameters
getters: {
filterProducts: state => type => { // only use state
return state.products.filter(p => p.type === type)
},
filteredLength: (state, getters) => type => { // want to use getters
return getters.filterProducts(type).length
}
}
@floscr
floscr / promiseAllExample.js
Created March 17, 2017 16:41
Promise All Example
function promiseWrap (value) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(value)
resolve(value * 2)
}, 100 * value)
})
}
const values = [1, 2, 3]
@floscr
floscr / generate-multi-size-assets
Created April 13, 2017 09:20
Photoshop Generate @1x, @2x assets from one @2x PSD
# Rename your layer to this:
filename-2x.png, 50% filename-1x.png
@floscr
floscr / haskell-setup-osx.md
Last active August 13, 2017 17:04
Haskell Setup OSX
brew install ghc cabal-install

stack new my-project
stack setup --install-ghc
stack install ghc-mod