Skip to content

Instantly share code, notes, and snippets.

@DSDev-NickHogle
DSDev-NickHogle / rsync_connect.c
Created June 19, 2012 19:31
Rsync HTTP Proxy
static int establish_proxy_connection(int fd, char *host, int port,
char *proxy_user, char *proxy_pass)
{
char *cp, buffer[1024];
char *authhdr, authbuf[1024];
int len;
if (proxy_user && proxy_pass) {
stringjoin(buffer, sizeof buffer,
proxy_user, ":", proxy_pass, NULL);
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@jordelver
jordelver / gist:3139365
Created July 18, 2012 22:29
How to write an image file to an SD card under Mac OS X (for Raspberry Pi)

Find the SD card device

In this case, the SD card is /dev/disk4. DO NOT get this wrong or you may destroy all the data on the wrong disk/card/drive.

diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0

1: EFI 209.7 MB disk0s1

@taldanzig
taldanzig / osxvpnrouting.markdown
Created January 24, 2013 22:14
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

@econchick
econchick / gist:4666413
Last active December 22, 2023 13:32
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
@mrjoes
mrjoes / ckedit.py
Created March 18, 2013 19:04
Flask-Admin and CKEditor WYSIWYG textarea integration. Basically, all you have to do: 1. Create new wtforms widget which will emit 'ckeditor' class 2. Make new wtforms field which will use this widget 3. Create new jinja2 template, which includes ckeditor javascript 4. Tell flask-admin to use new field and new template
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext import admin, wtf
from flask.ext.admin.contrib import sqlamodel
app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite'
db = SQLAlchemy(app)
@plentz
plentz / nginx.conf
Last active July 22, 2024 11:19
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@hanfeisun
hanfeisun / crack_xx.sh
Last active December 27, 2015 15:49 — forked from anonymous/gist:7350812
#!/bin/bash
sudo date 03050001
# Replace the following line with any application you need to run
open /Applications/Merriam-Webster\ 4.0/Merriam-Webster\ Dictionary.app
# sleep 60
# Set back to the current time using apple service (network needed)
sudo ntpdate -u time.apple.com
@hehongwei44
hehongwei44 / parseURL.js
Created June 30, 2014 07:26
js通过a标签解析url
/*
* @function: 通过a标签解析url标签
* @param:url url参数是字符串,解析的目标
通过IE6-9 chrome Firefox测试
*
*/
function parseURL(url) {
//创建一个a标签
var a = document.createElement('a');
@hehongwei44
hehongwei44 / eventUtil.js
Last active August 29, 2015 14:04
阻止事件冒泡和默认行为的通用函数
/**
* 阻止事件冒泡的通用函数
* */
function stopBubble(e) {
if (e && e.stopPropagation) {
e.stopPropagation();
} else {
window.event.cancelBubble = true;
}
}