Skip to content

Instantly share code, notes, and snippets.

@fengzhimei
fengzhimei / github-to-bitbucket
Created July 4, 2017 07:45 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
Go to Bitbucket and create a new repository (its better to have an empty repo)
git clone git@bitbucket.org:abc/myforkedrepo.git
cd myforkedrepo
Now add Github repo as a new remote in Bitbucket called "sync"
git remote add sync git@github.com:def/originalrepo.git
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync"
git remote -v
@fengzhimei
fengzhimei / tmux.md
Last active April 1, 2017 03:26
tmux cheat sheet copied from https://github.com/der-flo/tmux_cheatsheet. https://www.tmuxcheatsheet.com is a good reference as well.

tmux cheatsheet

Based on tmux: Productive Mouse-Free Development (The Pragmatic Progammers - Brian P. Hogan).

Shell command Description
tmux new-session -s sessionname
tmux new -s sessionname
Create a named session called sessionname
tmux new -s sessionname -d top Create detached session and run top inside
tmux new -s sessionname -n win Create session sessionname with window win
tmux list-sessions tmux ls
@fengzhimei
fengzhimei / edx-dl.py
Created April 1, 2017 03:06 — forked from xitij2000/edx-dl.py
A script to download videos from EdX using aria2 and automatically putting them in a clean folder hierarchy.
# A script that can automatically download videos from Edx
# Currently this is heavily tied to the way my Edx account and my computer is
# set up. It downloads by sending the the download url and download directory
# to aria2 runnig in rpc mode.
# More info here: http://aria2.sourceforge.net/manual/en/html/aria2c.html#rpc-interface
# You can use http://ziahamza.github.io/webui-aria2/ to see download progress
# For now parameters, such as username, password, and which course to download
# can be provided in the script
# I intend to make it more flexible
from __future__ import print_function
@fengzhimei
fengzhimei / grab-sessionid.py
Created April 1, 2017 03:05 — forked from cgoldberg/grab-sessionid.py
grab session id from edX cookie
def login(email, password, base_url='https://courses.edx.org'):
"""Login via HTTP and parse sessionid from the cookie."""
r = requests.get('{}/login'.format(base_url))
csrf = r.cookies['csrftoken']
payload = {'email': email, 'password': password}
cookies = {'csrftoken': csrf}
headers = {'referer': '{}/login'.format(base_url), 'X-CSRFToken': csrf}
r = requests.post('{}/user_api/v1/account/login_session/'.format(base_url),
data=payload, cookies=cookies, headers=headers)
try:
@fengzhimei
fengzhimei / 00.howto_install_phantomjs.md
Last active April 1, 2017 02:59 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 2.1.1

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@fengzhimei
fengzhimei / pfsense-backup.sh
Created January 4, 2017 07:37 — forked from peelman/pfsense-backup.sh
Backup pfSense firewalls remotely
#!/bin/sh
#
######################################################################################################
#
# Description:
# Backup pfSense 2.3 Firewalls to Local Disk
#
######################################################################################################
#
# Author: Nick Peelman