Skip to content

Instantly share code, notes, and snippets.

View trpfrog's full-sized avatar
🏠
Working from home

tsmami trpfrog

🏠
Working from home
View GitHub Profile
@trpfrog
trpfrog / TransposeListener.java
Created April 9, 2016 16:35
音の移調をします
package net.trpfrog.frogrobo.mini_tools;
import java.util.ArrayList;
import java.util.function.IntBinaryOperator;
import net.trpfrog.frogrobo.streaming.MentionListenerPlus;
import twitter4j.Status;
public class TransposeListener extends MentionListenerPlus {
public class Twitter {
import twitter4j.Twitter;
import twitter4j.TwitterFactory;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
import twitter4j.conf.ConfigurationBuilder;
protected TwitterStream stream;
protected final ConfigurationBuilder getBuilder(){ //ConfigurationBuilderの設定
@trpfrog
trpfrog / MakePicture.java
Created June 22, 2019 21:15
ppmファイルで使うグラデーション作るやつ
public class MakePicture {
public static void main(String[] args){
final int WIDTH = 255;
final int HEIGHT = 255;
RGB rgb = new RGB();
System.out.println("P3 255 "+WIDTH+" "+HEIGHT);
printRedBlueGradation(rgb,WIDTH,HEIGHT);
}
private static void printRedBlueGradation(RGB rgb, int width, int height){
@trpfrog
trpfrog / PictureMaker.java
Last active June 28, 2019 15:21
グラデーションを作ります
public class PictureMaker {
public static void main(String[] args){
Canvas canvas = new Canvas(10,10,255); //この時10×10pxの画像を出力します
RGB rgb = new RGB(0,0,0,255);
canvas.printHeader();
for (int y=0; y<canvas.getHeight(); y++) {
System.out.println();
@trpfrog
trpfrog / InverseMatrix.html
Created August 5, 2019 13:55
3*3の逆行列を計算します
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="favicon.ico">
<script type="text/javascript" src="./InverseMatrix.js"></script>
<style>
body{ margin: 2em; font-size: 3em;}
input{ font-size: 1em; text-align: center; width: 3em;}
@trpfrog
trpfrog / PrimeSearch.java
Created August 25, 2019 09:36
素数判定プログラムです。(4年前より速い)
import java.util.ArrayList;
import java.util.List;
public class PrimeSearch {
public static List<Integer> primeList;
public static int maxSearchIdx = 0;
public static void main(String[] args){
int number = 2019;
int numberOfPrime = 6*number/(int)(Math.round(Math.log(number)*5));
@trpfrog
trpfrog / trpfrog_builder.rb
Last active November 14, 2019 18:53
つまみアイコンを出力します。
WIDTH = 500
HEIGHT = 500
Pixel = Struct.new(:r,:g,:b)
$img = Array.new(HEIGHT) do
Array.new(WIDTH) do Pixel.new(255,255,255) end
end
def clear
$img = Array.new(HEIGHT) do
@trpfrog
trpfrog / LaTeXTableMaker.java
Last active November 18, 2019 18:22
表計算ソフトからコピーした表データをLaTeX形式に変換し、クリップボードにコピーします。指数表記(E-01,E+00など)もLaTeXの数式に変換されます。
package net.trpfrog.latex_table_generator;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.Scanner;
public class LaTeXTableMaker {
public static final String INDENT = " ";
@trpfrog
trpfrog / NearestPointOnHalfLine.pde
Created May 9, 2021 18:38
最も近い半直線上の点の座標を計算するやつ
PVector A, B;
void halfStraightLine(float x1, float y1, float x2, float y2) {
final int INF = 10000;
line(x1, y1, x1 + (x2 - x1) * INF, y1 + (y2 - y1) * INF);
}
PVector calcQ(float x, float y) {
float theta = atan2(B.y - A.y, B.x - A.x);
float d = dist(A.x, A.y, B.x, B.y);
@trpfrog
trpfrog / google-centering.css
Created July 4, 2021 11:18
Googleの検索結果を中央寄せするやつ
:root {
--google-margin-left: calc((100vw - 600px) / 2);
}
@media (min-width:1600px) {
.A8SBwf {
margin-left: calc(var(--google-margin-left) - 37px);
}
.MUFPAc {