View json_uuid.py
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 uuid | |
import json | |
import random | |
import datetime | |
id = str(uuid.uuid1()) | |
actions = ['purchase1', 'purchase2', 'version'] | |
print json.dumps({'date' : str(datetime.datetime.now()), 'id' : id, 'action' : 'install'}) | |
for i in xrange(10): |
View gist:52a2aafacb6561e8420151ac0c7cae6d
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
days = ['Monday','Tuesday','Wednesday','Thursday','Friday'] | |
today = datetime.datetime.today().strftime('%A') | |
tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).strftime('%A') | |
day = tomorrow | |
day_counter=0 | |
for cell_menu_item in row('div',{'class':'cell_menu_item'}): | |
if day not in days[day_counter]: |
View config.xml
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
<?xml version='1.0' encoding='UTF-8'?> | |
<project> | |
<description>hello-world</description> | |
<keepDependencies>false</keepDependencies> | |
<properties/> | |
<scm class="hudson.scm.NullSCM"/> | |
<canRoam>true</canRoam> | |
<disabled>false</disabled> | |
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> | |
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> |
View second.pl
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 perl | |
# for hackerrank https://www.hackerrank.com/challenges/nested-list/problem | |
# read the input file | |
@input = <>; | |
# get the first line; that's the number of students | |
$count = shift @input; | |
# process the rest of the input... |
View github_status.py
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 requests | |
from bs4 import BeautifulSoup | |
# make a request for the data | |
r = requests.get('https://status.github.com/') | |
# convert the response text to soup | |
soup = BeautifulSoup(r.text, "lxml") | |
# get all the divs with the "graph" class |
View azlyrics.py
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 requests | |
from bs4 import BeautifulSoup | |
url = "http://www.azlyrics.com/lyrics/onyx/bacdafucup.html" | |
print "Default request (it will fail)..." | |
# make the default request | |
try: | |
r = requests.get(url) |
View array123.py
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
tests = {"1":[1,1,2,3,1],"2":[1,1,2,4,1],"3":[1,1,2,1,2,3]} | |
def array123(array): | |
if len(array) < 3: | |
return False | |
for (index, item) in enumerate(array): | |
if item == 1: | |
state1 = True | |
elif (item == 2) and state1: |
View rockin_robin.py
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
arrays = [ [1,7], [2,3,4], [10,11,12,13] ] | |
while arrays: | |
for (index, item) in enumerate(arrays): | |
if len(arrays[index]) == 0: | |
arrays.pop(index) | |
continue | |
print arrays[index].pop(0) | |
print arrays |
View compare-the-triplets.pl
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 perl | |
# read the input file | |
@input = <>; | |
# initialize the scores | |
@score = qw(0 0); | |
# split the input into arrays | |
foreach $i (0..1) { |
View mini-max-sum.pl
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 perl | |
# read the input | |
@data = split /\s+/, <STDIN>; | |
@data = sort @data; | |
map { $min += $_ } @data[0 .. ($#data - 1)]; | |
map { $max += $_ } @data[1 .. $#data]; | |
print "$min $max\n"; |
OlderNewer