Skip to content

Instantly share code, notes, and snippets.

@mylesjao
mylesjao / gist:154a75ce8e0386785f44
Created January 19, 2016 17:48 — forked from bradfrost/gist:59096a855281c433adc1
Why I'm Not A JavaScript Developer

Answering the Front-end developer JavaScript interview questions to the best of my ability.

  • Explain event delegation

Sometimes you need to delegate events to things.

  • Explain how this works in JavaScript

This references the object or "thing" defined elsewhere. It's like "hey, thing I defined elsewhere, I'm talkin' to you."

  • Explain how prototypal inheritance works.
@mylesjao
mylesjao / svnignore
Created April 29, 2015 04:16
set svn ignore from file (ex. .svnignore)
svn propset svn:ignore -F .svnignore .
@mylesjao
mylesjao / nginx.conf
Created March 9, 2015 06:50
nginx force download
# attachment directory
location /attachment/ {
alias /tmp/attachment/;
types { }
default_type application/octet-stream;
if ($request_filename ~ "^.*/(.+\.png|jpg|gif)$"){
set $fname $1;
add_header Content-Disposition 'attachment; filename="$fname"';
@mylesjao
mylesjao / docker-clean.sh
Created January 27, 2015 05:35
clean docker container weeks ago
docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm
@mylesjao
mylesjao / bash-completion
Created January 22, 2015 08:22
bash-completion on mac
brew install bash-completion
# add below in .bash_profile
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
@mylesjao
mylesjao / WebConfig.java
Last active August 29, 2015 14:11
enable spring matrix variable support
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
// enable matrix variable support
if (configurer.getUrlPathHelper() == null) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setRemoveSemicolonContent(false);
configurer.setUrlPathHelper(urlPathHelper);
@mylesjao
mylesjao / vlc.html
Last active July 28, 2019 02:05
vlc web plugin sample. only for IE and Firefox
<!DOCTYPE html>
<html>
<body>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<object
@mylesjao
mylesjao / node_global.sh
Created June 18, 2014 12:43
Changing the global node version of nvm used
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
@mylesjao
mylesjao / show-git-branch.sh
Created June 6, 2014 02:54
show current git branch in shell
#show current git branch in shell
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\[\033[0m\]$ "
@mylesjao
mylesjao / app-init.sh
Last active August 29, 2015 14:01
get script file path and set to APP_HOME environment variable
#!/bin/bash
SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
# assume this script is in APP_HOME/bin directory
cd $SCRIPT_DIR/..
APP_HOME="`pwd -P`"