Skip to content

Instantly share code, notes, and snippets.

@bq1990
bq1990 / gist:3655dee62c4d97bb619fd8433f986f86
Created January 19, 2018 21:06
list octal permissions
stat -c "%a %n"
strace -ff -p <process id>
@bq1990
bq1990 / forms.py
Created December 27, 2017 20:58 — forked from maraujop/forms.py
django-crispy-forms bootstrap form example
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
@bq1990
bq1990 / ssltest.sh
Created December 27, 2017 17:24
SSL testing
#test tls support
openssl s_client -connect google.com:443 -tls1
openssl s_client -connect google.com:443 -tls1_1
#list cipers
nmap --script ssl-enum-ciphers -p 443 google.com
@bq1990
bq1990 / copyssh
Last active November 30, 2017 00:26
cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys && echo "Key copied"'
dobs = User.objects.values('date_of_birth') \
.annotate(count=Count('date_of_birth', distinct=True)).all()
@bq1990
bq1990 / nested.py
Created March 16, 2017 21:56
nested list comp
[u for s in self.sites for u in s.units]
import boto
s3 = boto.connect_s3('<your access key>', '<your secret key>')
bucket = s3.get_bucket('<your bucket>') # does this work?
s3 = boto.connect_s3()
s3.aws_access_key_id # is the same key being used by default?
key = bucket.new_key('testkey')
key.set_contents_from_string('This is a test')
@bq1990
bq1990 / plotCircle.js
Created November 18, 2016 02:11
Plot a circle
function plotCircle(points, radius, x0, y0) {
coords = [];
var slice = 2 * Math.PI / points; //calculate the slice of the pie
for(var i = 0; i < points; i++) {
var angle = slice * i;
var x = x0 + radius * Math.cos(angle);
var y = y0 + radius * Math.sin(angle);
coords.push({x: x, y: y});
@bq1990
bq1990 / gist:e4518e20d17c5abd3b10925451f3a616
Created July 3, 2016 21:03
Postgres import dump file into database
pg_restore -O -d dbname dumpfile