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 shuffle(list) { | |
var i = list.length; | |
while (--i) { | |
var j = Math.floor(Math.random() * (i + 1)); | |
if (i == j) continue; | |
var k = list[i]; | |
list[i] = list[j]; | |
list[j] = k; | |
} |
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
import React from 'react'; | |
import dynamics from 'dynamics.js'; | |
class Box extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
x: 0, | |
y: 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
var users = [ | |
{ name: 'tom', age: 18 }, | |
{ name: 'bob', age: 24 }, | |
{ name: 'john', age: 36 } | |
]; |
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
<dl> | |
<dt>name</dt> | |
<dd>tom</dd> | |
<dt>age</dt> | |
<dd>18</dd> | |
</dl> | |
<dl> | |
<dt>name</dt> | |
<dd>bob</dd> |
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
var frag = document.createDocumentFragment(); | |
for (var i = 0, l = users.length; i < l; i++) { | |
var user = users[i]; | |
var dl = document.createElement('dl'); | |
var nameTerm = document.createElement('dt'); | |
nameTerm.textContent = 'name'; | |
dl.appendChild(nameTerm); |
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
var html = users.map(function (user) { | |
return ` | |
<dl> | |
<dt>name</dt> | |
<dd>${user.name}</dd> | |
<dt>age</dt> | |
<dd>${user.age}</dd> | |
</dl> | |
`; | |
}); |
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
var empty = function (el) { | |
while (el.firstChild) { | |
el.removeChild(el.firstChild); | |
} | |
}; | |
var container = document.getElementById('container'); | |
empty(container); |
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 () { | |
var $field = $('#field'); | |
var $btn = $('#btn'); | |
var $list = $('#list'); | |
var addItem = function () { | |
var text = $field.val(); | |
$list.append('<li>' + text + '</li>'); | |
$field.val(''); | |
}; |
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 | |
pathinfo($filename, PATHINFO_EXTENSION); |
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 | |
$finfo = new finfo(FILEINFO_MIME_TYPE); | |
$finfo->file($filepath); |
OlderNewer