Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
"use strict";
var ApplicationConfiguration = function() {
var applicationModuleName = "backer-news",
applicationModuleVendorDependencies = ["ngResource", "ngCookies", "ngAnimate", "ngTouch", "ngSanitize", "ui.router", "ui.bootstrap", "ui.utils"],
registerModule = function(moduleName, dependencies) {
angular.module(moduleName, dependencies || []), angular.module(applicationModuleName).requires.push(moduleName)
};
return {
applicationModuleName: applicationModuleName,
applicationModuleVendorDependencies: applicationModuleVendorDependencies,

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@dvliman
dvliman / raymond
Last active August 29, 2015 14:09
new
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class Person {
protected:
string name;
string address;
@dvliman
dvliman / main.go
Last active August 29, 2015 14:11 — forked from nmerouze/main.go
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
@dvliman
dvliman / gist:267b66ac3a321172fd35
Created January 4, 2015 03:32
linux-kernel-booting-process

GNU/Linux kernel internals

Linux kernel booting process. Part 1.

If you read my previous blog posts, you can note that sometime ago I have started to get involved low-level programming. I wrote some posts about x86_64 assembly programming for Linux. In the same time I started to dive into GNU/Linux kernel source code. It is very interesting for me to understand how low-level things works, how programs runs on my computer, how they located in memory, how kernel manages processes and memory, how network stack works on low-level and many many other things. I decided to write yet another series of posts about GNU/Linux kernel for x86_64.

Note, that I'm not professional kernel hacker and I don't write code for kernel at work, just a hobby. I just like low-level stuff and it is interesting to me how these

Journey

I was using Boot2Docker 1.2 (OSX) and wanted to use volume for MongoDB. First nothing was happening because 1.2 has no Guest Additions and volumes don't work. There is a workaround by making a boot2docker.iso from master which has Guest Additions.

But then Mongo didn't like putting data on VirtualBox's shared folders:

[initandlisten] 	WARNING: This file system is not supported. For further information see:
[initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
@dvliman
dvliman / gist:f7ed98edb8b9819277a9
Created January 8, 2015 01:58
coupon-at-checkout
/*
* Coupons at Checkout Browser Extension
* Copyright (c) 2012, 2013 CouponFollow, LLC. All rights reserved.
* Copying this source code in any manner is strictly prohibited.
*/
"use strict";
var storage = chrome.storage.local;
# rob houses (3,5,1,7,9) where the rule is
# you can not rob adjacent houses and the goal
# is to get the maximum sum value
# 3 => 3
# 3, 5 => 5
# 3, 5, 1 => 5
# 3, 5, 1, 7 => 12
# ...
# 3, 5, 1, 7, 9
drwxr-xr-x 7 dv staff 238B Jul 18 2014 HackerSwifter
drwxr-xr-x 27 dv staff 918B Aug 17 15:46 NewsBlur
drwxr-xr-x 11 dv staff 374B Jun 24 2014 ScalaWebscraper
drwx------@ 6 dv staff 204B May 10 2014 ScrapeBox
drwxr-xr-x 20 dv staff 680B Jul 18 2014 SwiftHN
drwxr-xr-x 18 dv staff 612B Dec 25 14:06 atlas
drwxr-xr-x 24 dv staff 816B Sep 9 10:53 beansdb
drwxr-xr-x 33 dv staff 1.1K Aug 21 21:44 bolt
drwxr-xr-x 11 dv staff 374B Jul 16 2014 buggy
drwxr-xr-x 10 dv staff 340B Sep 8 22:05 cloudtunes
@dvliman
dvliman / gist:cd43db0419f400725fbd
Created February 19, 2015 00:05
uninstall-node-pkg
if you installed node pkg from official website, here is how to uninstall
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
brew install node