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
@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;
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active July 23, 2024 17:45
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:

import nbformat
import os
import sys
file_name = sys.argv[1]
def parse(code: list) -> nbformat.v4:
nb = nbformat.v4.new_notebook()
nb["cells"] = []
@kepi
kepi / org-archive-subtree-hierarchical.el
Last active July 25, 2024 09:45
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
@XueshiQiao
XueshiQiao / ExportNetEaseMusicSongList.js
Last active July 6, 2024 07:26
导出网易云音乐歌单到 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
@kepano
kepano / obsidian-web-clipper.js
Last active July 22, 2024 07:29
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 = "";
/* Optional folder name such as "Clippings/" */
@xiesixia
xiesixia / coalesce_join.R
Last active May 19, 2023 06:51
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")) {