Skip to content

Instantly share code, notes, and snippets.

View aster-hu's full-sized avatar
🏠
Working from home

Aster Hu aster-hu

🏠
Working from home
View GitHub Profile
@xiesixia
xiesixia / coalesce_join.R
Last active August 22, 2024 13:32
Coalesce join function applied to data frame (expand coalesce function from dplyr)
# For detailed explaination of this function, check this blog post: https://asterhu.com/post/2023-05-11-coalesce-join-in-r/
# Reference: https://alistaire.rbind.io/blog/coalescing-joins/
require(dplyr)
require(stringr)
coalesce_join <- function(x, y,
by = NULL,
keep = c("left", "right"), # "left" means keep value from left table if there's any duplicate value in both tables.
suffix = c(".x", ".y"),
join = c("full_join","left_join", "right_join", "inner_join")) {
@kepano
kepano / obsidian-web-clipper.js
Last active November 14, 2024 04:15
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/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@XueshiQiao
XueshiQiao / ExportNetEaseMusicSongList.js
Last active October 25, 2024 19:29
导出网易云音乐歌单到 AppleMusic / Spotify 等平台
/**
* 使用方法:
* 1. 用 Chrome 打开歌单的 web 页面(可以通过分享拿到链接,链接类似这样:http://music.163.com/playlist?id=xxx&userid=yyy)
* 2. 然后右键“检查”(如果有左上角有 device 选项,需要选择 Laptop 开头的,可以在 Edit/编辑 里添加,添加的时候注意 “User Agent string” 里选择 Desktop)
* 3. 在 console 里输入下面脚本,即可输出 “歌曲名 - 歌手名” 格式的内容:
Springsteen - Eric Church
Chattahoochee - Alan Jackson
Baby Now That I Found You - Alison Krauss
Check Yes or No - George Strait
@kepi
kepi / org-archive-subtree-hierarchical.el
Last active October 12, 2024 23:09
Hierarchical archiving for Org-mode
;; org-archive-subtree-hierarchical.el
;;
;; version 0.2
;; modified from https://lists.gnu.org/archive/html/emacs-orgmode/2014-08/msg00109.html
;; modified from https://stackoverflow.com/a/35475878/259187
;; In orgmode
;; * A
;; ** AA
;; *** AAA
import nbformat
import os
import sys
file_name = sys.argv[1]
def parse(code: list) -> nbformat.v4:
nb = nbformat.v4.new_notebook()
nb["cells"] = []
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active September 24, 2024 04:20
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@bradleybossard
bradleybossard / titleUrlMarkdownClip.js
Created December 5, 2015 21:09
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;