Skip to content

Instantly share code, notes, and snippets.

import select
import socket
class EchoServer(object):
def __init__(self, reactor):
self.sock = socket.socket()
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.sock.bind(('', 8000))
self.sock.listen(2)
@timurridjanovic
timurridjanovic / flatten-array.js
Last active August 4, 2016 22:17
Flatten an array
function flatten(arr) {
if (!Array.isArray(arr)) throw new Error('flatten takes an array as a parameter');
return arr.reduce(function(newArr, el) {
if (Array.isArray(el)) return flatten(newArr.concat(el));
return newArr.concat(el);
}, []);
}
//uses jasmine as a testing framework
describe('Flattening an array', function() {
@timurridjanovic
timurridjanovic / jsx
Created November 10, 2016 16:23
image aspect fit scaling
import React from 'react';
import {
Image,
View,
Dimensions
} from 'react-native';
import messageStyle from './MessageStyles';
class ImageRow extends React.Component {