Skip to content

Instantly share code, notes, and snippets.

@scupython
scupython / go_scp.go
Created February 27, 2014 02:04 — forked from jedy/go_scp.go
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"code.google.com/p/go.crypto/ssh"
"crypto"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
#!/usr/bin/python
__author__ = 'shelbydz'
import json
import requests
import pickle
import smtplib
import time
import datetime
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@scupython
scupython / index.html
Created August 14, 2013 07:07 — forked from enjalot/index.html
d3 pie example understoodable
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<style type="text/css">
@app.route('/users/<username>', methods = ['GET', 'POST', 'PATCH', 'DELETE'])
@requires_auth
def api_user(username):
current_user = User.get(request.authorization.username)
app.logger.debug("req.auth.username = %s", request.authorization.username)
# Only "SELF" can access/modify user info
if current_user.username != username:
return unauthorized()
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@scupython
scupython / decorators.py
Created November 23, 2012 05:02 — forked from jsocol/decorators.py
A better @permission_required decorator for Django
try:
from functools import wraps
except ImportError:
from django.utls.functional import wraps
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.template import loader, RequestContext, TemplateDoesNotExist
from django.utils.decorators import available_attrs