A Pen by Alan Languirand on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function Plugin(Vue) { | |
| /** | |
| Installing in your app root: | |
| import DarkMode from './path/to/this/code.js'; | |
| Vue.use(DarkMode); | |
| Usage in your components: | |
| <div v-if="$darkMode.isDark">...</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // vue.config.js | |
| module.exports = { | |
| configureWebpack: { | |
| watch: true | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Benchmark = require('benchmark'); | |
| Benchmark.prototype.setup = function() { | |
| a = ["test"]; | |
| for (var i = 0; i < 10000; i++) { | |
| a.push("some other stuff"); | |
| } | |
| s = a.join(); | |
| re1 = new RegExp("^test"); | |
| re2 = new RegExp("^not there"); | |
| }; |
An angular module to report on bootstrap's reponsive grid breakpoints. The injected html snipped uses bootstrap's named breakpoints so your script doesn't need to know anything about the actual css dimensions.
- Include
ScreenSizeas a dependency of your app - Reference
ScreenSizeFactoryin your controler's DI list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > typeof([]) | |
| 'object' | |
| > typeof({a:[]}.a) | |
| 'object' | |
| > [] | |
| [] | |
| > typeof(['hi']) | |
| 'object' | |
| > var hello = ['hi'] | |
| undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A tiny Jekyll filter for giving custom dates a proper timezone offset | |
| # example usage `{{ post.startDate | tz_local | date: '%l:%M %P'}}` | |
| # Why? If you omit a timezone offset, Jekyll automatically adds +0000...which is probably not what you want. | |
| # This let's dates like `startDate: 2015-1-14 18:00:00` render correcty in local time. DST is calculated correctly | |
| # NOTE: This will still inherit Jekyll's timezone property as set in _config.yml | |
| module TZLocal | |
| def tz_local(input) | |
| input = input + (Time.parse(input.to_s).gmt_offset) * -1 | |
| end |
NewerOlder
