Skip to content

Instantly share code, notes, and snippets.

Skylar Saveland skyl

View GitHub Profile
@crgimenes
crgimenes / stringToReaderCloser.go
Last active May 24, 2020
string to io.ReadCloser
View stringToReaderCloser.go
package main
import (
"bytes"
"fmt"
"io/ioutil"
)
func main() {
r := ioutil.NopCloser(bytes.NewReader([]byte("hello world"))) // r type is io.ReadCloser
@jashkenas
jashkenas / semantic-pedantic.md
Last active Jul 19, 2020
Why Semantic Versioning Isn't
View semantic-pedantic.md

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@pydanny
pydanny / wtf
Created Jul 31, 2013
South 0.8.1, Django 1.6b2, Python 3.3.2. Occurs in PostgreSQL and SQLite3
View wtf
Running migrations for socialaccount:
- Migrating forwards to 0011_auto__chg_field_socialtoken_token.
> socialaccount:0001_initial
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/danielgreenfeld/.envs/cheesely_project/lib/python3.3/site-packages/django/core/management/__init__.py", line 397, in execute_from_command_line
utility.execute()
File "/Users/danielgreenfeld/.envs/cheesely_project/lib/python3.3/site-packages/django/core/management/__init__.py", line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
@iamatypeofwalrus
iamatypeofwalrus / roll_ipython_in_aws.md
Last active Mar 9, 2020
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.
View roll_ipython_in_aws.md

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@kayzhu
kayzhu / csrf.js
Last active Sep 27, 2016
Send POST request in Angular.js to a CSRF-protected Django view
View csrf.js
<script type="text/javascript" src="/angular/angular.js"></script>
<script type="text/javascript" src="/angular/angular-cookies.min.js"></script>
// app.js
// inject ngCookies to your app named 'myApp'.
angular.module('myApp', ['ngCookies']);
// controller.js
function MyCtrl($scope, $http, $cookies) {
@jeremyjbowers
jeremyjbowers / my_app.conf
Created Dec 31, 2012
This is an upstart configuration file to execute uWSGI as a daemon on Ubuntu-recent (10.x, 12.x). For more info on upstart: http://upstart.ubuntu.com/getting-started.html. This file would live in /etc/init/ and you'd need to do sudo initctl reload-configuration on the initial file creation and then sudo service my_app start/restart/stop to contr…
View my_app.conf
description "uWSGI server for electris CMS"
start on runlevel [2345] # start on all runlevels.
stop on runlevel [!2345] # stop when shutting down.
respawn # respawn if job crashes or is stopped ungracefully.
env DEPLOYMENT_TARGET=production # set any environment variables you like here.
env DJANGO_SETTINGS_FILE=conf/settings.py # more environment variables if you like.
env PYTHONPATH=/home/ubuntu/apps/my_app:/home/ubuntu/.virtualenv/my_app
@guillaumepiot
guillaumepiot / gist:3939452
Created Oct 23, 2012
ANGULARJS - Django CSRF Token header setup
View gist:3939452
var myApp = angular.module('myApp').config(function($httpProvider) {
$httpProvider.defaults.headers.post['X-CSRFToken'] = $('input[name=csrfmiddlewaretoken]').val();
});
@moklett
moklett / openconnect.md
Created Jul 24, 2012
OpenConnect VPN on Mac OS X
View openconnect.md

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
     brew install openconnect
    
@evildmp
evildmp / gist:3094281
Last active May 2, 2020
Set up Django, nginx and uwsgi
View gist:3094281

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:

@jezdez
jezdez / pip.conf
Created Mar 10, 2010
My ~/.pip/pip.conf. More information here: http://pip.openplans.org/configuration.html
View pip.conf
[global]
default-timeout = 60
respect-virtualenv = true
download-cache = ~/.pip/cache
log-file = ~/.pip/pip.log
build = ~/.pip/build
[install]
use-mirrors = true
You can’t perform that action at this time.