Skip to content

Instantly share code, notes, and snippets.

View pangyuteng's full-sized avatar

pangyuteng

View GitHub Profile
@jagregory
jagregory / gist:710671
Created November 22, 2010 21:01
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@cournape
cournape / gist:1077528
Created July 12, 2011 07:00
cython c++ example
# rectangle.pyx
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@edrex
edrex / ssh-auto
Last active May 8, 2020 05:47
SSH Auto
#!/bin/sh
# Auto-reconnect ssh screen session after sleep + wifi network change
# usage: ssh-auto user@server
# With these setting SSH will detect a dropped connection after 30 seconds.
# Script will attempt to reconnect every 5 seconds whenever connection is dropped.
# Use Ctrl-C to exit the reconnect loop.
# choose your remote session manager
# ON_CONNECT_CMD='screen -DR'
ON_CONNECT_CMD='tmux -2 attach || tmux -2 new'
@tott
tott / gist:3895832
Created October 15, 2012 21:57
create cpu load in python
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
@certik
certik / compile_run.sh
Last active February 23, 2023 22:50
Test offscreen rendering with VTK 6
#! /bin/bash
set -e
g++ -o test_offscreen.o -c test_offscreen.cpp -I$PYTHONHPC/include/vtk-6.0
g++ -o test_offscreen test_offscreen.o $PYTHONHPC/lib/libvtk*.so
LD_LIBRARY_PATH=$PYTHONHPC/lib/ ./test_offscreen
@bkdinoop
bkdinoop / login-example
Last active May 21, 2024 06:25
Flask-Login : login.py created by https://github.com/maxcountryman : Matthew Frazier
# -*- coding: utf-8 -*-
"""
Flask-Login example
===================
This is a small application that provides a trivial demonstration of
Flask-Login, including remember me functionality.
:copyright: (C) 2011 by Matthew Frazier.
:license: MIT/X11, see LICENSE for more details.
"""
@pfote
pfote / AsyncNotify.py
Created December 5, 2013 12:39
postgres LISTEN/NOTIFY psycopg2/twisted
import psycopg2
import psycopg2.extensions
from select import select
from twisted.internet import threads
class AsyncNotify():
"""
based on http://divillo.com/, adapted to newer psycopg version
Class to trigger a function via PostgreSQL NOTIFY messages.
@thiagooak
thiagooak / kill-rmq-connections.sh
Created December 13, 2013 12:11
kill ALL rabbitmq connections
rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "/bin/bash" }'