Skip to content

Instantly share code, notes, and snippets.

View hipertracker's full-sized avatar

Jaroslaw Zabiello hipertracker

View GitHub Profile
FROM phusion/passenger-full:latest
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# Build system and git.
RUN /build/utilities.sh
@hipertracker
hipertracker / bench.py
Created February 8, 2015 01:46
Python benchmark
import sys, time
stdout = sys.stdout
BAILOUT = 16
MAX_ITERATIONS = 1000000
class Iterator:
def __init__(self):
print('Rendering...')
for y in range(-39, 39):
@hipertracker
hipertracker / bench2.py
Created February 8, 2015 01:52
Python bench2
import time
class Person:
def __init__(self, count):
self.count = count
self.prev = None
self.next = None
def shout(self, shout, deadif):
if shout < deadif:
return shout + 1
import unittest
import datetime
def last_week_days(day, week_day, n):
'''
Last n days of the week
:param day: datetime.date
:param week_day: int (0=Monday, 1=Tuesday, ... 6=Sunday)
:param n: number of past weeks
@hipertracker
hipertracker / promises-escalation.js
Last active August 29, 2015 14:19
Promises escalation
window.f1 = function () {
var p1 = Q.defer();
if {
p1.resolve({'resolved f1:': x})
} else {
p1.reject({'rejected f1': x})
}
return p1.promise;
};
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
colors: ['#7cb5ec', '#91e8e1', '#90ed7d', '#f7a35c', '#8085e9',
'#f15c80', '#e4d354', '#8085e8', '#8d4653', '#91e8e1'],
title: {
text: 'Something '
@hipertracker
hipertracker / gist:e15795fc24a7f19ff0dd
Last active August 29, 2015 14:20
Python is ugly
#given: argv = {'--encoding': 'utf-8', '--orientation': 'Landscape', '-s': 'A4'}
#expected: ['--orientation', 'Landscape', '-s', 'A4', '--encoding', 'utf-8']
#Python:
import itertools
print(list(itertools.chain.from_iterable(list(argv.items()))))
# Ruby:
import React from 'react';
class Navbar extends React.Component {
constructor(props) {
super(props);
this.state = {isChecked: true, radio: 1};
}
handleCheckbox() {
this.setState({isChecked: !this.state.isChecked});
import subprocess
html = subprocess(['babel-node', 'main.js'])
print html
@hipertracker
hipertracker / datatable.js
Last active August 29, 2015 14:23
React & fixed-data-table
import React, { Component, PropTypes } from 'react'
import { Table, Column } from 'fixed-data-table'
import _ from 'lodash'
const SortTypes = {
ASC: 'ASC',
DESC: 'DESC'
};
class DataTable extends Component {