This file contains 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
function readURL(input) { | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function(e) { | |
$('#blah').attr('src', e.target.result); | |
} | |
reader.readAsDataURL(input.files[0]); | |
} |
This file contains 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
set nocp | |
call plug#begin() | |
Plug 'tpope/vim-sensible' | |
Plug 'editorconfig/editorconfig-vim' | |
Plug 'qpkorr/vim-bufkill' | |
Plug 'justinmk/vim-sneak' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'ctrlpvim/ctrlp.vim' |
This file contains 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
window.addEventListener('keydown', (e) => { | |
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`); | |
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`); | |
if (!audio) return; | |
audio.currentTime = 0; | |
audio.play(); | |
key.classList.add('playing'); | |
key.classList.remove('playing'); | |
key.classList.toggle('playing'); | |
key.classList.contains('playing'); |
This file contains 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
const inputs = document.querySelectorAll('.controls input'); | |
function handleUpdate() { | |
const suffix = this.dataset.sizing || ''; // data-sizing='something' | |
document.documentElement.style.setProperty(`--${this.name}`, this.value); // css variable | |
} | |
inputs.forEach(input => input.addEventListener('change', handleUpdate)); | |
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate)); |
This file contains 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
// filter active items | |
const filtered = items.filter(item => item.isActive == 10); | |
// map name and title | |
const mapped = items.map(item => `${item.name} ${item.title}`); | |
// sort the item by year, oldest to yongest | |
const sorted = items.sort((a, b) => a.year > b.year ? 1 : -1); | |
// calculate total |
This file contains 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
<?php | |
Schema::create('users', function(Blueprint $table) { | |
$table->bigIncrements('id'); | |
$table->username('string')->unique(); | |
$table->password(); | |
}); | |
Schema::create('articles', function(Blueprint $table) { | |
$table->bigIncrements('id'); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Floating Navigation</title> | |
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"> | |
<style> | |
@keyframes slide-nav-down { | |
100% { | |
transform: translateY(0); | |
} |
This file contains 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
<div x-data="{ count: 0 }"> | |
<button @click="count++">+</button> | |
<button @click="count--">-</button> | |
<span x-text="count"></span> | |
</div> | |
let dataString = document.querySelector('[x-data]').getAttribute('x-data'); | |
let data = eval(`(${dataString})`) |
This file contains 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
<?php | |
namespace Acme\Reporting; | |
use Auth, DB, Exception; | |
class SalesReporter | |
{ | |
public functon between($startDate, $endDate) { |
OlderNewer