Skip to content

Instantly share code, notes, and snippets.

View buddylindsey's full-sized avatar
🚜
Homesteading

Buddy Lindsey, Jr. buddylindsey

🚜
Homesteading
View GitHub Profile
@buddylindsey
buddylindsey / awsup.py
Created April 8, 2014 19:29
Automated Postgres Backup
import sys
import boto
from boto.s3.connection import S3Connection
from boto.s3.key import Key
file_name = sys.argv[1]
AWSAccessKeyId = ''
AWSSecretKey = ''
@buddylindsey
buddylindsey / gist:b51fbcd0f2221590cfd8
Created April 29, 2014 20:28
Install a specific version of salt-minion
wget --no-check-certificate -O - http://bootstrap.saltstack.org | sudo sh -s -- git v0.17.0
@buddylindsey
buddylindsey / shutdown.bash
Created May 9, 2014 15:14
Shutdown all lxc's
#!/bin/bash
for f in `ls -d *`; do
lxc-shutdown -n $f
done
@buddylindsey
buddylindsey / gist:73d080b9ccbc0939fc0d
Created July 17, 2014 13:51
start tmux environment
SESSION=$USER
tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
sleep 1
tmux attach -t $SESSION
exit 0;
fi
class Task(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField()
body = models.TextField()
git checkout master
git fetch ca master
git rebase ca/master
# create a new branch
git checkout -b my-new-branch
# push changes
git push origin my-new-branch
@buddylindsey
buddylindsey / gist:095d6e9775d6a6d0b53d
Created May 20, 2015 00:12
User Profile with `DetailView`
url(r'^users/(?P<username>[-\w]+)/$', UserProfile.as_view(), name="userprofile"),
class UserProfile(generic.DetailView):
model = User
template_name = 'accounts/profile.html'
slug_field = 'username' # Should be field name for query in `get_object` queryset
slug_url_kwarg = 'username' # Should be actual data fro the URL username kwarg
# Will work just fine because code executes when calling the view
# so there is something for reverse to create a url from
def view(request):
url = reverse('index')
return HttpResponse()
# Works well because when python parses this reverse_lazy just stores
# the name instead of trying to execute code so it works just fine
class ObjectCreateView(CreateView):
class Signal(object):
def init(self):
self.receivers = []
def output(self):
print self.receivers
def connect(self, receiver):
self.receivers.append(receiver)
class MainController < NSWindowController
def awakeFromNib
end
def newWindow(sender)
someData = "Blob"
nw = MainWindowController.alloc.init