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
| from mrjob.job import MRJob | |
| class MRWordCountJob(MRJob): | |
| def steps(self): | |
| return [self.mr( | |
| mapper=self.capture_values, | |
| mapper_init=self.init_values, | |
| mapper_final=self.emit_values, |
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
| ssh -o ServerAliveInterval=10 -o StrictHostKeyChecking=no -i ~/.ssh/EMR.pem hadoop@<value of Master Public DNS Name> |
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
| # Tab color aliases | |
| alias tred='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;128N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"' | |
| alias torange='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;192N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"' | |
| alias tyellow='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"' | |
| alias tgreen='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"' | |
| alias tcyan='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;255N^G\a"' | |
| alias tblue='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;128N^G\a" && echo -en "\033]6;1;bg;blue;brightness;255N^G\a"' | |
| alias tmagenta=' |
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 MyTable(...): | |
| __tablename__ = 'my_table' | |
| id = ... | |
| unicode_col = Column(UnicodeText()) | |
| # (insert some rows into my_table) | |
| assert type(session.query(MyTable).first()) == unicode # NOPE! | |
| ### workaround ### |
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
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm.session import Session | |
| from sqlalchemy import ( | |
| create_engine, | |
| Column, | |
| Integer, | |
| UnicodeText, | |
| ) | |
| Base = declarative_base() |
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
| from bson import ObjectId | |
| from sqlalchemy import types | |
| from sqlalchemy.dialects.mysql import BINARY | |
| class BinaryObjectId(types.TypeDecorator): | |
| impl = BINARY | |
| def process_bind_param(self, value, dialect): | |
| if value: |
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
| def run_job(self): | |
| """Run the all steps of the job, logging errors (and debugging output | |
| if :option:`--verbose` is specified) to STDERR and streaming the | |
| output to STDOUT. | |
| Called from :py:meth:`run`. You'd probably only want to call this | |
| directly from automated tests. | |
| """ | |
| self.set_up_logging(quiet=self.options.quiet, | |
| verbose=self.options.verbose, |
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
| - id: beginner | |
| maleName: Bob | |
| femaleName: Dora | |
| genre: tutorial | |
| goals: | |
| - name: "Flower garden" | |
| sampleObjectTypeIds: ['2h5i418'] | |
| minimumSubmitLevel: 2 | |
| templateQuery: '' | |
| dimensions: |
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
| - id: beginner | |
| maleName: Bob | |
| femaleName: Dora | |
| genre: tutorial | |
| goals: | |
| - name: "Flower garden" | |
| verbPhrase: 'Enjoying flowers' | |
| sampleObjectTypeIds: ['2h5i418'] | |
| minimumSubmitLevel: 2 | |
| templateQuery: 'tutorial garden' |
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
| func getUIImageForRGBAData(#width: UInt, #height: UInt, #data: NSData) -> UIImage? { | |
| let pixelData = data.bytes | |
| let bytesPerPixel:UInt = 4 | |
| let scanWidth = bytesPerPixel * width | |
| let provider = CGDataProviderCreateWithData(nil, pixelData, height * scanWidth, nil) | |
| let colorSpaceRef = CGColorSpaceCreateDeviceRGB() | |
| var bitmapInfo:CGBitmapInfo = .ByteOrderDefault; | |
| bitmapInfo |= CGBitmapInfo(CGImageAlphaInfo.Last.rawValue) |