Skip to content

Instantly share code, notes, and snippets.

View yaodong's full-sized avatar

Yaodong Zhao yaodong

View GitHub Profile
@yaodong
yaodong / 0fixup.md
Created July 31, 2024 21:09 — forked from silent1mezzo/0fixup.md
On undoing, fixing, or removing commits in git

A git choose-your-own-adventure!

This document is an attempt to be a fairly comprehensive guide to recovering from what you did not mean to do when using git. It isn't that git is so complicated that you need a large document to take care or your particular problem, it is more that the set of things that you might have done is so large that different techniques are needed depending on exactly what you have done and what you want to have happen.

@yaodong
yaodong / __init__.py
Last active February 20, 2022 17:12
a service layer use flask local stack
from functools import partial
from flask import Flask
from flask import current_app
from werkzeug.local import LocalProxy
from werkzeug.local import LocalStack
from .boto import Boto3Service
from .cognito import CognitoService
Server Error in '/' Application.
The network path was not found
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The network path was not found
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
---
- hosts: manage
remote_user: root
tasks:
- name: install dependencies
apt:
package:
- apt-transport-https
- ca-certificates
- curl
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:')
Session = sessionmaker(bind=engine)
session = Session()
from datetime import datetime
const fs = require('fs')
const crypto = require('crypto')
const publicKey = fs.readFileSync('public.pem')
const privateKey = fs.readFileSync('private.pem')
const message = 'Hello, world!'
const encryptedMsg = crypto.publicEncrypt(publicKey, Buffer.from(message, 'utf8'))
console.log('encrypted by private key: ' + encryptedMsg.toString('hex'))
###########################
# Common Configuration
###########################
set -g default-terminal "screen-256color"
# use vim key bindings
setw -g mode-keys vi
# increase repeat time for repeatable commands
a.js
const mapDispatchToProps = (dispatch) => {
create: function(name) {
dispatch(createUser(name));
dispatch(displayUser(name));
}
}
connect(mapDispatchToProps)(A)
title date tags categories
How to get started to build your own Spacemacs
2018-10-12 12:59
emacs
Tools

I have been a Vim user for quite a while. I love it, so the very first thing when I set up a new server is installing VIM. I heard a lot about Emacs and tried it. It's better at almost everything except text editing. So I stayed with Vim until Spacemacs was released. The Vim key bindings of Spacemacs is so excellent that I switched.

However, Spacemacs has its problem: boots up slowly and crashes frequently. Upgrading packages became very challenging. Finally, I have to use the develop branch because the master branch is not working anymore. People began to complain and requested to speed up the release from the master branch. Considering its dependencies and numerous open issues, I have no hope for this.

@yaodong
yaodong / download_leetcode_problem_list.rb
Last active March 29, 2019 20:15
leetcode problems list
#!/usr/bin/ruby
require 'net/http'
require 'json'
require 'yaml'
url = URI('https://leetcode.com/api/problems/algorithms/')
res = Net::HTTP.get(url)
data = JSON.parse(res)
problems = data['stat_status_pairs'].map do |pair|