I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
SCRIPT="security add-trusted-cert -d -r trustAsRoot -p ssl -p basic -k /Library/Keychains/System.keychain "filename.crt"" | |
osascript -e "do shell script \"$SCRIPT\" with administrator privileges" | |
# or you can just run the above SCRIPT command with sudo directly. | |
# This osascript stuff is so that you get a native OS password prompt |
#!/usr/bin/env python | |
"""Determine if the instances in an autoscaling group are InService in its ELBs | |
attached to that group. | |
""" | |
import sys | |
import boto.ec2.elb | |
import boto.ec2.autoscale | |
import argparse |
packer build packer.json 2>&1 | sudo tee output.txt | |
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt |
# | |
# Acts as a nginx HTTPS proxy server | |
# enabling CORS only to domains matched by regex | |
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/ | |
# | |
# Based on: | |
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html | |
# * http://enable-cors.org/server_nginx.html | |
# | |
server { |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
-
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the
secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection. -
Use production SSL certificates locally. This is annoying
- If you rename a field, then your users are fucked. Convert with a hardcoded array structure.
- Most DB drivers [for PHP] will show integers as numeric strings and
false
as"0"
, so you want to typecast them. - Unless you're using an ORM with "hidden" functionality, people will see passwords, salts and all sorts of fancy codes. If you add one and forget to put it in your
$hidden
array then OOPS!
- Use the query string for paired params instead of
/users/id/5/active/true
. Your API does not need to be SEO optimised. ?format=xml
is stupid, use anAccept: application/xml
header. I added this to the CodeIgniter Rest Server once for lazy people, and now people think it's a thing. It's not.
<?php | |
/** | |
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and | |
* then use this script to apply updates and refresh the config cache without | |
* causing a stampede on the config cache. | |
* | |
* @author Colin Mollenhour | |
*/ | |
umask(0); | |
ini_set('memory_limit','512M'); |