Skip to content

Instantly share code, notes, and snippets.

View codenameyau's full-sized avatar

Jorge Yau codenameyau

View GitHub Profile
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{:});
@codenameyau
codenameyau / auto-child-width.css
Created May 18, 2015 20:51
Autofill children width to fill parent
/*!
* Description:
* Fill variable child containers to 100% width
* http://stackoverflow.com/a/5862782
*/
.control-container {
width: 100%;
display: table;
table-layout: fixed;
@codenameyau
codenameyau / lambda_vs_list_comprehension.py
Last active June 29, 2017 15:34
Python lambda vs list comprehension
################################################################
# 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))

The Magic of Maybe

The Pattern

Consider the following code

def do_some_stuff(x)
  try:
    val = f(x)
  except NameError, e:
    val = False
  return va;
@codenameyau
codenameyau / receipe.scss
Last active January 25, 2018 21:03
CSS Recipe Book
// 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;
@codenameyau
codenameyau / deploy-gh-pages.md
Last active January 1, 2018 05:02
Deploying to GitHub Pages

Deploying to GitHub Pages

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).

First Push to GitHub Page

git subtree push --prefix build origin gh-pages
@codenameyau
codenameyau / linux-cheatsheet.sh
Last active January 6, 2024 21:56
Bash Cheatsheet
# 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.
@codenameyau
codenameyau / console-tricks.js
Last active April 6, 2022 13:07
Javascript Snippets
/************************************************************************
* 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=/;"
@codenameyau
codenameyau / elasticsearch-rest.md
Last active January 12, 2021 12:41
Elasticsearch REST Cheatsheet
@codenameyau
codenameyau / .eslintrc.yaml
Created May 9, 2016 21:56 — forked from odedw/.eslintrc.yaml
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
# 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