Skip to content

Instantly share code, notes, and snippets.

View vishwakarma's full-sized avatar
🎯
Code like a maniac

Gopi Vishwakarma vishwakarma

🎯
Code like a maniac
View GitHub Profile
@vishwakarma
vishwakarma / dropbox_restore.py
Last active October 19, 2016 05:01
[Dropbox] Script to restore ransomware corrupted files
import sys
# Include the Dropbox SDK
import dropbox
from dropbox.files import DeletedMetadata
def solve(entries, client, store, corrupted_file_extension):
for i in entries:
if i.name.endswith('swp'):
continue
if isinstance(i,DeletedMetadata):
import java.io.*;
import java.util.StringTokenizer;
public class TaskA {
private static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
(venv) [gopi2667@ip-172-31-60-179 my_project]$ pip install pydoop
Collecting pydoop
Using cached pydoop-1.2.0.tar.gz
Requirement already satisfied: setuptools>=3.3 in ./venv/lib/python2.7/site-packages (from pydoop)
Requirement already satisfied: six>=1.6.0 in ./venv/lib/python2.7/site-packages (from setuptools>=3.3->pydoop)
Requirement already satisfied: appdirs>=1.4.0 in ./venv/lib/python2.7/site-packages (from setuptools>=3.3->pydoop)
Requirement already satisfied: packaging>=16.8 in ./venv/lib/python2.7/site-packages (from setuptools>=3.3->pydoop)
Requirement already satisfied: pyparsing in ./venv/lib/python2.7/site-packages (from packaging>=16.8->setuptools>=3.3->pydoop)
Building wheels for collected packages: pydoop
Running setup.py bdist_wheel for pydoop ... error
@vishwakarma
vishwakarma / latency.markdown
Created June 22, 2020 22:36 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
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

class Solution {
public List<String> removeInvalidParentheses(String s) {
List<String> result = new ArrayList<>();
int maxLen = -1;
Set<String> visited = new HashSet<>();
Queue<String> queue = new LinkedList<>();
queue.add(s);
visited.add(s);
while (!queue.isEmpty()) {
0 -> [1,2]
2 -> [3,4]
(currentNode, currentPath, paths)
0, "", []
-> {1,2}
-> (1, 0, [])
-> XXXXXX paths = [01]
-> (2, 0, [01])
-> {3,4}
@vishwakarma
vishwakarma / latency.txt
Created July 5, 2020 21:59 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
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
(<_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "The caller does not have permission"
debug_error_string = "{"created":"@1595520430.751834000","description":"Error received from peer ipv6:[2a00:1450:400e:80c::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"The caller does not have permission","grpc_status":7}"
>, <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "The caller does not have permission"
debug_error_string = "{"created":"@1595520430.751834000","description":"Error received from peer ipv6:[2a00:1450:400e:80c::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"The caller does not have permission","grpc_status":7}"
>, errors {
error_code {
class Solution {
public void findSecretWord(String[] wordlist, Master master) {
Random random = new Random();
for (int i = 0; i < 10; i++) {
int idx = random.nextInt(wordlist.length);
String word = wordlist[idx];
int guess = master.guess(word);
if (guess == 6) {
break;
}