This file contains 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
const http = require('http'); | |
const {promisify} = require('util'); | |
http.get[promisify.custom] = function getAsync(options) { | |
return new Promise((resolve, reject) => { | |
http.get(options, (response) => { | |
response.end = new Promise((resolve) => response.on('end', resolve)); | |
resolve(response); | |
}).on('error', reject); | |
}); |
This file contains 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
package com.example.wear; | |
import android.app.Activity; | |
import android.hardware.Sensor; | |
import android.hardware.SensorEvent; | |
import android.hardware.SensorEventListener; | |
import android.hardware.SensorManager; | |
import android.os.Bundle; | |
import android.support.wearable.view.WatchViewStub; | |
import android.util.Log; |
This file contains 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
#include <cuda_runtime.h> | |
#include <cstring> | |
#include <cstdlib> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <stdio.h> | |
#include "caffe/caffe.hpp" |
This file contains 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
package com.javaforu.rsync; | |
import com.javaforu.rsync.Sync.CharRingBuffer.Visitor; | |
import rollinghash.RabinKarpHash; | |
import java.util.*; | |
import java.util.zip.CRC32; | |
/** | |
* Author: Ashwin Jayaprakash / [email protected] / http://www.ashwinjayaprakash.com |
This file contains 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
/** | |
* In this code we have a very large array called arr, and very large set of operations | |
* Operation #1: Increment the elements within range [i, j] with value val | |
* Operation #2: Get max element within range [i, j] | |
* Build tree: build_tree(1, 0, N-1) | |
* Update tree: update_tree(1, 0, N-1, i, j, value) | |
* Query tree: query_tree(1, 0, N-1, i, j) | |
* Actual space required by the tree = 2*2^ceil(log_2(n)) - 1 | |
*/ |
This file contains 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
public double doIt(BufferedImage image) { | |
final double skewRadians; | |
BufferedImage black = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY); | |
final Graphics2D g = black.createGraphics(); | |
g.drawImage(image, 0, 0, null); | |
g.dispose(); | |
skewRadians = findSkew(black); | |
System.out.println(-57.295779513082320876798154814105 * skewRadians); | |
return skewRadians; |
This file contains 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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
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 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |