Skip to content

Instantly share code, notes, and snippets.

@oconnor663
oconnor663 / gist:8142166
Created December 27, 2013 03:17
Cracking a password with a known structure.
import random
import string
import itertools
def random_capitalize(start):
out = ''
for char in start:
out += char.upper() if random.randrange(2) else char.lower()
return out
@oconnor663
oconnor663 / gist:8483257
Created January 17, 2014 22:59
stacktrace for fbmessenger QtWebKit crash
Program received signal SIGSEGV, Segmentation fault.
0x00007fff70176293 in ?? ()
(gdb) bt
#0 0x00007fff70176293 in ?? ()
#1 0x00007fffb5325700 in ?? ()
#2 0x00007fff4a9666c0 in ?? ()
#3 0x00007fff6d6713c0 in ?? ()
#4 0x00007fff558c3c38 in ?? ()
#5 0x00007fff700dcb37 in ?? ()
#6 0x00007fff6c771a80 in ?? ()
@oconnor663
oconnor663 / gist:8922568
Created February 10, 2014 19:32
Jack's solution to the sum of consecutive primes problem
#! /usr/bin/env python3
import sys
upper_bound = 1000000
# Optionally take the upper bound from the command line.
if len(sys.argv) > 1:
upper_bound = int(sys.argv[1])
# Computes the list of all primes using Sundaram's Sieve. This is a *lot*
@oconnor663
oconnor663 / gist:9010980
Last active September 6, 2015 02:50
First Python problem set: if and while

If you already have a Python environment already set up that you're comfortable with, great. If not, I recommend downloading Python 3 from http://www.python.org/download/. It comes with a program called IDLE that helps you write small programs and run them. YouTube has some good videos for getting started with that, depending on whether you're running Windows, Mac, or Linux.

Here's the Python book I like to use to get started: http://openbookproject.net/thinkcs/python/english3e/

To do the problems below, you'll need to be roughly familiar with chapters 1-8 in that book, particularly chapters 5, 7, and 8. If you're starting from scratch, it might be a good idea to try the exercises in those chapters as you go along. When you're up to speed, you'll have the following basic building blocks for your programs:

  • how to print output
  • how to create variables and change their values
  • how to use if statements to make choices
  • how to use while loops to do repeated work
@oconnor663
oconnor663 / gist:9077080
Created February 18, 2014 18:41
gdb stacktrace of QtWebKit crash
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python3.3...Reading symbols from /usr/lib/debug/usr/bin/python3.3...done.
@oconnor663
oconnor663 / gist:fffb0f2fcd7ca472b589
Created July 22, 2014 07:18
Buggy sync output for Sean's dotfiles
git clone https://github.com/seebi/dircolors-solarized
git checkout https://github.com/seebi/dircolors-solarized
git clone https://github.com/altercation/vim-colors-solarized.git
git checkout https://github.com/altercation/vim-colors-solarized.git
git clone https://github.com/kien/ctrlp.vim.git
git checkout https://github.com/kien/ctrlp.vim.git
git clone https://github.com/tpope/vim-fugitive.git
git checkout https://github.com/tpope/vim-fugitive.git
git clone https://github.com/scrooloose/nerdtree.git
git checkout https://github.com/scrooloose/nerdtree.git
@oconnor663
oconnor663 / gist:958b41d45ab781c9e1b8
Last active August 29, 2015 14:10
a bug in GitHub's markdown rendering
  1. This is some text.

  2. This is some text.

  3. This example has more space around it than it really should

    code code code
    

    because it has code in it.

  4. This is some text.

@oconnor663
oconnor663 / keybase.md
Created December 21, 2014 23:40
keybase.md

Keybase proof

I hereby claim:

  • I am oconnor663 on github.
  • I am oconnor663 (https://keybase.io/oconnor663) on keybase.
  • I have a public key whose fingerprint is 58A2 45D3 D8B2 5C15 F6CE 3FFF 7187 6B68 AD48 2D32

To claim this, I am signing this object:

@oconnor663
oconnor663 / gist:eb90a4100385d6f29ddb
Created March 4, 2015 15:52
Exercise the daemon RPC
rpc = require 'framed-msgpack-rpc'
assert = require 'assert'
x = rpc.createTransport { path: '/run/user/1000/keybased.sock' }
await x.connect defer err
if err
console.log "error connecting"
else
c = new rpc.Client x, "keybase.1"
await c.invoke 'config.getCurrentStatus', [{}], defer err, response

EDIT from 2019: Hi folks. I wrote this gist for myself and some friends, and it seems like it's gotten posted somewhere that's generated some (ahem, heated) discussion. The whitespace was correct when it was posted, and since then GitHub changed how it formats <pre> tags. Look at the raw text if you care about this. I'm sure someone could tell me how to fix it, but (thank you @anzdaddy for suggesting a formatting workaround) honestly this is a random throwaway gist from 2015, and someone more knowledgable about this comparison should just write a proper blog post about it. If you comment here I'll hopefully see it and stick a link to it up here. Cheers. @oconnor663

Here's the canonical TOML example from the TOML README, and a YAML version of the same.

title = "TOML Example"