Skip to content

Instantly share code, notes, and snippets.

View iShawnWang's full-sized avatar
🤗
2333

Shawn Wang iShawnWang

🤗
2333
View GitHub Profile
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active March 9, 2024 12:03
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

# lazyload nvm
# all props goes to http://broken-by.me/lazy-load-nvm/
# grabbed from reddit @ https://www.reddit.com/r/node/comments/4tg5jg/lazy_load_nvm_for_faster_shell_start/
lazynvm() {
unset -f nvm node npm npx
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
if [ -f "$NVM_DIR/bash_completion" ]; then
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
@remarkablemark
remarkablemark / Dockerfile
Last active April 24, 2024 13:40
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
1. `vim /etc/syslog.conf`
2. Add to end of file: `cron.* /var/log/cron.log`
3.
```
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
```
[where-is-the-cron-log-file-in-macosx-lion](http://apple.stackexchange.com/questions/38861/where-is-the-cron-log-file-in-macosx-lion)
@52cik
52cik / npm.taobao.sh
Last active February 29, 2024 02:56
npm 淘宝镜像配置
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
@mokagio
mokagio / update_xcode_plugins.sh
Last active May 17, 2019 08:54
Script updating all plugins to be compatible with the latest Xcode and Xcode-beta
#!/bin/bash
#
# Updates all plug-ins to be compatible with the latest Xcode and Xcode-beta
#
plugins_location="~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins"
# Get Xcode's version
current_xcode_version="$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)"
@lukas-h
lukas-h / license-badges.md
Last active May 1, 2024 10:20
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

// TextView subclass that replicates TVOS movies app
// Also made a quick presentation controller
// Just connect the delegate to the ViewController in IB
// and set the TextView class to FocusTextView
import UIKit
class TextPresentationViewController:UIViewController {
let label = UILabel()
let blurStyle = UIBlurEffectStyle.Dark
@ryuichis
ryuichis / gist:755e6297aec13c900cdf
Last active June 4, 2022 05:38 — forked from gavrix/gist:5054182
Script integrating OCLint into XCode. Put it in "Run script" build phase.
source ~/.bash_profile
cd ${SRCROOT}
xcodebuild clean
xcodebuild | xcpretty -r json-compilation-database
oclint-json-compilation-database -- -report-type xcode
@marcoconti83
marcoconti83 / Guard-catch.swift
Created October 29, 2015 23:46
Guard-catch in swift?
/**
# QUESTION
Is there a way to combine `guard` and `try-catch`, so that we can
exploit the `guard let` to have a immutable value, but have an early
return in case of errors?
*/