Skip to content

Instantly share code, notes, and snippets.

View garywu's full-sized avatar
🌴
On vacation

Gary Wu garywu

🌴
On vacation
View GitHub Profile
@garywu
garywu / ipython_0.13.2_windows_line_profiler.md
Last active February 21, 2018 00:58
How to fix ipython 0.13.2 runtime Error on Windows: ImportError: No module named line_profiler

How to fix: ImportError: No module named line_profiler when running ipython 0.13.2 on Windows

  1. install Line_profiler from http://www.lfd.uci.edu/~gohlke/pythonlibs/
  2. This should install following files in your python27/Lib/site-packages directory
    • _line_profiler.pyd
    • line_profiler-1.0b3-py2.7-win32.egg
    • line_profiler-1.0b3-py2.7.egg-info
    • line_profiler.py
    • line_profiler.pyc
  • line_profiler.pyo

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
// Chrome extension 'content scripts' run in a sandboxed 'isolated world'
// (http://code.google.com/chrome/extensions/content_scripts.html#execution-environment).
// However, there are ways to get out and execute js code in the page
// context. Google searching revealed the following ways:
////////////////////////////////////////////////////////////////////////////////
// http://blog.afterthedeadline.com/2010/05/14/how-to-jump-through-hoops-and-make-a-chrome-extension/
// it looks like jQuery must be loaded by the content-script
jQuery('body').append('<script type="text/javascript">(function(l) {
var res = document.createElement('SCRIPT');
@garywu
garywu / 0_reuse_code.js
Created January 11, 2014 18:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@garywu
garywu / gist:8c84dbb9e16b0f2967fd
Last active August 29, 2015 14:04
Indepensible Open Source Softwares
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
<?php
function cidr_match($ip, $ranges)
{
$ranges = (array)$ranges;
foreach($ranges as $range) {
list($subnet, $mask) = explode('/', $range);
if((ip2long($ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) {
return true;
}
}
@garywu
garywu / Keepass multi database
Last active July 29, 2023 18:40
Easy way to securely manage/open multiple keepass database files
1. Create an entry in your personal database with the Password for the shared database
2. On the advanced tab create a field named "DbPath" and with the value of where the shared database is located. If multiple users are sharing the same keepass database you can use environment variable as part of the path for example: %HOMEPATH%/secret.kdbx.
3. Set the Url value to: cmd://"{APPDIR}\KeePass.exe" "{s:DbPath}" -pw:{PASSWORD}
4. Now, when you want to open the shared database, mark the entry and press CTRL + U.
@garywu
garywu / requirements.txt
Created September 29, 2015 06:33
Snippet:Python
pip install -e git+ssh://git@bitbucket.org/corp_name/repo_namename.git#egg=repo_name