Skip to content

Instantly share code, notes, and snippets.

@githubhy
githubhy / gist:179559994119a43d2b17129c3817153e
Last active May 4, 2022 10:13
Regular expression for Chinese characters
perl: /[^u4E00-u9FA5]/
js: match(/[\u4E00-\u9FA5]/)
Example:
use `<([^u4E00-u9FA5]*<[^u4E00-u9FA5]+>[^u4E00-u9FA5]*)*>` to match `<封爵 河津亭侯→安國鄉侯→向鄉侯→舞陽侯→晉王<追尊>→晉帝<追尊>>`
@githubhy
githubhy / RMD_and_GitHub.docx
Created May 3, 2022 13:10 — forked from JoshuaTPierce/RMD_and_GitHub.docx
Creating and Pushing a R-Markdown Document to Github (including graphs)
Go to github
Create new repository [don't need to initialize with the readme (can add later)]
Go to R Studio
File -> New Project -> Version Control -> Git
Ctrl+V repository URL from GitHub
File -> New -> Markdown, enter Title, etc.
In the Markdown window, change "output=html_document" to "output=github_document"
Knit the document for the first time, will prompt you to save
Save as Title.rmd
In the "git" tab of the R studio Environment window, you will notice that the knit produced:
@githubhy
githubhy / git_submodules.md
Created May 5, 2021 10:52 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@githubhy
githubhy / brew-list.sh
Created May 3, 2021 04:27 — forked from eguven/brew-list.sh
List all packages installed using Homebrew and their sizes
brew list --formula | xargs -n1 -P8 -I {} \
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \
sort -h -r -k2 - | column -t
@githubhy
githubhy / podcast-dl.sh
Created March 20, 2021 00:43
Download all episodes from a podcast RSS feed
URL=https://feeds.buzzsprout.com/136050.rss # A URL example
curl -s $URL | xmlstarlet sel -N atom="http://www.w3.org/2005/Atom" -t -m './/enclosure' -v '@url' -n | xargs -n 1 -P 10 wget -nc
@githubhy
githubhy / rename.sh
Last active March 20, 2021 00:40
Rename file on macOS (one-liner perl)
# [Example] mv 818210-021-english-vocabulary-devious-devout.mp3?blob_id=1265211 021-english-vocabulary-devious-devout.mp3
# [Perl switches] https://perl101.org/command-line-switches.html
# Use "chomp" to remove '\n' from "$_". See https://perldoc.perl.org/functions/chomp
ls | perl -pe 'chomp;s/^\d+-(\d{3}-.*\.mp3)\?.*$/mv $_ $1 \n/' | sh
@githubhy
githubhy / understanding_new_keyword.js
Created April 1, 2016 16:09
Understanding what new keyword do and the prototype inheritance.
'use strict'
function Scope() {
this.va = '123';
};
Scope.prototype.va = 'abc';
var s = new Scope();
@githubhy
githubhy / toggleiTerm2icon
Last active March 27, 2016 12:43 — forked from lg0/toggleiTerm2icon
show/hide iTerm2 Dock icon
# toggle iTerm Dock icon
# add this to your .bash_profile or .zshrc
function toggleiTerm() {
pb='/usr/libexec/PlistBuddy'
iTerm='/Applications/iTerm.app/Contents/Info.plist'
echo "Do you wish to hide iTerm in Dock?"
select ync in "Hide" "Show" "Cancel"; do
case $ync in
'Hide' )
@githubhy
githubhy / index.jade
Created March 22, 2016 02:55
Microsoft JQuery CDN.
script(src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.2.1.min.js")
@githubhy
githubhy / split.js
Created March 22, 2016 02:45
Split sentence in HTML
var newText = $( "p" ).text().split( " " ).join( "</span> <span>" );
newText = "<span>" + newText + "</span>";
$( "p" )
.html( newText )
.find( "span" )
.hover(function() {
$( this ).addClass( "hilite" );
}, function() {
$( this ).removeClass( "hilite" );