Skip to content

Instantly share code, notes, and snippets.

var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@avshabanov
avshabanov / gist:10949276
Created April 17, 2014 02:41
Sequences.java
package com.truward.polymer.util;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import javax.annotation.Nonnull;
import java.util.*;
/**
@avshabanov
avshabanov / proxyserver.js
Created May 30, 2014 17:03
NodeJS Simple Proxy Server
var http = require("http"),
url = require("url");
var port = process.argv[2] || 8888;
// Sample redir link: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
http.createServer(function(request, response) {
var urlOptions = url.parse(request.url);
var pathname = urlOptions.pathname;
@avshabanov
avshabanov / perf_double.c
Created June 2, 2014 17:39
Performance benchmark: double multiplication vs integer multiplication+shift
#include <stdio.h>
#define N (100000000)
double arr[] = { 8, 0.125, 4, 0.25 };
int main() {
double d = 1.0;
for (int i = 0; i < N; ++i) {
d *= arr[i % 4];
package com.alexshabanov.kotwebdemo.service.radio
import java.util.Collections
import java.util.ArrayList
// prototype of non-AOP based approach to service exposure
//
// Public API
//
@avshabanov
avshabanov / ratio.kt
Last active August 29, 2015 14:12 — forked from abreslav/ratio.kt
class Ratio(num : Int, denom : Int) {
val numerator: Int
val denominator: Int
{
val theGcd = gcd(num, denom)
numerator = num / theGcd
denominator = denom / theGcd
}
}
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engi
@avshabanov
avshabanov / Gruntfile.js
Last active August 29, 2015 14:18
Sample gruntfile for mixed (plain JS + reactjs) project processed by browserify
module.exports = function(grunt) {
function prepareSkeleton() {
grunt.file.mkdir('target/web/js');
grunt.file.mkdir('target/web/tmp/js');
}
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
package com.alexshabanov.neocharseq
trait Str {
/** Appends the contents of this stream. */
fun appendTo(stream: Appendable)
fun charAt(pos: Int): Char
fun length(): Int
final Object o1 = jdbcOperations.query("SELECT book_id, series_id, pos FROM book_series", new RowMapper<Object>() {
@Override
public Object mapRow(ResultSet rs, int i) throws SQLException {
final Map<String, Object> result = new HashMap<String, Object>();
result.put("book_id", rs.getLong("book_id"));
result.put("series_id", rs.getLong("series_id"));
result.put("pos", rs.getInt("pos"));
return result;
}
});