This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
num_digits (int n) | |
{ | |
int r; | |
for (r = 1, n /= 10; n != 0; n /= 10) | |
r++; | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from functools import wraps | |
from django.utils.decorators import available_attrs | |
def header(name, value): | |
# View decorator that sets a response header. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
# | |
# Issue an HTTP POST request to upload a string as file using libcurl | |
# and pycurl. | |
# | |
# vars.php | |
# <?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
int val; | |
struct klist_node node; | |
} knode_t; | |
/* Not the wisest way of doing it for sure. */ | |
knode_t * | |
my_klist_first (struct klist *list) | |
{ | |
struct klist_iter iter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from StringIO import StringIO | |
import pprint as pprint | |
import sys | |
# Original idea: http://softwaremaniacs.org/forum/python/25696/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xdotool search --name Firefox key --window %@ F5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun y:python-run () | |
(interactive) | |
(let* ((dedicated-proc-name (python-shell-get-process-name t)) | |
(dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name)) | |
(dedicated-running (comint-check-proc dedicated-proc-buffer-name))) | |
;; If there's already a python shell running for this buffer, kill it | |
(when dedicated-running | |
(let* ((process (python-shell-get-or-create-process)) | |
(buffer (process-buffer process))) | |
(set-process-query-on-exit-flag process nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
from __future__ import unicode_literals | |
import sys | |
from PyQt4 import QtCore, QtGui | |
from PyQt4.QtCore import Qt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
import re | |
from django import forms | |
from django.core import exceptions | |
from django.db import models | |
from south.modelsinspector import add_introspection_rules |
OlderNewer