Skip to content

Instantly share code, notes, and snippets.

@do3cc
do3cc / gist:5611777
Created May 20, 2013 11:45
This is a template one can use to create notifications for each repo, one ever committed to on github
# In this example, I chose to look into the organizations collective and plone only. Adjust to your needs, don't forget to add yourself, if you want to watch yourself.
# Pagination count is based on the number of repos in collective, which is 919.
# Get all repos from a project
for ORG in collective plone
do
for PAGE in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
do
curl -u $YOURUSER:$YOURPASS -i https://api.github.com/users/$ORG/repos\?page\=$PAGE >> repos
done
@do3cc
do3cc / gist:5805562
Created June 18, 2013 13:56
Ordering imports or other things in vim can be done with !sort If you have some proper locales set, sort always sorts case insensitive and there is no flag to tell him to stop that. You can, however, run sort with a different locale. Doing so from vim is a bit much to type though, therefor, add the alias below
# Works in bash AND zsh
alias sort="LC_ALL=C sort"
@do3cc
do3cc / gist:11041989
Created April 18, 2014 12:38
Simple way to generate ssl certs without interactive questions
# When having multiple vhosts, and one of them listens to https,
# nginx will answer ssl requests for all of your vhosts, but with data
# from that one host that answers ssl. The browser will complain
# that the certificate is for the wrong site and you will receive
# the wrong site.
# With this simple self signed certificate, the user gets a warning
# for the untrusted certificate but at least gets the right site.
openssl req -x509 -newkey rsa:2048 -keyout lala.key -out lala.crt -days 3650 -nodes -subj "/C=de/CN=www.example.com"
@do3cc
do3cc / gist:1179ebaa8de24247eb75
Created May 13, 2014 14:12
Repair CMFEditions quick and dirty
from Products.CMFEditions.ZVCStorageTool import Removed
zvc_repo = app.Plone2.portal_historiesstorage.zvc_repo
for shadow_history in app.Plone2.portal_historiesstorage._shadowStorage._storage.values():
for version in shadow_history._full.values():
if not 'referenced_data' in version:
continue
vc_info = version['vc_info']
zope_version = zvc_repo._histories[vc_info.history_id]._versions[vc_info.version_id]
if isinstance(Removed, zope_version._data._object):
del version['referenced_data']
@do3cc
do3cc / keybase.md
Last active August 29, 2015 14:09
keybase.md

-----BEGIN PGP MESSAGE----- Version: GnuPG v1

owF1kntQVFUcxxdIC6YSSCGQBG9jCax43w9kTBSE1BwjKgJqueeec5crsrvsA0ME RSWjUEHEEYQyaJxBHhaKCD7YQYYI0oApiKFleqKGQ2NI43OmexmaqJnOX+fx+X3P 93t+p+QpD52721BuSemdu492uvXdBLpE55ghFwNmmINF5mLSNgWZ7NrMJGYiLBLL QDlAtKEIxRxiMkMUsdUWMsvosWxktSlmk0rhEVwEheXpNVwrlhWTEVktVkXTwmQA GZoQJZIVRU4CJA1ljgC0RNKCQMgsLgoMwbI0oUqmm232f92KzWgaFKjuzvDrWTz6 H94xc4AIQWAgK0GZ4WiewYFE8TwhCwQnQZrDcQ20IetsJGimJEkzm4msGduQwWo2 zySW7Ip2TtAkIZCMQNCqHdGWrlZINJAEjqBknuQBLxJAEBEHKBxKnESKEEesBBBP

@do3cc
do3cc / gist:520c9b0b03466f2bf469
Created April 8, 2015 21:10
virtualenvwrapper init
#!/bin/bash
# Initialize a directory as a project
# This is script is meant as a companion for users who have a tool like
# checkoutmanager and work with virtualenvwrapper
# It also checks for starzel specific buildout conventions, but works for
# normal buildouts too
# This script is dangerous, it will delete the directory from which it gets
# executed and has no safeguard against it.
<browser:page
for="*"
name="SecSigner.jar"
permission="zope2.View"
allowed_attributes="HEAD"
class=".applet.Applet1"
layer="blabla.signit.interfaces.IKboSignitLayer"
/>
class Applet(BrowserView):
@do3cc
do3cc / lala.py
Last active November 25, 2015 13:56
Hacky script to try to repair your database after problems with interfaces and the relation catalog
# It was hard to figure out, it might now be appropriate to use in your case.
# If you are not feeling comfortable to work on your database like this,
# don't run this gist.
from BTrees.OIBTree import OITreeSet
from ZODB.broken import Broken
from zc.relation.interfaces import ICatalog
from zope.component import getUtility
import transaction
@do3cc
do3cc / gist:4de070dfa15e945a21ea4e54c6247790
Last active April 14, 2016 14:46
How to run isort only for specific projects
# ~/.vimrc
" Allow project specific vimrc files
set exrc
set secure " Prevent potentially malicious vimrc files from breaking stuff
" Isort
function! Isort()
let cursor_pos = getpos('.')
%!isort -
call setpos('.', cursor_pos)
if request.META['HTTP_ACCEPT'].startswith('text/html'):
return HttpResponseRedirect(self.login_url)
else:
# You are not human after all and can handle 401 better
# https://www.youtube.com/watch?v=PXYeARRyDWk
return HTTPResponse(status_code=status.HTTP_401_UNAUTHORIZED)