Skip to content

Instantly share code, notes, and snippets.

View lesywix's full-sized avatar
🎯
Focusing

weixiang lesywix

🎯
Focusing
View GitHub Profile
@lesywix
lesywix / README.md
Created February 6, 2022 15:43 — forked from progrium/README.md
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

@lesywix
lesywix / TTL_cache.py
Created February 26, 2020 09:24
A simple cache of ttl base
import collections
import threading
try:
from time import monotonic as default_timer
except ImportError:
from time import time as default_timer
class TTLCache:
@lesywix
lesywix / django_db.py
Last active June 1, 2018 13:47
Check if django DB migrations is not synchronized. Import `exit_if_db_not_synchronized` in wsgi.py
# coding: utf-8
from __future__ import absolute_import
import functools
from django.db import close_old_connections, connections, DEFAULT_DB_ALIAS
from django.db.migrations.executor import MigrationExecutor
def close_connection_after_call(f):