Skip to content

Instantly share code, notes, and snippets.

View alexblom's full-sized avatar

Alex Blom alexblom

View GitHub Profile
@alexblom
alexblom / memory-leak.js
Created January 28, 2016 18:34
Sample JS Memory Leak
var node = $("#node");
var nodeAgain = $("#node");
var body = $("body");
body.removeChild(node);
node = null;
nodeAgain = null;
@alexblom
alexblom / firefox-extension-adapter.js
Created January 25, 2015 19:35
Ember Data Adapter (HTTP Request Handling) for Firefox Extension /w Add-on SDK
import Ember from "ember";
import DS from 'ember-data';
export default DS.ActiveModelAdapter.extend({
ajax: function(url, type, hash) {
var browser, adapter;
adapter = this;
return new Ember.RSVP.Promise(function(resolve, reject) {
var options = {};
@alexblom
alexblom / nginx
Last active August 8, 2019 03:13
Golang Websocket Nginx
#Golang Websocket Server
server {
listen 8080;
server_name wss.morse.io;
access_log /var/log/nginx/access_log.log;
error_log /var/log/nginx/error.log;
#ssl config
ssl on;
#Cert Info
type MemberInitFunction func() (interface{}, error)
type ConnectionPool struct {
size int
conn chan interface{}
}
func (p *ConnectionPool) Init(size int, initFn MemberInitFunction) error {
p.conn = make(chan interface{}, size)
for i := 0; i < size; i++ {
conn, err := initFn()
@alexblom
alexblom / string_concatenation.rb
Last active December 11, 2015 07:59
Ruby string concatenation does not break assignment, which can lead to unexpected results
# When assigning string a = string b, Ruby simply makes string b a *ptr to string a
# The generic string a += string b will convert string b to a new object
# String concatenation (a.concat(b), a << b) will not, leading to unexpected values for a
#Initialize first and last name
1.9.3p125 :002 > first_name = "Alex"
=> "Alex"
1.9.3p125 :003 > last_name = " Blom"
=> " Blom"