Skip to content

Instantly share code, notes, and snippets.

View gutchom's full-sized avatar

gutchom gutchom

View GitHub Profile
@gutchom
gutchom / setup.sh
Created November 24, 2023 05:45
Set up shell script for CentOS
#!/bin/bash
# Install basic tools
sudo yum -y install git vim zsh zip unzip wget curl
# Create basic directories
mkdir -p ~/projects ~/tmp ~/.vim/undo
# Change default shell to zsh
if [[ $SHELL == *"zsh"* ]]; then
@gutchom
gutchom / twitter-image-downloader.js
Created October 16, 2022 06:55
code sniped for downloading images in twitter, running on developer console of web browser
const [, user] = location.pathname.split('/');
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function extract(map, tweets) {
const pares = Array.from(tweets).map(($tweet) => {
const [$time] = $tweet.getElementsByTagName('time');
if (!$time) return;
const date = new Date($time.dateTime);
const timestamp = date.toLocaleString().split('/').join('-');
printf '\e[36m\n This project has\e[35m %s lines\e[36m of source code!\n\n\e[m' $(find . -name '*.css' -o -name '*.ts' -o -name '*.tsx' | grep -v node_modules | xargs wc -l | tail -1 | awk '{print $1}')
@gutchom
gutchom / nowplayingtweet.js
Created April 20, 2022 10:13
Tweet #nowplaying via Node.js
const Jxa = import('run-jxa');
const Twitter = require('twitter');
const client = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY,
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
});
(() => {
return `
"abort scrolling"
clearInterval(${scrollToTheEnd()});
"total images count"
document.querySelectorAll('.AdaptiveMedia img').length;
`
function scrollToTheEnd(interval = 800) {
const theEnd = document.querySelector('#timeline .stream-end')
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Lyric Translation Builder</title>
<style>
body {
text-align: center;
}
@gutchom
gutchom / array-dedupe.ts
Created January 22, 2020 01:58
Help me about TypeScript
export default function equal<T>(a: T, b: T): boolean {
return typeof a === 'object' ? Object.keys(a).every(<K extends keyof T>(key: K) => equal(a[key], b[key])) : a === b
}
export function refer<T, K extends keyof T>(variable: T, property: K): T[K] {
return variable[property]
}
Array.prototype.dedupe = function dedupe<T>(comparison?: ((val1: T, val2: T) => boolean)|string, ...key: string[]): T[] {
if (typeof comparison === 'string') {
{
"name": "care-me-followers",
"version": "1.0.0",
"description": "Health condition dashboard",
"main": "index.js",
"author": "gutchom",
"license": "MIT",
"homepage": "https://github.com/gutchom/care-me-followers#readme",
"repository": {
"type": "git",
@gutchom
gutchom / verticalize.html
Last active June 28, 2019 05:57
縦書きのツイート作るよ最上川
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Verticalizer</title>
</head>
<body>
<form>
<textarea id="source" cols="40" rows="16">
縦書きの
@gutchom
gutchom / .front-configs
Last active October 26, 2017 23:57
Config files for my front-end development environment
All files are MIT Licence.