Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@junjis0203
junjis0203 / fliptrip-react.html
Last active September 28, 2019 10:49
React and Vue implementation for Mathematical Girls: The Secret Notebook (Bits and Binary), chapter 4
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link type="text/css" href="fliptrip.css" rel="stylesheet">
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<!--
<script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
@junjis0203
junjis0203 / fliptrip.html
Last active September 12, 2019 12:31
React implementation(alpha) for Mathematical Girls: The Secret Notebook (Bits and Binary), chapter 4
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
.board {
display: inline-block;
}
.stone-wrapper {
def f(x)
x + 3
end
def g(x)
x * x
end
def h(x)
2 * x
@junjis0203
junjis0203 / montecarlo-File_sturcted.go
Created May 27, 2018 08:13
File struct(hand parsing) for Go program calculating pi using monte carlo algorithm
/*
package main
import (
"fmt"
"math/rand"
)
func worker(n int, ch chan int) {
count := 0
@junjis0203
junjis0203 / sample1.html
Created January 31, 2018 14:08
vis.js network example
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css" rel="stylesheet">
<style type="text/css">
#network {
width: 400px;
height: 400px;
border: 1px solid #000;
}
</style>
@junjis0203
junjis0203 / onemax_2d.py
Created October 13, 2017 03:37
2D gene example derived from onemax_short.py
import random
import numpy
from deap import algorithms
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
@junjis0203
junjis0203 / file0.py
Created July 24, 2017 14:37
Djangoでモデル保存時(初回)に実行されるSQLを確認する ref: http://qiita.com/junjis0203/items/8ce6fcfe857e45dc8561
>>> from polls.models import Question, Choice
>>> from django.utils import timezone
>>> question = Question(question_text="What's new?", pub_date=timezone.now())
>>> question.save()
@junjis0203
junjis0203 / get-db-adapter.rb
Created July 31, 2014 07:47
降順で並べるときにnullを最後に持ってきたいが書き方はDBMSに依存するようなので、利用しているDBMSを取得する方法を調べた
Rails.configuration.database_configuration[Rails.env]['adapter']
# Usage: create_db_seed(Person) => "Person.first_or_create([{name: \"Jon\",age:23},{name: \"Mary\",age:31}])"
def create_db_seed(model)
records = model.all.map {|r|
attrs = r.attributes.map {|k,v|
next if /^id|created_at|updated_at$/ =~ k
"#{k}: #{v.inspect}"
}.compact.join(',')
"{#{attrs}}"
}.join(",\n")