Skip to content

Instantly share code, notes, and snippets.

View 4096void's full-sized avatar
:shipit:
wrangling

TJ 4096void

:shipit:
wrangling
View GitHub Profile
@4096void
4096void / ThemeToggle.tsx
Created December 25, 2024 12:13
theme toggle
'use client';
import { useTheme } from './ThemeProvider';
export function ThemeToggle() {
const { theme, toggleTheme } = useTheme();
return (
<button
onClick={toggleTheme}
@4096void
4096void / ThemeProvider.tsx
Created December 25, 2024 12:10
theme provider
'use client';
import { createContext, useContext, useEffect, useState } from 'react';
import { lightTheme, darkTheme } from '@/styles/theme';
type Theme = 'light' | 'dark';
interface ThemeContextType {
theme: Theme;
toggleTheme: () => void;
@4096void
4096void / cross.svg
Last active June 4, 2024 05:56
erd icons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@4096void
4096void / TJ's FAQs.md
Last active November 15, 2022 08:52
google search cache for TJ's FAQs
  • get my Mac's RSA public key, pbcopy < ~/.ssh/id_rsa.pub

GR III

  • move files if destination does not exists, mv -vn from_dir/**.JPG to_dir
  • rename files, find . -depth -name "*.JPG" -exec sh -c 'f="{}"; mv -- "$f" "${f%.JPG}_1.JPG"' \;

Git

  • delete a branch locally and remotely, git branch -d ${local_branch} && git push orogin -d ${remote_branch}
  • create local branch in git then push it to remote, git checkout -b <branch> && git push -u origin <branch>
  • push to another url, git remote set-url origin
@4096void
4096void / README.md
Last active May 28, 2019 03:55
about frontend interview

How to prepare.

About.

  • I was mainly responsible for ...
  • I just kind of ...
  • Collecting feedbacks and requirements from customers and project-manager. #developing requirements
  • Brainstorming new production ideas. #developing requirements
  • Building application prototype with visual-designer and backend-developer (from zero to one). #team
  • In frontend part, I was in charge of choosing technology stacks and relevant tools for frontend developing. #leadership
  • I've been heavily used ReactJS, Vue and libraries of their ecosystem. #technologies
  • My strengths lies in solid foundations of HTML, CSS and JavaScript. #strengths
@4096void
4096void / .block
Created April 15, 2019 09:54
multiple lines in one linechart
license: mit
@4096void
4096void / .block
Last active April 15, 2019 06:58
random × random
license: mit
@4096void
4096void / ××s2××n.sh
Created December 21, 2018 04:57
××s2××n
#!/bin/bash
# Install Shadowsocks on CentOS 7
echo "Installing Shadowsocks..."
random-string()
{
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
@4096void
4096void / index.js
Created December 5, 2018 10:35
make your compression easy.
/*
Compress images in current dir & its subdir ...
*/
var tinify = require("tinify");
var fs = require("fs");
var path = require("path");
tinify.key = "YOUR_TINYPNG_API_KEY";
var imgsQ = [];
@4096void
4096void / abstractHTML2less.js
Last active November 15, 2018 15:34
HTML's less abstract
function html2less($item, pass) {
var tmp = {};
$item = $item || $("body");
pass = pass || { max: 50, count: 0, less: "" };
$item.each(function (n, v) {
var tagName = '', // this.tagName.toLowerCase()
className = this.className && `.${this.className}` || '',
selector = tagName + className, // todo