Skip to content

Instantly share code, notes, and snippets.

View melotusme's full-sized avatar
💭
Busy and excited

wrong melotusme

💭
Busy and excited
View GitHub Profile
@melotusme
melotusme / README.md
Created July 20, 2020 12:48 — forked from joyrexus/README.md
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@melotusme
melotusme / Base64.md
Created April 26, 2020 10:23 — forked from barrysteyn/Base64.md
OpenSSL Base64 En/Decode: Portable and binary safe.

OpenSSL Base64 Encoding: Binary Safe and Portable

Herewith is an example of encoding to and from base64 using OpenSSL's C library. Code presented here is both binary safe, and portable (i.e. it should work on any Posix compliant system e.g. FreeBSD and Linux).

License

The MIT License (MIT)

Copyright (c) 2013 Barry Steyn

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@melotusme
melotusme / example.sql
Last active November 8, 2019 03:58
sql mysql
-- mysql 行转列, 一个字段转成多行记录
-- 使用了辅助表 mysql.help_topic
SELECT
id, b.help_topic_id, SUBSTRING_INDEX( SUBSTRING_INDEX(id,',', b.help_topic_id+1),',',-1)
FROM
( SELECT "1,2,3,4,5" AS id ) a
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( a.id ) - LENGTH( REPLACE ( a.id, ',', '' ))+ 1 );
@melotusme
melotusme / CMakeLists.txt
Last active October 31, 2019 02:47
ffmpeg
cmake_minimum_required(VERSION 3.15)
project(learning_demos C)
set(CMAKE_C_STANDARD 11)
include_directories("/usr/local/Cellar/ffmpeg/4.2.1_1/include")
link_directories("/usr/local/Cellar/ffmpeg/4.2.1_1/lib")
find_package(sdl2)
include_directories(${SDL2_INCLUDE_DIRS})
@melotusme
melotusme / hide-all-app.scpt
Created October 8, 2019 02:29 — forked from Teraflopst/hide-all-app.scpt
AppleScript: Hide all applications and show the desktop on Mac
tell application "Finder"
set visible of every process whose visible is true and name is not "Finder" to false
set the collapsed of windows to true
end tell
@melotusme
melotusme / install-tmux.sh
Created July 2, 2019 02:58 — forked from pokev25/install-tmux.sh
Install tmux 2.8 on centos 7
# Install tmux 2.8 on Centos
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -LOk https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=/usr/local
@melotusme
melotusme / RPi-aria2-with-webui.sh
Created April 26, 2018 12:39 — forked from akaxxi/RPi-aria2-with-webui.sh
Install Aria2 and webui on Raspberry Pi with one simple script.
#!/bin/sh
DOWNLOAD_DIR="${HOME}/MiniDLNA"
CONFIG_DIR="${HOME}/.aria2"
RPC_TOKEN="changeIt"
RPC_PORT="6800"
change_apt_source(){
if [ -f /etc/apt/sources.list ]; then
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
@melotusme
melotusme / one-liners.md
Created March 29, 2018 03:59 — forked from KL-7/one-liners.md
Ruby one-liners

One-liners

Reverse every line:

Input file:

$ cat foo
qwe
123

bar