Skip to content

Instantly share code, notes, and snippets.

Sam Pullara spullara

Block or report user

Report or block spullara

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@spullara
spullara / profile.svg
Last active Sep 3, 2019
Profile of javac 11 compiling 155 classes, 42000 loc
View profile.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View jlink
View bitsquatting.log
/var/log/httpd/cloudfront_log:"d1wh43egtz3cgo.clgudfront.net" 116.12.133.146 - - [22/Aug/2011:00:32:55 +0000] "GET /bulk_images/69632/banner-small-planet-holiday-batam.jpg HTTP/1.1" 404 348 "http://36ohk6dgmcd1n.yom.mail.yahoo.net/om/api/1.0/openmail.app.invoke/36ohk6dgmcd1n/4/1.0.35/sg/en-SG/view.html" "Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20100101 Firefox/6.0"
/var/log/httpd/cloudfront_log:"d3dtik4dz1nejo.cloedfront.net" 208.80.194.29 - - [22/Aug/2011:17:27:58 +0000] "GET /75.html HTTP/1.0" 404 300 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; YPC 3.0.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
/var/log/httpd/cloudfront_log:"doug1izaerwt3.cloutfront.net" 76.94.217.102 - - [23/Aug/2011:05:02:10 +0000] "GET /icons/apache_pb2.gif HTTP/1.1" 200 1797 "http://doug1izaerwt3.cloutfront.net/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
/var/log/httpd/cloudfront_log:"doug1izaerwt3.cloutfront.net" 76.94.217.102 - - [23/Aug/2011:05:02:10 +00
@spullara
spullara / App.java
Created Jul 30, 2018
Comparing Java Fibers vs ForkJoinPool - performance of FJP is 60% faster than Fibers are currently and use less memory
View App.java
package com.sampullara.fibers;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;
public class App {
public static final int NUM = 100_000_000;
View Pauses.java
Timer timer = mr.timer("jvm.pausetime");
new Thread(() -> {
while (true) {
long start = System.nanoTime();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// ignore
}
long diff = System.nanoTime() - start;
@spullara
spullara / main.swift
Created Mar 24, 2018
Swift implementation of my interview code
View main.swift
func render(text: String, entities: Set<Entity>) -> String {
let entityArray = Array(entities).sorted()
var sb = String()
var pos = 0
var posIndex = text.startIndex
for entity in entityArray {
let startIndex = text.index(posIndex, offsetBy: entity.start - pos)
sb.append(contentsOf: text[posIndex ..< startIndex])
sb += entity.html
View gist:6489b1704e51d75190f94be3ead3154a
-> /resolve com.fasterxml.jackson.core:jackson-databind:2.8.7
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar added to classpath
| Path /Users/sam/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar added to classpath
-> var mf = new com.fasterxml.jackson.databind.MappingJsonFactory()
| Added variable mf of type com.fasterxml.jackson.databind.MappingJsonFactory with initial value com.fasterxml.jackson.databind.MappingJsonFactory@1a482e36
-> var jp = mf.createJsonParser("{\"foo\":\"bar\"}")
| Added variable jp of type com.fasterxml.jackson.core.JsonParser with initial value com.fasterxml.jackson.core.json.ReaderBasedJsonParser@689604d9
@spullara
spullara / SlowInputStream.java
Created Nov 15, 2017
Read it more slowly so as not to overload the system
View SlowInputStream.java
public class SlowInputStream extends BufferedInputStream {
private final long start;
private final double rate;
private long read;
@Override
public synchronized int read(byte[] b, int off, int len) throws IOException {
maybeWait();
int bytes = super.read(b, off, len);
read += bytes;
@spullara
spullara / Render.java
Last active Jan 14, 2017
Comparing performance between Java and Swift
View Render.java
public CharSequence render(String text, Set<Entity> entities) {
StringBuilder sb = new StringBuilder(256);
Entity[] array = entities.toArray(new Entity[entities.size()]);
Arrays.sort(array);
int pos = 0;
int codePointPosition = 0;
for (Entity entity : array) {
int start = text.offsetByCodePoints(pos, entity.start - codePointPosition);
sb.append(text, pos, start);
sb.append(entity.html);
@spullara
spullara / ArchiveMail.gs
Created May 2, 2016
This looks for all mail labeled "To be archived" that is older than 1 day, archives it and removes the label.
View ArchiveMail.gs
function archiveMail() {
var delayDays = 1 // Enter # of days before messages are archived
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays);
var label = GmailApp.getUserLabelByName("To be archived");
if (label != null) {
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
if (threads[i].getLastMessageDate()<maxDate) {
You can’t perform that action at this time.