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
from datetime import date | |
sundays=0 | |
for year in range(1901,2001): | |
for month in range(1,13): | |
if date(year,month,1).weekday()==6: | |
sundays+=1 | |
print sundays |
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
from math import factorial | |
num=factorial(100) | |
num_list=[int(x) for x in list(str(num))] | |
print sum(num_list) |
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
import subprocess, signal | |
import os | |
import re | |
a_process = "postgres" | |
def is_running(process): | |
s = subprocess.Popen(["ps", "axw"],stdout=subprocess.PIPE) | |
for x in s.stdout: | |
if re.search(process, x): |
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
f=open("names.txt",'r') | |
char_num_dict={"A":1,"B":2,"C":3,"D":4,"E":5,"F":6,"G":7,"H":8,"I":9,"J":10,"K":11,"L":12,"M":13,"N":14,"O":15,"P":16,"Q":17,"R":18,"S":19,"T":20,"U":21,"V":22,"W":23,"X":24,"Y":25,"Z":26} | |
names=sorted(f.read().replace('"','').split(','),key=str) | |
sum=0 | |
for ind,val in enumerate(names): | |
temp=0 | |
for x in val: | |
temp+=char_num_dict[x] | |
sum+=temp*(ind+1) | |
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
from random import randint, randrange, random, choice | |
from string import letters | |
from math import floor | |
import pygal | |
from pygal.style import CleanStyle | |
def generatechromosome(length): | |
chromosome = "" | |
for index in xrange(length): | |
chromosome += choice(letters) |
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
// You are given a map of arbitrary size represented | |
// as a two-dimensional array, and your job is to | |
// return the same map, but rotated 180 degrees. | |
this.run = function(map) { | |
var newmap = []; | |
for (var i = map.length-1; i >= 0; i--) { | |
newmap.push(map[i].reverse()); | |
} | |
return newmap; |
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
set number | |
set lisp | |
set expandtab | |
set shiftwidth=4 | |
set softtabstop=4 | |
set autoindent | |
set smartindent | |
filetype plugin indent on | |
set showmatch | |
syntax on |
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
# Sets the prefix key to C-a | |
unbind-key C-b | |
set-option -g prefix C-a | |
bind-key C-a send-prefix | |
# Start numbering windows at 0 | |
set -g base-index 0 | |
# Set default color scheme | |
set -g default-terminal "screen-256color" |
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
(if (member "--no-linedit" sb-ext:*posix-argv* :test 'equal) | |
(setf sb-ext:*posix-argv* | |
(remove "--no-linedit" sb-ext:*posix-argv* :test 'equal)) | |
(when (interactive-stream-p *terminal-io*) | |
(require :sb-aclrepl) | |
(require :linedit) | |
(funcall (intern "INSTALL-REPL" :linedit) :wrap-current t))) | |
(sb-alien:alien-funcall | |
(sb-alien:extern-alien "disable_lossage_handler" (function sb-alien:void))) |
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
from random import choice | |
from string import ascii_lowercase | |
def generate_gibberish(length): | |
gibberish = [] | |
for x in xrange(0, length): | |
gibberish.append(choice(ascii_lowercase)) | |
return "".join(gibbeirish) | |
print gibberish(10) |