おのうえ(@_likr)です。
モダンJavaScriptの便利な書き方や、Linterに怒られないコードの書き方などを紹介します。
| const optimalFontSize = (word, r, fontFamily, fontWeight) => { | |
| const text = document.createElementNS('http://www.w3.org/2000/svg', 'text') | |
| text.textContent = word | |
| text.setAttributeNS(null, 'font-family', fontFamily) | |
| text.setAttributeNS(null, 'font-weight', fontWeight) | |
| const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') | |
| svg.appendChild(text) | |
| document.body.appendChild(svg) | |
| let ok = 0 | |
| let ng = 100 |
| const getImageUrl = async () => { | |
| const response1 = await fetch('https://example.com'); | |
| const data1 = await response1.json(); | |
| const response2 = await fetch(data1.url); | |
| const data2 = await response2.json(); | |
| return data2 | |
| }; | |
| const App = () => { | |
| const [data, setData] = useState(null); |
| void swap(int[] a, int i, int j) { | |
| int tmp = a[i]; | |
| a[i] = a[j]; | |
| a[j] = tmp; | |
| } | |
| void qsort(int[] a, int start, int stop) { | |
| if (stop - start <= 1) { | |
| return; | |
| } |
おのうえ(@_likr)です。
モダンJavaScriptの便利な書き方や、Linterに怒られないコードの書き方などを紹介します。
| const THREE = require('three') | |
| const EffectComposer = require('three-effectcomposer')(THREE) | |
| const width = 500 | |
| const height = 500 | |
| const r = 5 | |
| const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000) | |
| camera.position.z = r |
| const THREE = require('three') | |
| const EffectComposer = require('three-effectcomposer')(THREE) | |
| class EnsembleAveragePass { | |
| constructor (scene, camera, repeat) { | |
| this.scene = scene | |
| this.camera = camera | |
| this.uniforms = THREE.UniformsUtils.clone({ | |
| accBuffer: {type: 't', value: null}, | |
| newBuffer: {type: 't', value: null}, |
| function _f2c_daxpy($n,$da,$dx,$incx,$dy,$incy) { | |
| $n = $n|0; | |
| $da = $da|0; | |
| $dx = $dx|0; | |
| $incx = $incx|0; | |
| $dy = $dy|0; | |
| $incy = $incy|0; | |
| var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0.0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0.0, $112 = 0.0, $113 = 0, $114 = 0, $115 = 0; | |
| var $116 = 0.0, $117 = 0.0, $118 = 0, $119 = 0.0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0.0, $125 = 0.0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0.0, $131 = 0.0, $132 = 0, $133 = 0.0; | |
| var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0.0, $139 = 0.0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0.0, $145 = 0.0, $146 = 0, $147 = 0.0, $148 = 0, $149 = 0, $15 = 0.0, $150 = 0, $151 = 0; |
| function nop() { | |
| "use strict"; | |
| } | |
| module.exports = function createComponent(options) { | |
| "use strict"; | |
| var enter = options.enter || nop, | |
| exit = options.exit || nop, | |
| update = options.update || nop; |
| <html> | |
| <link rel="stylesheet" href="bgstretcher.css" /> | |
| <script type="text/javascript" src="jquery-1.6.1.js"></script> | |
| <script type="text/javascript" src="bgstretcher.js"></script> | |
| <script type="text/javascript"> | |
| $(document).ready(function(){ | |
| var iter = 0; | |
| var images = ['images/白い画像.jpg', 'images/sample-2.jpg']; |
| fn dp (p : &[int], w : &[int], c : int) -> int { | |
| let mut z = std::vec::from_elem((c + 1) as uint, 0); | |
| for p.iter().zip(w.iter()).advance |(pj, wj)| { | |
| for std::uint::range_rev(c as uint, (*wj - 1) as uint) |k| { | |
| z[k] = match z[k - *wj as uint] + *pj { | |
| v if v > z[k] => v, | |
| _ => z[k] | |
| } | |
| } | |
| } |