Skip to content

Instantly share code, notes, and snippets.

View nma's full-sized avatar

Nick Ma nma

View GitHub Profile
@nma
nma / gist:ae37618ea76f4d08b58f5b3729b6e836
Created June 30, 2016 18:34
Nginx config for use with ember HISTORYLOCATION
server {
root /var/www/{Your App Directory Path Here};
index index.html index.htm;
server_name {Your website URL or IP address here};
location / {
try_files $uri $uri/ /index.html?/$request_uri;
}
}
@nma
nma / UbuntuHiDPI.md
Last active September 11, 2022 13:29
DPI Scaling Fix for Ubuntu on HiDPI 3840x2160 eDP1 with 1920x1080 External Monitor

Based on the contents http://blog.jamiek.it/2015/04/manually-fixing-multiple-screens-with.html

  • Set your Ubuntu to the highest DPI from the System Configurations
  • If not using Ubuntu, then you may need to configure based on instructions here and use a DPI calclator.
  • Please referer to the full blog post and give thanks to the OP.
  • This is just notes and a cached script for my personal laptop
  • My External Monitor (HDMI2) is Above my Laptop Screen (eDP1)
@nma
nma / dockerinfo.txt
Last active November 24, 2016 07:09
RaspberryPI images
Containers: 9
Running: 0
Paused: 0
Stopped: 9
Images: 64
Server Version: 1.10.3
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 89
@nma
nma / ifme_rails_c9ide_rake_setup.rb
Created February 9, 2017 01:58
Rake tasks for quickly setting up C9 IDE.
desc 'Automate the Config Setup for New Environments'
task :setup_workspace do
dev_example = Rails.root + 'config/env/development.example.env'
dev_target = Rails.root + 'config/env/development.env'
FileUtils.cp(dev_example, dev_target)
test_example = Rails.root + 'config/env/test.example.env'
test_target = Rails.root + 'config/env/test.env'
FileUtils.cp(test_example, test_target)
I have run an nginx container...
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d67de07731d nginx "nginx -g 'daemon ..." 40 minutes ago Up 40 minutes 80/tcp, 443/tcp epic_goldberg
I want to use Debian for debug:
docker run -it --pid=container:6d67de07731d --net=container:6d67de07731d --cap-add sys_admin debian
I can see the nginx process:
@nma
nma / windowsize.js
Created February 22, 2017 21:31
ReactJS get window sizes
constructor(props) {
super(props);
this.state = { height: 512 };
this.updateWindowDimensions = this.updateWindowDimensions.bind(this);
}
componentDidMount() {
this.updateWindowDimensions();
window.addEventListener("resize", this.updateWindowDimensions.bind(this));
}
@nma
nma / combinations_recursive.py
Last active August 26, 2020 03:56
Combinations Recursive
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
nums = list(range(1, n + 1))
combinations = []
def combine_helper(ans: List[int], path: List[int], options: List[int], count: int):
if count == 0:
ans.append(path)
else:
@nma
nma / permutations_recursive.py
Last active August 26, 2020 04:00
Permutations Recusive
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
result = []
def permute_helper(ans: List[int], cur: List[int], options: List[int]):
if len(options) == 0:
ans.append(cur)
else:
for index, choice in enumerate(options):
@nma
nma / combinations_backtracking.py
Last active April 5, 2019 04:37
Combinations Backtracking
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
nums = list(range(1, n + 1))
combinations = []
def backtracking(results, path, depth, options):
if depth == 0:
results.append(path[:])
else:
@nma
nma / permutations_backtracking.py
Created April 6, 2019 04:14
Permutations Backtracking
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
result = []
def backtracking(permutations, path, options):
if len(path) == len(options):
permutations.append(path[:])
else:
for option in options: