Skip to content

Instantly share code, notes, and snippets.

View omas-public's full-sized avatar

Omas Naohiko omas-public

View GitHub Profile
if __name__ == '__main__':
# pythonの論理演算子を使った関数の実装
_not = lambda p: not p
_and = lambda p, q: p and q
_or = lambda p, q: p or q
_xor = lambda p, q: not(p and q) and (p or q)
comparator = lambda fn: lambda list: fn(*list)
bit = [True, False]
twobit = [
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
const list = [2, 3, 6]
const sum1 = (...args) => {
return args.reduce((a, b) => a + b)
}
const sum2 = (...args) => {
let acc = 0
for (let v of args) {
acc += v
@omas-public
omas-public / aoj.md
Last active August 29, 2019 12:50
AOJ IT

// X cubic

(stdin => {
  // Define Function
  const cube = n => n ** 3
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const x = parseInt(inputs[0], 10)
@omas-public
omas-public / Template.jsx
Last active January 30, 2020 07:48
API template pattern
import React from 'react'
import {
Card,
CardHeader,
CardContent,
CardActions
// List,
// ListItem,
// ListItemText,
// TextField
const getCurrentPosition = async () => {
const geolocation = options => new Promise((resolve, reject) =>
navigator.geolocation.getCurrentPosition(resolve, reject, options)
)
const options = { enableHighAccuracy: true }
const position = await geolocation(options)
.then(json => json.coords)
.then(coords => ({ latitude: coords.latitude, longitude: coords.longitude }))
.catch(error => console.log(error))
@omas-public
omas-public / Template.html
Last active December 6, 2019 04:55
いまどきのJSプログラマーのためのNode.jsとReactアプリケーション
<!DOCTYPE html>
<meta charset="utf-8">
<title>test</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<div id="root"></div>
<script type="text/babel">
@omas-public
omas-public / App.jsx
Created December 12, 2019 11:55
React Form(p158)
import React from 'react'
import {
TextField,
Button,
FormControl,
makeStyles,
createStyles
} from '@material-ui/core'
const App = props => {
@omas-public
omas-public / App.css
Last active December 19, 2019 12:24
Code prep Todo css
body {
margin:0;
padding: 20px;
background: #FFF7FF;
}
.todo {
width:100%;
max-width:25rem;
margin:0 auto;
padding:20px;
import React from 'react'
import sa from 'superagent'
class App extends React.Component {
constructor (props) {
super(props)
this.state = { items: null }
}
async loadedJSON () {
const getAPI = uri =>