$ python --version
Python 3.6.0
$ python -m timeit -s 'import random; l = list(range(18))' 'random.choice(l)'
1000000 loops, best of 3: 0.591 usec per loop
$ python -m timeit -s 'd = {str(n): list(range(15)) for n in range(18)}' 'd["12"]'
10000000 loops, best of 3: 0.0224 usec per loop
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 hashlib | |
import hmac | |
import json | |
import struct | |
import sys | |
def main(): | |
if len(sys.argv) != 2: | |
print(f"Usage: python3 {sys.argv[0]} COURSES.jsonl\n", file=sys.stderr) |
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 itertools | |
data = ['str', 'int', 'dex', 'con', 'wis', 'cha'] | |
covered = frozenset([ | |
# paladin | |
('wis', 'cha'), ('cha', 'str'), ('str', 'cha'), ('str', 'int'), | |
# barbarian | |
('str', 'dex'), ('str', 'con'), ('con', 'str'), |
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
addDataset(id: string, content: string): Promise<InsightResponse> { | |
return new Promise(function (fulfill, reject) { | |
let zip = new JSZip(); | |
let courseStringsPromises: Promise<string>[] = []; | |
if (id === "" || id === null) { | |
reject({"code": 400, "body": {"error": "invalid id"}}); | |
} | |
if (content === "" || content === null) { |
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
using System; | |
using System.Collections.Generic; | |
static class Application { | |
static void Main() { | |
var list = new List<int>(); | |
for (int i = 0; i < 100; i++) { | |
Console.WriteLine("{0,5}/{1,5}", list.Count, list.Capacity); | |
list.Add(i); |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
// most code is single-threaded | |
unsigned char* current_mem; | |
void* readA(); | |
void* readB(); |
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
using System; | |
using System.Windows.Forms; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
class ColorInterpolationApplication { | |
public static void Main() { | |
Application.Run(new ColorInterpolation()); | |
} | |
} |
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
alert("Don't blindly paste scripts into your console! Sheesh."); |
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
#include <string.h> | |
#include <stdio.h> | |
#include <libpq-fe.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <sys/epoll.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> |
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
problem = [ | |
[75], | |
[95, 64], | |
[17, 47, 82], | |
[18, 35, 87, 10], | |
[20, 04, 82, 47, 65], | |
[19, 01, 23, 75, 03, 34], | |
[88, 02, 77, 73, 07, 63, 67], | |
[99, 65, 04, 28, 06, 16, 70, 92], | |
[41, 41, 26, 56, 83, 40, 80, 70, 33], |
NewerOlder