Skip to content

Instantly share code, notes, and snippets.

View martian17's full-sized avatar
🛰️
Working from home

Yutaro Yoshii martian17

🛰️
Working from home
View GitHub Profile
@martian17
martian17 / mandelbrot.js
Created October 7, 2022 05:10
draws rotated mandelbrot
let width = 1500;
let height = 1500;
let canvas = document.createElement("canvas");
document.body.innerHTML = "";
document.body.appendChild(canvas);
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext("2d");
let imgdata = ctx.getImageData(0,0,width,height);
@martian17
martian17 / scrape-contacts.js
Last active October 6, 2022 13:05
scrape contacts
/*
init commands to run
$ npm init
$ npm install jsdom
$ npm install node-fetch
*/
const {JSDOM} = require("jsdom");
const fetch = (()=>{let m = import("node-fetch");return async (...args)=>await (await m).default(...args);})();
@martian17
martian17 / byte-num-to-ascii.bf
Created July 8, 2022 06:27
number decoding to ascii brainfuck
# input format
# 0 n 0 0 0 etc
# ^
# simulating input 124
>++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
>>>+<<<
# 0 124 0 0 1
@martian17
martian17 / gitclone
Created February 21, 2022 09:13
Pull a git module with sub modules without ssh permissions
#!/bin/bash
# first extracting the repository name
rep_regex="\\/([^\\/]*)\\.git$"
if [[ $1 =~ $rep_regex ]]
then
reponame="${BASH_REMATCH[1]}"
else
echo "$1 doesn't match" >&2 # this could get noisy if there are a lot of non-matching files
exit
function range_include(a,b){
let arr = [];
for(; a <= b; a++){
arr.push(a);
}
return arr;
}
//array of the object
let Arrayobject = range_include(1,10).map((i)=>{
@martian17
martian17 / asdf.js
Last active January 12, 2022 05:15
//array of the object
let Arrayobject=[
{
section:'Dynamic Table',
marks:10
},
{
section:'Intellij Usage',
marks:10
},
@martian17
martian17 / mac.js
Last active December 27, 2021 10:17
random mac generator
Array(6).fill(0).map(a=>("00"+Math.floor(Math.random()*256).toString(16)).substr(-2).toUpperCase()).join(":")
@martian17
martian17 / murica_day.js
Created July 4, 2021 22:39
happy murica day!
let txt =
`bwbwbwbwbwbwbwbwbrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
bbbwbwbwbwbwbwbwbbsssssssssssssssssssssssssssssssssss
bwbwbwbwbwbwbwbwbrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
bbbwbwbwbwbwbwbwbbsssssssssssssssssssssssssssssssssss
bwbwbwbwbwbwbwbwbrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
bbbwbwbwbwbwbwbwbbsssssssssssssssssssssssssssssssssss
bwbwbwbwbwbwbwbwbrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
@martian17
martian17 / nepleague.js
Created June 8, 2021 12:11
このツイートに基づいて書いてみました。https://twitter.com/2_wykipedia/status/1402160697497165826
var primes = [];
var cond = [1];
for(var i = 2; i < 335; i++){
var flag = true;
var primeFlag = true;
for(var j = 0; j < primes.length; j++){
var prime = primes[j];
if(prime*prime > i)break;
primeFlag = primeFlag && (i%prime !== 0)
// flag === true if not divisible by any prime
@martian17
martian17 / hello.c
Created June 7, 2021 14:11
hello world program using write syscall
//# include <stdio.h>
// for testing purposes only
# include <stdlib.h>
# include <unistd.h>
# include <sys/time.h>
# include <time.h>
int lengthUntilNull(char * str){
int i = 0;
while(str[i] != 0){