Skip to content

Instantly share code, notes, and snippets.

View brikis98's full-sized avatar

Yevgeniy Brikman brikis98

View GitHub Profile
@brikis98
brikis98 / echo.js
Last active February 15, 2019 19:30
Echo server in socket.io
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
console.log("Someone just connected!");
// Echo back messages from the client
socket.on('message', function (message) {
console.log("Got message: " + message);
socket.emit('message', message);
});
@brikis98
brikis98 / gist:1024230
Created June 14, 2011 03:08
Java GC log explanation (Young Generation collections)
{Time since VM started, in seconds}: [GC {Time since VM started}: [{GC type}
Desired survivor size {size of one survivor space} bytes, new threshold {y} (max {x}) <- how many collections objects can stay in the young gen. More on this later
- age 1: {a} bytes, {a} total <- How many objects have survived one collection. Next collection, any surviving objects will appear in age 2
- age 2: {b} bytes, {a+b} total
: {pre-collection young gen[5] usage}K->{post-collection young gen usage}K({Total young gen size}K), {young gen time} secs]
{pre-collection heap size}K->{post-collection heap size}K({total heap size}K), {total collection time} secs]
@brikis98
brikis98 / gist:e71d6c736158080968f5
Created April 16, 2015 19:34
Getting a sorted list of tags in Jekyll with no plugins
{% capture tags %}{% for tag in site.tags %}{{ tag[0] }}|{% endfor %}{% endcapture %}
{% assign sortedtags = tags | split:'|' | sort %}
{% for tag in sortedtags %}
<a name="{{ tag }}"></a>
<h2>{{ tag }}</h2>
<ul>
{% for post in site.tags[tag] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
@brikis98
brikis98 / gist:1024235
Created June 14, 2011 03:11
Java GC log explanation (CMS)
{Time since VM started, in seconds}: [GC
[1 CMS-initial-mark: {estimated old gen usage}K({total old gen size}K)] {estimated heap usage}K({total heap size}K), {pause time} secs]
{Time since VM started, in seconds}: [Rescan (parallel) , {pause time} secs]
{Time since VM started, in seconds}: [weak refs processing, {pause time} secs]
[1 CMS-remark: {old gen usage}K({total old gen size}K)] {heap usage}K({total heap size}K), {pause time} secs]
{Time since VM started, in seconds}: [CMS-concurrent-reset: 0.019/0.019 secs]
@brikis98
brikis98 / gist:1024233
Created June 14, 2011 03:10
Java GC log example (CMS)
294989.748: [GC
[1 CMS-initial-mark: 1782676K(2097152K)] 1784501K(3137664K), 0.0067714 secs]
295047.329: [Rescan (parallel) , 0.2497803 secs]
295047.579: [weak refs processing, 0.1272999 secs]
[1 CMS-remark: 1782929K(2097152K)] 2303079K(3137664K), 0.3816787 secs]
295049.065: [CMS-concurrent-reset: 0.019/0.019 secs]
@brikis98
brikis98 / gist:1024228
Created June 14, 2011 03:07
Java GC log example (Young Generation collections)
325209.429: [GC 325209.429: [ParNew
Desired survivor size 4128768 bytes, new threshold 2 (max 2)
- age 1: 1812544 bytes, 1812544 total
- age 2: 305568 bytes, 2118112 total
: 1034582K->2103K(1040512K), 0.0116910 secs]
2598263K->1565814K(3137664K), 0.0118312 secs]
@brikis98
brikis98 / framework.html
Created July 22, 2011 22:57
Getting started with LinkedIn API's
<!-- Add the following to the head of your webpage: -->
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: your_api_key_goes_here
</script>
@brikis98
brikis98 / script.js
Last active March 7, 2018 00:15
Get course summary from Teachable
var result = $('.section-item .item').get().reduce(function(total, item) {
var text = $(item).text().split("\n").join(" ");
var matches = /.+\((\d):(\d\d)\)/g.exec(text);
var minutes = parseInt(matches[1]);
var seconds = parseInt(matches[2]);
var totalMin = total[0] + minutes;
var totalSec = total[1] + seconds;
@brikis98
brikis98 / CacheFilter.scala
Last active August 4, 2017 22:22
An outline of how to de-dupe remote service calls in Play.
// Put this filter early in your filter chain so it can initialize and clean up
// the cache
object CacheFilter extends Filter {
def apply(next: RequestHeader => Future[Result])(request: RequestHeader): Future[Result] = {
def init = RestClient.initCacheForRequest(request)
def cleanup = RestClient.cleanupCacheForRequest(request)
// You have to be very careful with error handling to garauntee the cache gets cleaned
// up, or you'll have a memory leak.
@brikis98
brikis98 / factorial.prolog
Created February 12, 2012 02:41
Seven Languages in Seven Weeks: Prolog, Day 2
fact(0, 1).
fact(N, Out) :- N > 0, N1 is N - 1, fact(N1, Prev), Out is N * Prev.