Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

weixiang lesywix

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

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 Feb 26, 2020
A simple cache of ttl base
View TTL_cache.py
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 Jun 1, 2018
Check if django DB migrations is not synchronized. Import `exit_if_db_not_synchronized` in wsgi.py
View django_db.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):