Skip to content

Instantly share code, notes, and snippets.

def rollback(migrations_path)
migrations_paths_was = ActiveRecord::Migrator.migrations_paths
ActiveRecord::Migrator.migrations_paths = [migrations_path]
ActiveRecord::Tasks::DatabaseTasks.check_target_version
scope = ENV["SCOPE"]
verbose_was, ActiveRecord::Migration.verbose = ActiveRecord::Migration.verbose, ActiveRecord::Tasks::DatabaseTasks.send(:verbose?)
ActiveRecord::Base.connection.migration_context.down(ActiveRecord::Tasks::DatabaseTasks.target_version) do |migration|
scope.blank? || scope == migration.scope
@Dounx
Dounx / 130.go
Created September 20, 2019 15:22
130
type unionFind struct {
parent []int
rank []int
boundedNode map[int] bool
}
func NewUnionFind(board [][]byte) *unionFind {
m := len(board)
n := len(board[0])
@Dounx
Dounx / package.json
Created September 9, 2019 09:18
package.json
{
"name": "ant-design-pro",
"version": "1.0.0",
"private": true,
"description": "An out-of-box UI solution for enterprise applications",
"scripts": {
"analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build",
"deploy": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site npm run site && npm run gh-pages",
"fetch:blocks": "pro fetch-blocks",
@Dounx
Dounx / yarn.log
Created September 9, 2019 08:20
yarn.log
yarn upgrade v1.17.3
[1/5] Validating package.json...
[2/5] Resolving packages...
warning @ant-design/pro-layout > antd > rc-tree-select > rc-trigger > rc-animate > fbjs > core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
warning dva > react-router-redux@5.0.0-alpha.9: This project is no longer maintained.
warning dva > dva-core > flatten@1.0.2: I wrote this module a very long time ago; you should use something else.
warning umi > umi-build-dev > umi-notify > is-ali-env > superagent@3.8.3: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header). This notice will go away with v5.0.2+ once it is released.
warning umi > umi-build-dev > umi-test > jest-cli > jest-config > jest-environment-jsdom > jsdom > left-pad@1.3.0: use String.prototype.padStart()
warning umi-plugin-react > umi-plugin-dva > dva > dva-core > flatt
@Dounx
Dounx / 139.go
Created September 6, 2019 10:54
139. 单词拆分
// s = "catsandog"
// wordDict = ["cats", "dog", "sand", "and", "cat"]
// dp[0] = "" => true
// dp[1] = "c" => false
// dp[2] = "ca" => false
// dp[3] = "cat" -> dp[0] && wordMap["cat"] => true
// dp[4] = "cats" -> dp[0] && wordMap["cats"] => true
// dp[5] = "catsa" => false
// dp[6] = "catsan" => false
// dp[7] = "catsand" -> dp[3] && wordMap["sand"] => true
@Dounx
Dounx / subsets.go
Created August 30, 2019 15:55
78. 子集
// [9,0,3,5,7]
// When num = 9, size = 16, i = 7, there will be a strange issue:
// ans[15][3] 7 -> 9
func subsets(nums []int) [][]int {
sort.Ints(nums)
// fmt.Println(nums)
ans := make([][]int, 0)
ans = append(ans, []int{})
# s[i..j]
# dp[i][j] = (s[i] == s[j]) && (j - i <= 2 || dp[i + 1, j - 1])
# @param {String} s
# @return {String}
def longest_palindrome(s)
return s if s.size <= 1
longest_size = 1
longest_s = s[0]