This file contains hidden or 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
| show dbs | |
| use hello | |
| db.people.insert({name: "Abdul", age: 22, likes: ["skiing", "hiking"]}) | |
| db.people.insert({name: "Barbara", age: 20, country: "UK"}) | |
| db.people.insert({name: "Chi", age: 40, country: "CN", | |
| job: {title: "welder", salary: {currency: "EUR", amount: 50000}}}) |
This file contains hidden or 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
| # Mongo not happy unless lots of open files | |
| ulimit -n 2000 | |
| # Start server | |
| sudo mongod --fork --syslog | |
| # Already done | |
| unzip all-films.zip | |
| mongoimport -d mgo -c films all-films.json |
This file contains hidden or 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
| mkdir -p data/shard0/rs0 data/shard0/rs1 data/shard0/rs2 | |
| mongod --replSet s0 --logpath "s0-r0.log" --dbpath data/shard0/rs0 --port 37017 --fork --shardsvr | |
| mongod --replSet s0 --logpath "s0-r1.log" --dbpath data/shard0/rs1 --port 37018 --fork --shardsvr | |
| mongod --replSet s0 --logpath "s0-r2.log" --dbpath data/shard0/rs2 --port 37019 --fork --shardsvr | |
| mongo --port 37017 | |
| config = {_id: "s0", members: [ | |
| {_id: 0, host: "localhost:37017" }, | |
| {_id: 1, host: "localhost:37018" }, | |
| {_id: 2, host: "localhost:37019" }]}; |
This file contains hidden or 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
| # Writes the class hierarchy of the core Ruby classes. | |
| $nodes = Hash.new | |
| module Hack # Hack to keep Node out of the result! | |
| class Node | |
| attr_reader :cls | |
| attr_accessor :children | |
| def initialize(c) | |
| @cls = c |
This file contains hidden or 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
| BasicObject | |
| Object (Kernel) | |
| Module | |
| Class | |
| NilClass | |
| Data | |
| TrueClass | |
| FalseClass | |
| Encoding | |
| String (Comparable) |
This file contains hidden or 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
| class Circle | |
| attr_reader :r | |
| def initialize(x = 0, y = 0, r = 1) | |
| @x = x | |
| @y = y | |
| @r = r | |
| end | |
| def center |
This file contains hidden or 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
| class Animal | |
| def initialize(name) | |
| @name = name | |
| end | |
| def speak() | |
| "#{@name} says #{sound()}" | |
| end | |
| end | |
| class Cow < Animal |
This file contains hidden or 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 re | |
| import sys | |
| pattern = re.compile(r'"[\w]+":') | |
| all = set([]) | |
| for line in sys.stdin: | |
| keys = re.findall(pattern, line) | |
| all.update(keys) | |
| print all |
This file contains hidden or 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
| /* | |
| * bypass.c | |
| * | |
| * Try this on an x86 machine. It does **not** print "1". | |
| */ | |
| #include <stdio.h> | |
| void weird() { | |
| int a; |
This file contains hidden or 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
| next((i for i,row in enumerate(a) if all(x == 0 for x in row)), -1) |
OlderNewer