Skip to content

Instantly share code, notes, and snippets.

def _find_neg_rect(image, pos_rects):
image_width, image_height = image.shape
rand = partial(random.randint, 1)
while True:
x = rand(image_width - 1)
width = rand(image_width - x)
y = rand(image_height - 1)
height = rand(image_height - y)
random_rect = Rect(x, y, width, height)
diff --git a/ceval.c b/ceval.c
index 06ada97..27a929b 100644
--- a/ceval.c
+++ b/ceval.c
@@ -4781,6 +4781,7 @@ static PyObject *
string_concatenate(PyObject *v, PyObject *w,
PyFrameObject *f, unsigned char *next_instr)
{
+ printf("\ncalling string_concatenate\n");
/* This function implements 'variable += expr' when both arguments
print "\nadding string variables\n"
a = "zhi"
b = "hu"
c = "yao"
d = "xxx"
print a+b+c+d
print "\nadding string literals\n"
print "zhi" + "hu" + "yao" + "xxx"
# coding: utf-8
import math
def map_loop():
list(map(math.sin, range(20000000)))
def for_loop():
r = []
for i in range(20000000):
r.append(math.sin(i))
From: Antonio Radici <antonio@debian.org>
Date: Sat, 19 Sep 2015 13:19:55 +0200
Subject: sidebar
When enabled, mutt will show a list of mailboxes with (new) message counts in a
separate column on the left side of the screen.
As this feature is still considered to be unstable, this patch is only applied
in the "mutt-patched" package.
#mkdir,cd into it
mkcd(){
mkdir -p "$*"
cd "$*"
}
@ggarlic
ggarlic / gist:11028662
Created April 18, 2014 07:07
async and sync method in twisted
import time
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.web import server
from twisted.internet.protocol import ProcessProtocol
from twisted.internet.defer import Deferred
from calendar import calendar
#include <iostream>
using namespace std;
void hannoi (int n, char A, char B, char C) {
if (n == 1) {
cout << "move one from " << A << " to " << C << endl;
}
else {
hannoi (n-1, A, C, B);
cout << "move one from " << A << " to " << C << endl;
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import pyinotify
import mailbox
import pynotify
import os
import gtk
from email.header import decode_header
from os.path import expanduser
#!/bin/bash
while inotifywait -e moved_to ~/.mail/{gmail,work}/inbox/new/; do
notify-send -i /usr/share/icons/Humanity/status/48/dialog-info.svg "You've got a new mail.'"
aplay -q ~/.mybashscripts/mail.wav
done