Skip to content

Instantly share code, notes, and snippets.

WorkQueue = {
MAX_CONCURRENT: 2,
init: function() {
this.num_working = 0;
this.items = [];
},
push: function(item) {
this.items.push(item);
this.update()
},
require 'benchmark'
Benchmark.bmbm do |x|
x.report('Break') do
1_000_000.times do
loop { break }
end
end
For Jeff n Kelly 💝
require 'mysql2'
p Mysql2::VERSION # Make sure mysql2 version >= 0.3.12
Encoding::default_internal = Encoding::UTF_8
Encoding::default_external = Encoding::UTF_8
s = 'Test emoji 💝' # text with emoji character
c = Mysql2::Client.new(username: 'root', database: 'test', encoding: 'utf8mb4')
c.query("INSERT INTO test(`text`) VALUES('#{c.escape(s)}')")
@jacobdam
jacobdam / __extend__.js
Created December 31, 2014 04:01
JS OOP
__hasProp = {}.hasOwnProperty;
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key))
child[key] = parent[key];
}
function ctor() {
this.constructor = child;
@jacobdam
jacobdam / gist:184e99819841bcf903ce
Created May 5, 2015 08:02
Lazy-lize class loading dependency
# bad
class Book
belongs_to :categoy, :class_name => BookCategory
end
# good
class Book
belongs_to :categoy, :class_name => 'BookCategory'
end
@jacobdam
jacobdam / designer.html
Last active August 29, 2015 14:21
designer
<link rel="import" href="../cool-clock/cool-clock.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../speech-mic/speech-mic.html">
<polymer-element name="my-element">
<template>
<style>
:host {

Keybase proof

I hereby claim:

  • I am jacobdam on github.
  • I am jacobdam (https://keybase.io/jacobdam) on keybase.
  • I have a public key ASCqbyQsbLyw2j7iTMqfURPdzMo1025YtuC5Lh9HRbP0tQo

To claim this, I am signing this object:

class AuthService extends EventEmitter {
async initialize(){
this.accessToken = res['access_token'];
this._checkTokenExpiration();
// ...
}
isSignedIn(){
return !!this.accessToken;