Skip to content

Instantly share code, notes, and snippets.

View mike1e's full-sized avatar

Michael Le mike1e

View GitHub Profile
@mike1e
mike1e / Sublime Text 2 User Preferences
Last active December 18, 2015 10:49
Sublime Text User Preferences
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 15.0,
"font_face": "Inconsolata",
"ignored_packages":[],
"rulers":[80],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"vintage_start_in_command_mode": true,
@mike1e
mike1e / .vimrc
Last active December 19, 2015 12:29
vim
""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""
" Set to auto read when file is changed from outside
set autoread
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugins
@mike1e
mike1e / secret_key
Created November 22, 2013 23:42
create secret key
python -c "import os; print repr(os.urandom(24))"
@mike1e
mike1e / gist:7610855
Created November 23, 2013 04:34
Jinja2 / Bootstrap Navigation Active Page highlighting
<ul class="nav nav-pills pull-right">
{%- for endpoint, caption in [
('index', 'Index'),
('add_user', 'Add User')
] %}
<li{% if endpoint == request.endpoint %} class="active"{% endif %}>
<a href={{ url_for(endpoint) }}>{{ caption }}</a>
</li>
{%- endfor %}
</ul>
@mike1e
mike1e / venv_folder
Last active December 29, 2015 05:09
switch folders with virtualenv
# In the postmkvirtualenv script I have the following to create a directory based on the project name,
# add that directory to the python path and then cd into it:
proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}')
mkdir $HOME/projects/$proj_name
add2virtualenv $HOME/projects/$proj_name
cd $HOME/projects/$proj_name
# In the postactivate script I have it set to automatically change to the project
# directory when I use the workon command:
@mike1e
mike1e / flask_auth.py
Last active January 3, 2016 14:59
Flask authorization
def login_required(role="ANY"):
def wrapper(fn):
@wraps(fn)
def decorated_view(*args, **kwargs):
if not current_user.is_authenticated():
return current_app.login_manager.unauthorized()
urole = current_user.get_role()
if ( (urole != role) and (role != "ANY")):
#!/bin/bash
scalesvg ()
{
svgfile="$1"
pngdir="$2"
pngscale="$3"
qualifier="$4"
svgwidthxheight=$(identify "$svgfile" | cut -d ' ' -f 3)
@mike1e
mike1e / gist:f407230551a4ba8cd0bf
Created October 23, 2015 22:35
gchrome to safari
tell application "Google Chrome"
set pageUrl to get URL of active tab of first window
end tell
tell application "Safari" to add reading list item pageUrl
@mike1e
mike1e / gulpfile.js
Created January 26, 2016 06:43
michael1e.com | Static site generator tutorial
var gulp = require('gulp');
var browserSync = require('browser-sync');
gulp.task('serve', function() {
browserSync({
server: {
baseDir: 'app' // Change this to your web root dir
}
});
});
@mike1e
mike1e / index.html
Created January 26, 2016 06:54
michael1e.com | Static site generator tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->