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
import org.apache.lucene.analysis.standard.StandardAnalyzer; | |
import org.apache.lucene.document.Document; | |
import org.apache.lucene.document.Field; | |
import org.apache.lucene.document.StringField; | |
import org.apache.lucene.index.DirectoryReader; | |
import org.apache.lucene.index.IndexWriter; | |
import org.apache.lucene.index.IndexWriterConfig; | |
import org.apache.lucene.index.Term; | |
import org.apache.lucene.search.BooleanClause; | |
import org.apache.lucene.search.BooleanQuery; |
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
// chromium plugin | |
(function() { | |
Notification.requestPermission(); | |
WebSocket.prototype._send = WebSocket.prototype.send; | |
WebSocket.prototype.send = function(data) { | |
this._send(data); | |
this.addEventListener('message', function(msg) { | |
console.log('>> ' + msg.data); | |
if (msg.data.includes("Presence")) { | |
var d = eval(msg.data.split(',').slice(1).join()); |
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 static void main(String[] args) { | |
long[] begin = new long[]{1504848555000L,1504867164000L,1504893887000L,1504893409000L,1504860962000L,1504881065000L,1504839844000L,1504890726000L}; | |
long[] end = new long[]{1504858555000L,1504869164000L,1504897887000L,1504896409000L,1504890962000L,1504981065000L,1504849844000L,1504990726000L}; | |
maxOverlap(begin, end); | |
} | |
/** | |
* You have time-stamps (mentioned as integers), which represents phone call begin and end to call center. | |
* find the number of overlaps in calls that suggests to add more call center agents. | |
*/ |
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
import com.maxmind.geoip2.DatabaseReader; | |
import com.maxmind.geoip2.exception.GeoIp2Exception; | |
import java.io.File; | |
import java.io.IOException; | |
import java.net.InetAddress; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import static java.nio.file.StandardOpenOption.*; |
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
# TODO refactor to function | |
sudo lsof -t -i:'8080' -sTCP:LISTEN # get process id that uses port 8080 | |
ps -p $PID # get process info | |
ps -o ppid= -p $PID # sometimes killing the PID will not work because it's a child process, this will get parent process | |
sudo kill -9 $PID # of course. killing the process | |
# .bashrc | |
alias kill_port='kill -9 $(lsof -t -i:'$0' -sTCP:LISTEN)' |
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
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.HttpClientBuilder; | |
import org.apache.tika.metadata.Metadata; | |
import org.apache.tika.parser.AutoDetectParser; | |
import org.apache.tika.parser.ParseContext; | |
import org.apache.tika.parser.Parser; | |
import org.apache.tika.sax.BodyContentHandler; |
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
import numpy as np | |
from matplotlib import pyplot as plt | |
y = [10, 20, 30, 40, 50, 52, 60, 70, 200] | |
x = np.random.uniform(low=1, high=200, size=(len(y),)) | |
min_sum, Y = sum(y), 0 | |
for cur_y in y: | |
cur_sum = 0 | |
for j in y: |
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
GCC_BIN=`xcrun --sdk iphoneos --find gcc` | |
SDK=`xcrun --sdk iphoneos --show-sdk-path` | |
#support iPhone 3GS and above, delete armv6 to avoid SDK error | |
ARCH_FLAGS=-arch armv7 -arch armv7s -arch arm64 | |
LDFLAGS =\ | |
-F$(SDK)/System/Library/Frameworks/\ | |
-F$(SDK)/System/Library/PrivateFrameworks/\ | |
-framework UIKit\ | |
-framework CoreFoundation\ |
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
""" | |
Riddle : | |
Room with 100 drawers each drawer contains a unique real number between 0..99 | |
First man gets into the room and can open all drawers but can switch drawers only once | |
Second man will enter afterwards and will be asked to find a random number in 50 attempts | |
Both men can talk only before first man will get in and decide on strategy | |
Whats the best strategy ? | |
""" | |
from random import shuffle | |
from turtle import Turtle, Screen |
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
<!DOCTYPE html> | |
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<style> | |
body { | |
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA |
OlderNewer