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 math | |
import operator | |
import re | |
functions = { | |
"sqrt": math.sqrt, | |
"lg": math.log10, | |
"ln": math.log, | |
"log": math.log, | |
} |
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
jest.dontMock("../dropdown.jsx"); | |
var React = require("react/addons"); | |
var TestUtils = React.addons.TestUtils; | |
var Dropdown = require("../dropdown.jsx"); | |
var items = ["A", "B"]; | |
describe('dropdown', function() { | |
it('renders an empty button initially', function() { | |
var c = TestUtils.renderIntoDocument(<Dropdown menuItems={items} />); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="bower_components/react/react-with-addons.js"></script> | |
<script src="bower_components/react/JSXTransformer.js"></script> | |
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.css"> | |
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap-theme.css"> | |
<style type="text/css"> | |
.dropdown-menu { display: block; } |
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 "set" | |
def eratosthenes n | |
nums = [nil, nil, *2..n] | |
(2..Math.sqrt(n)).each do |i| | |
(i**2..n).step(i) { |m| nums[m] = nil } if nums[i] | |
end | |
nums.compact | |
end |
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 python | |
import pymysql as db | |
import configparser | |
class ConnectionManager(object): | |
connections = {} | |
def connection(self, source): | |
if source not in self.connections: |
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
diff --git i/general.c w/general.c | |
index 491a7ea267ab..ec9b6271015d 100644 | |
--- i/general.c | |
+++ w/general.c | |
@@ -700,10 +700,11 @@ polite_directory_format (name) | |
strncpy (tdir + 1, name + l, sizeof(tdir) - 2); | |
tdir[0] = '~'; | |
tdir[sizeof(tdir) - 1] = '\0'; | |
- return (tdir); | |
} |
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
#! /bin/bash | |
PATH=/usr/sbin:/sbin:/usr/bin:/bin | |
services=(cron syslogd) | |
start_service() { | |
service=$1 | |
echo "$service is not running." >&2 | |
$service |
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 | |
letters = ARGV[0].split('') | |
words = open("/usr/share/dict/words").read.split(/\n/).reduce([]) do |words, word| | |
signature = word.chomp.downcase.split('') | |
words << word if signature == signature & letters | |
words | |
end |
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 | |
src = [["Ukraine", ["Kyiv", "Kharkov"]], ["France", ["Paris", "Marseilles"]], ["Poland", ["Warsaw", "Krakow"]]] | |
dst = src.flat_map { |(country, cities)| cities.map { |city| "#{country}/#{city}" }} | |
puts dst.map { |i| [i, dst - [i]]}.inspect |
NewerOlder