Skip to content

Instantly share code, notes, and snippets.

View lzwjava's full-sized avatar

Zhiwei Li lzwjava

View GitHub Profile
@nicklockwood
nicklockwood / gist:21495c2015fd2dda56cf
Last active August 13, 2020 13:57
Thoughts on Swift 2 Errors

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

@xfreebird
xfreebird / customsshd
Last active May 31, 2022 07:32
A script which can be used to start a second SSHD daemon on OS X. This is an workaround for running tests using xcodebuild through ssh with Jenkins .
#!/bin/bash
INSTALL_PATH="$HOME/scripts"
SCRIPT_PATH="$INSTALL_PATH/customsshd"
LAUNCHCTL_PATH="$HOME/Library/LaunchAgents/com.my.customsshd.plist"
SSH_KEYS_INSTALL_PATH=$HOME/customkeys
SSH_HOST_KEY=$SSH_KEYS_INSTALL_PATH/ssh_host_key
SSH_HOST_RSA_KEY=$SSH_KEYS_INSTALL_PATH/ssh_host_rsa_key
SSH_HOST_DSA_KEY=$SSH_KEYS_INSTALL_PATH/ssh_host_dsa_key
SSHD_PORT=50111
@plantvsbirds
plantvsbirds / feynman-lecture-vol-i.json
Last active January 5, 2023 09:17
download your copy of epub/mobi of caltech fenman lecture on physics vol i http://www.feynmanlectures.caltech.edu/I_toc.html, powered by https://github.com/lepture/getbook/
{
"uid": "feynman-lecture-vol-i",
"title": "The Feynman Lectures on Physics, Volume I",
"author": "Richard Feynman",
"chapters": ["http://www.feynmanlectures.caltech.edu/I_89.html","http://www.feynmanlectures.caltech.edu/I_90.html","http://www.feynmanlectures.caltech.edu/I_91.html","http://www.feynmanlectures.caltech.edu/I_92.html","http://www.feynmanlectures.caltech.edu/I_01.html","http://www.feynmanlectures.caltech.edu/I_02.html","http://www.feynmanlectures.caltech.edu/I_03.html","http://www.feynmanlectures.caltech.edu/I_04.html","http://www.feynmanlectures.caltech.edu/I_05.html","http://www.feynmanlectures.caltech.edu/I_06.html","http://www.feynmanlectures.caltech.edu/I_07.html","http://www.feynmanlectures.caltech.edu/I_08.html","http://www.feynmanlectures.caltech.edu/I_09.html","http://www.feynmanlectures.caltech.edu/I_10.html","http://www.feynmanlectures.caltech.edu/I_11.html","http://www.feynmanlectures.caltech.edu/I_12.html","http://www.feynmanlectures.caltech.edu/I_13.html","http://www.feynman
@xiaolai
xiaolai / markdownhere.css
Created July 2, 2016 12:12
markdown-here-css
.markdown-here-wrapper {
font-size: 16px;
line-height: 1.8em;
letter-spacing: 0.1em;
}
pre, code {
font-size: 14px;
font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace;
@johnz133
johnz133 / elon_musk_use_commencement_speech_transcript
Last active April 1, 2024 16:11
Elon Musk USC Commencement Speech Transcript.
Alright, thank you.
So, I’ve got about apparently I’ve got about five to six minutes to say the most useful things I can think of.
I’m gonna do my best.
It was suggested that I distill things down to 3 items.
I think I’ll go with four.
And I’ll try, I think, I think these are pretty important ones.
Some of it may kinda sound like, well you’ve heard them before.
But, you know, worth reemphasizing.
I think the first is, you need to work, if you, depending on how well you want to do,
@mabasic
mabasic / helpers.php
Last active April 27, 2024 14:07
config_path function for Lumen framework
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@Kartones
Kartones / postgres-cheatsheet.md
Last active May 9, 2024 10:07
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

Ubuntu 22.04 for Deep Learning

In the name of God

This gist contains steps to setup Ubuntu 22.04 for deep learning.


Install Ubuntu 22.04