Consider the following code
def do_some_stuff(x)
try:
val = f(x)
except NameError, e:
val = False
return va;
function A = generate_a( N ) | |
% Generates matrix A | |
% N: Integer of size of mesh | |
n = N-1; | |
meshsize = n*n; | |
% Build matrix D | |
D_block = triu(tril(ones(n), 1), -1) - 5*eye(n); | |
D_repeat = repmat({D_block}, n, 1); | |
D_matrix = blkdiag(D_repeat{:}); |
/*! | |
* Description: | |
* Fill variable child containers to 100% width | |
* http://stackoverflow.com/a/5862782 | |
*/ | |
.control-container { | |
width: 100%; | |
display: table; | |
table-layout: fixed; |
################################################################ | |
# BASICS: LAMBDA VS LIST COMPREHENSION | |
################################################################ | |
# Filter | |
filter(lambda x: x % 2, range(10)) | |
[x for x in range(10) if x % 2] | |
# Map | |
map(lambda x: x*x, range(10)) |
// Fix pixelated images and svg by removing this line. | |
svg, | |
img { | |
image-rendering: -webkit-optimize-contrast; | |
} | |
// Spinning React logo | |
.App-logo { | |
animation: App-logo-spin infinite 20s linear; | |
height: 80px; |
You can serve your project websites for free on GitHub Pages.
Normally, I use gulp to generate a minified and concatenated build inside the build/
directory,
and then use git subtree
to push only the build/
directory to the gh-pages branch (without needing
to push the build to master).
git subtree push --prefix build origin gh-pages
# Check which process is using a port. | |
lsof -i tcp:57454 | |
# Bash scrict mode. | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Exit script if you try to use an uninitialized variable. |
/************************************************************************ | |
* CLIENT ONE-LINERS | |
*************************************************************************/ | |
// Set top level domain cookie. | |
document.cookie = "token=12345; Max-Age=120; Secure; Domain=mozilla.org; Path=/;" | |
// Set a subdomain cookie. | |
document.cookie = "name=hello world; Max-Age=120; Secure; Domain=developer.mozilla.org; Path=/;" |
# http:#eslint.org/docs/rules/ | |
ecmaFeatures: | |
binaryLiterals: false # enable binary literals | |
blockBindings: false # enable let and const (aka block bindings) | |
defaultParams: false # enable default function parameters | |
forOf: false # enable for-of loops | |
generators: false # enable generators | |
objectLiteralComputedProperties: false # enable computed object literal property names | |
objectLiteralDuplicateProperties: false # enable duplicate object literal properties in strict mode | |
objectLiteralShorthandMethods: false # enable object literal shorthand methods |