Skip to content

Instantly share code, notes, and snippets.

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@xufuou
xufuou / windows_privesc
Created February 27, 2019 20:38 — forked from sckalath/windows_privesc
Windows Privilege Escalation
// What system are we connected to?
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
// Get the hostname and username (if available)
hostname
echo %username%
// Get users
net users
net user [username]
https://www.digitalocean.com/community/tutorials/how-to-configure-devise-and-omniauth-for-your-rails-application
add to Gemfile
gem 'therubyracer'
gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-google'
bundle install
@xufuou
xufuou / Setting RoR and postgres
Last active November 8, 2017 11:05
Playing with Ruby on Rails
https://www.digitalocean.com/community/tutorials/how-to-setup-ruby-on-rails-with-postgres
#install rvm with rails
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -L https://get.rvm.io | bash -s stable --rails
source ~/.rvm/scripts/rvm
#installing postgres
# Commands to use in GDB/PEDA
b <func_name> - classic breakpoint
b *0x123123 - break at address 0x123123
pdisas - better disass
vmmap - print mapped memory
pattern create 2000 - generate cyclic pattern
telescope 200 - pretty print the stack, 200 ahead
context all - print registers, stack, code, everything good
xormem - xor a memory region with a key
procinfo - display various info from /proc/pid/
@xufuou
xufuou / gist:ce97ce538f763632a5066949296bfc96
Created July 5, 2017 21:39 — forked from alekpopovic/gist:ce3635c7e29596e6f65154b1785e5ef9
Installing Laravel 5.2 on Ubuntu 16.04 and Apache2
Installing Laravel 5.2 on Ubuntu 16.04 and Apache2
This post will document how I installed Laravel 5.2, on Apache2 on an Ubuntu 16.04 server. Will will also install MySQL, as we will need a database, and PHP which is required by Laravel. This will be the starting point of most of my posts, so if you’re following along from scratch…this is “scratch!”
First thing you need, of course, is the Ubuntu 16.04 server, with an SSH connection. Follow these excellent instructions and get yourself sorted out with one. Make sure you also give the server a static IP address (step 8., in the linked instructions). Come back when you’re done.
Welcome back! Lets get started.
@xufuou
xufuou / caffe_commands.txt
Last active May 4, 2017 22:39
caffe_commands
#create LMDB dataset
/Users/xufuou/Documents/caffe/build/tools/convert_imageset --resize_height=224 --resize_width=224 datasets/training_images/ datasets/training_list.txt datasets/training_set_lmdb
#create mean proto file
/Users/xufuou/Documents/caffe/build/tools/compute_image_mean datasets/training_set_lmdb/ datasets/mean_training_image.binaryproto
#create lmdb datasets
/Users/xufuou/Documents/caffe/build/tools/convert_imageset --resize_height=224 --resize_width=224 datasets/training_images/ datasets/training.txt datasets/training_lmdb
/Users/xufuou/Documents/caffe/build/tools/convert_imageset --resize_height=224 --resize_width=224 datasets/training_images/ datasets/validation.txt datasets/validation_lmdb
@xufuou
xufuou / README.md
Created May 3, 2017 22:21 — forked from GilLevi/README.md
Emotion Recognition in the Wild via Convolutional Neural Networks and Mapped Binary Patterns

Gil Levi and Tal Hassner, Emotion Recognition in the Wild via Convolutional Neural Networks and Mapped Binary Patterns

Convolutional neural networks for emotion classification from facial images as described in the following work:

Gil Levi and Tal Hassner, Emotion Recognition in the Wild via Convolutional Neural Networks and Mapped Binary Patterns, Proc. ACM International Conference on Multimodal Interaction (ICMI), Seattle, Nov. 2015

Project page: http://www.openu.ac.il/home/hassner/projects/cnn_emotions/

If you find our models useful, please add suitable reference to our paper in your work.

@xufuou
xufuou / instal_caffe_cpu.sh
Last active May 3, 2017 00:25 — forked from rizky/instal_caffe_cpu.sh
Setup Caffe CPU Only in MacOS Sierra
#!/bin/sh
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Apple hides old versions of stuff at https://developer.apple.com/download/more/
# Install the latest XCode (8.0).
# We used to install the XCode Command Line Tools 7.3 here, but that would just upset the most recent versions of brew.
# So we're going to install all our brew dependencies first, and then downgrade the tools. You can switch back after
# you have installed caffe.
# Install the experimental NVIDIA Mac drivers