Skip to content

Instantly share code, notes, and snippets.

Eyal Arubas EyalAr

Block or report user

Report or block EyalAr

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
@EyalAr
EyalAr / README.md
Last active Aug 29, 2015
Benchmarks of various nested loops control flow mechanisms in Javascript
View README.md

MDN recommends NOT to use labels in Javascript, and instead use exceptions or functions. But turns out labels are the fastest, closely followed by named functions.

Test case: Run two nested loops. The inner loop needs to continue the outer loop upon some condition.

Tests:

  1. Using named loops with labels.
@EyalAr
EyalAr / README.md
Last active Aug 29, 2015
TroopJS data-weave inside template bug - multiple widget instances are created for elements
View README.md

To run:

  1. Clone this gist
  2. bower install
  3. Serve index.html
  4. Open developer tools inspector
  5. First <li> element has 4 widget instances attached; second had 3, etc.
@EyalAr
EyalAr / error_demo.go
Last active Aug 29, 2015
Go + ZeroMQ ROUTER socket concurency problem demo
View error_demo.go
// This is a demonstration for a ROUTER socket which is used concurrently
// by two different threads. One to receive messages and one to send.
// Running this program will cause a panic because ZeroMQ sockets are not
// threads-safe.
package main
import (
"fmt"
zmq "github.com/pebbe/zmq4"
@EyalAr
EyalAr / dbcopy.sh
Last active Aug 29, 2015
Export from one mongo database into another
View dbcopy.sh
#!/usr/bin/env bash
#https://gist.github.com/EyalAr/4bc6524c3c9ae6af33a9
SOURCE_HOST=127.0.0.1
SOURCE_DB=dev
TARGET_HOST=127.0.0.1
TARGET_DB=stage
@EyalAr
EyalAr / conf.example.js
Last active Aug 29, 2015
Generic configuration parser for my Node.js projects. Allows to override selectively with environment variables.
View conf.example.js
module.exports = {
key1: 'foo',
key2: {
subkey1: 'foo',
subkey2: {
subsubkey1: 'foo',
// ...
}
}
}
View gist:22747ffd69d89d095fc4
export PS1='[\[\033[0;95m\]\#\[\033[0m\]][\[\033[0;35m\]\!\[\033[0m\]] \[\033[0;36m\]\u\[\033[0m\]:\[\033[0;32m\]\W\[\033[0m\]\[\033[0;33m\]$(declare -F __git_ps1 &>/dev/null && __git_ps1 ":%s")\[\033[0m\]\[\033[0;31m\]$\[\033[0m\] '
View Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme",
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
"font_face": "SourceCodePro-light",
"font_size": 15,
"caret_extra_width": 1,
"caret_style": "phase",
"ignored_packages": [
@EyalAr
EyalAr / batch_export.sh
Last active Aug 29, 2015
Shell script to easily export mongo collections into JSON files
View batch_export.sh
#!/usr/bin/env bash
#https://gist.github.com/EyalAr/67791f51fce51ed55594
COLLECTIONS=()
HOST="127.0.0.1"
PORT="27017"
DB=
if [ -n "$1" -a "$1" = "--help" ]
@EyalAr
EyalAr / 1.generator_example.js
Created May 9, 2014
Code snippets for Javascript generators and asynchronous code presentation. Based on http://eyalarubas.com/javascript-generators-and-callbacks.html
View 1.generator_example.js
// generate a series of even numbers,
// but be able to to reverse the order of iteration
function * generateEvens(start) {
var dir = 1; // up
if (start % 2 !== 0) start++;
while (true) {
var tmp = yield start;
if (tmp === 'up') dir = 1;
if (tmp === 'down') dir = -1;
@EyalAr
EyalAr / count_words_in_selection.py
Last active Aug 4, 2019
Count words in selection - plugin for Sublime Text 3. Full blog post: http://eyalarubas.com/count-words-in-sublime-text-3.html
View count_words_in_selection.py
import sublime, sublime_plugin, re
class CountWordsInSelectionCommand(sublime_plugin.EventListener):
def on_selection_modified(self, view):
'''
listen to event 'on_selection_modified' and count words in all selected
regions when invoked.
'''
You can’t perform that action at this time.