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
# Assistant: | |
{"comment": "Printing first few lines of the file", "python": "with open('food-enforcement.json') as f:\n for i in range(3):\n print(f.readline().strip())"} | |
## Extracting comment: | |
Printing first few lines of the file | |
## Extracting python code: | |
with open('food-enforcement.json') as f: | |
for i in range(3): | |
print(f.readline().strip()) | |
## Do you want to execute this code? (y/n) | |
y |
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 collections import defaultdict | |
def all_pairs(): | |
for n1 in range(2, 65): | |
for n2 in range(n1+1, 65+1): | |
yield n1, n2 | |
def prod(pair): |
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 python3 | |
import sys | |
from random import random | |
def single_trial(): | |
""" | |
Generate a random 2 dimensional point between (0, 0) and (1, 1) | |
and returns weather the distance to the origin is less than 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
#!/usr/bin/env python3 | |
RADIX = 10 | |
# radix sort that works for non negative integers | |
def radix_sort_nonneg(lst): | |
last_iteration = False | |
radix_power = 1 | |
while not last_iteration: |
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
######################################### | |
# helpers # | |
######################################### | |
# helper to calculate s | |
s.func <- function(X) { | |
# norms ^ 4 | |
norms4 <- apply(X, 2, function(Xi) (Xi%*%Xi)^2) | |
n <- ncol(X) |
I hereby claim:
- I am fela on github.
- I am fela (https://keybase.io/fela) on keybase.
- I have a public key whose fingerprint is 0875 81C7 564F 1E05 5EE3 8D05 7B0D 4361 506C 15B0
To claim this, I am signing this object:
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 ruby | |
x=<<'X' | |
#!/usr/bin/env ruby | |
x=<<'X' | |
x+="X\n" | |
x=x.split("\n") | |
x=x[0..1]+x[0..7]+x[2..-2] | |
puts x.join("\n") | |
X | |
x+="X\n" |
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 ruby | |
$VERBOSE = true | |
$:.unshift File.dirname($0) | |
require 'Qt4' | |
module Shoes | |
def self.app &blk |
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
require 'thread' | |
Shoes.app do | |
@s = stack do | |
para "this is a para in the stack.." | |
end | |
Thread.new do | |
sleep 0.1 | |
@s.remove |
NewerOlder