Skip to content

Instantly share code, notes, and snippets.

View appleshan's full-sized avatar
💭
抛弃世俗之浮躁,留我钻研之刻苦.

Alec Shan appleshan

💭
抛弃世俗之浮躁,留我钻研之刻苦.
View GitHub Profile
@appleshan
appleshan / curl.md
Created April 10, 2023 02:25 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@appleshan
appleshan / i3-cheat-sheet.md
Created March 25, 2023 06:32 — forked from JeffPaine/i3-cheat-sheet.md
i3 Window Manager Cheat Sheet

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (alt by default)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
@appleshan
appleshan / pre-commit.sh
Created March 13, 2023 10:28 — forked from tmelz/pre-commit.sh
auto format java files with google-java-format
#!/bin/bash
# Auto format changed java files using google-java-format.
# To install, copy this file into $repo/.git/hooks and remove the .sh extension.
# Download the google-java-format JAR from
# https://github.com/google/google-java-format
# A more mature implementation of this would be a plugin for Yelp's pre-commit library:
# http://pre-commit.com/
echo "Running auto-formatter for any changed Java files"
echo "(formatting changes will be automatically added to your commit)"
package my.netty.http.upload;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.HttpRequestDecoder;
@appleshan
appleshan / ssh-agent.md
Created February 15, 2023 11:52 — forked from mvneves/ssh-agent.md
"Could not open a connection to your authentication agent"

SSH authentication agent does not automatically start when using it from a remote server. This results in the following error message:

$ git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
$ ssh-add ~/my-ssh-key.pem
Could not open a connection to your authentication agent.

To fix it requires manually starting ssh-agent:

@appleshan
appleshan / arch-i3gaps-install.md
Created February 4, 2023 16:06 — forked from fjpalacios/arch-i3gaps-install.md
Arch + i3-gaps Install Guide

Arch + i3-gaps Install Guide

First set up your keyboard layout. For example, in Spanish:

   # loadkeys es

For a list of all acceptable keymaps:

   # localectl list-keymaps
@appleshan
appleshan / git-workflow.svg
Created April 16, 2022 14:11 — forked from twlz0ne/git-workflow.svg
git workflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

基于上游仓库某次提交做了修改

----(a)---------------> upstream/up_master
      \
------(b)-------------> origin/my_master

一段时间之后,上游仓库更新了

----(a)--(c)--(d)--(e)--(f)--(g)--> upstream/up_master
@appleshan
appleshan / here-emacs
Created April 16, 2022 09:29 — forked from twlz0ne/here-emacs
Launch emacs from emacs.d folder you placed anywhere.
#!/usr/bin/env bash
##
# Launch emacs from emacs.d folder you placed anywhere.
#
# @author gongqijian@gmail.com
# @date 2016-07-21
#
function usage {
cat<<EOF
@appleshan
appleshan / fix_database_to_utf8.py
Created April 6, 2022 11:51 — forked from miratcan/fix_database_to_utf8.py
Small python script that converts character sets to utf8 in all databases and tables. My solution for "Illegal mix of collations" errors. (http://stackoverflow.com/questions/3029321/how-to-solve-illegal-mix-of-collations-in-mysql)
from MySQLdb import connect
conn = connect(user="[USER]", passwd= "[PASSWORD]")
cur = conn.cursor()
cur.execute("show databases;")
dbs_to_update = filter(
lambda db: db not in ('information_schema', 'mysql', 'performance_schema'),
[dbname[0] for dbname in cur.fetchall()])