Skip to content

Instantly share code, notes, and snippets.

@wangyingang
wangyingang / obsidian-web-clipper.js
Last active April 12, 2024 04:41 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "Obsidian-Vault";
/* Optional folder name such as "Clippings/" */
@wangyingang
wangyingang / 01.bash_shortcuts_v2.md
Created February 7, 2023 07:45 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
Since 2013 a video format much better than H.264 is widely available, namely H.265 (better in that it compresses more for the same quality, or gives higher quality for the same size). To use it, replace the libx264 codec with libx265, and push the compression lever further by increasing the CRF value — add, say, 4 or 6, since a reasonable range for H.265 may be 24 to 30. Note that lower CRF values correspond to higher bitrates, and hence produce higher quality videos.
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
To see this technique applied using the older H.264 format, see this answer, quoted below for convenience:
Calculate the bitrate you need by dividing your target size (in bits) by the video length (in seconds). For example for a target size of 1 GB (one gigabyte, which is 8 gigabits) and 10 000 seconds of video (2 h 46 min 40 s), use a bitrate of 800 000 bit/s (800 kbit/s):
ffmpeg -i input.mp4 -b 800k output.mp4
@wangyingang
wangyingang / IdeaVim OS X Key Repeat.markdown
Created November 26, 2021 18:10 — forked from lsd/IdeaVim OS X Key Repeat.markdown
Enable key-repeat for ALL applications or just for IdeaVim/specific JetBrains apps

Upgrading to Lion or Yosemite and WebStorm 9, I noticed key repeat was
turned off for the IdeaVim plugin h j k l keys.

System-wide key repeat

defaults write -g ApplePressAndHoldEnabled -bool false in a terminal will enable
key repeat for every app. This can alternatively be found in the accessibility settings in OS X' preferences.

App specific key repeat

@wangyingang
wangyingang / README-Template.md
Created January 5, 2019 01:14 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@wangyingang
wangyingang / Utils.java
Created July 13, 2015 18:06
Convert InputStream to Byte Array
public class Utils {
public static byte[] getBytes(InputStream is) throws IOException {
int len;
int size = 1024;
byte[] buf;
if (is instanceof ByteArrayInputStream) {
size = is.available();
@wangyingang
wangyingang / UrlEscapeSample.java
Created July 10, 2015 08:55
URL escape sample (java.net.URLEncoder and Guava UrlEscaper)
public class UrlEscapeSample {
public static void main(String[] args) {
String filename = "中国 地图/? a.docx";
String urlEncoding = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
prettyPrint("java.net.URLEncoder", urlEncoding);
prettyPrint("UrlEscapers.urlFormParameterEscaper", UrlEscapers.urlFormParameterEscaper().escape(filename));
prettyPrint("java.net.URLEncoder then replace to %20", urlEncoding.replaceAll("\\+", "%20"));
prettyPrint("UrlEscapers.urlPathSegmentEscaper", UrlEscapers.urlPathSegmentEscaper().escape(filename));
prettyPrint("UrlEscapers.urlFragmentEscaper", UrlEscapers.urlFragmentEscaper().escape(filename));
}
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Environment;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.assertj.core.data.MapEntry;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.junit.ClassRule;
import org.junit.Test;