Skip to content

Instantly share code, notes, and snippets.

View josmardias's full-sized avatar

Josmar Dias josmardias

  • moises.ai
  • Vitória - ES, Brazil
View GitHub Profile
(async () => {
// logs to just to make sure that stuff is really asynchronous
// setInterval(() => console.log('--'), 200)
function iterWrap(iter) {
return {
take: (n = 100) => {
function* limitedGenerator() {
for(let i = 0; i < n; i++) {
@josmardias
josmardias / setTimeout-nashorn.js
Last active August 23, 2023 21:12 — forked from salomvary/settimeout-nashorn.js
setTimeout polyfill for Nashorn
// https://gist.github.com/josmardias/20493bd205e24e31c0a406472330515a
// at least one timeout needs to be set, larger then your code bootstrap
// or Nashorn will run forever
// preferably, put a timeout 0 after your code bootstrap
(function(context) {
'use strict';
var Timer = Java.type('java.util.Timer');
var Phaser = Java.type('java.util.concurrent.Phaser');
@josmardias
josmardias / create_postgres_docker.sh
Last active August 29, 2015 14:22
create postgres docker container
#!/usr/bin/env bash
VOLUME_NAME="test-postgres-data"
CONTAINER_NAME="test-postgres9.4"
PGPASSWORD="password"
DATABASE="test"
(
echo -e "\ncreating persistent volume...\n";
docker create -v /var/lib/postgresql/data --name $VOLUME_NAME busybox
@josmardias
josmardias / .bashrc
Last active August 29, 2015 14:18
Prevent multiple entries on ~/.bashrc
# fix multiple entries when .bashrc is sourced multiple times
if [ -z "$ORIGINAL_PATH" ]; then
export ORIGINAL_PATH="$PATH"
fi
if [ -z "$ORIGINAL_MANPATH" ]; then
export ORIGINAL_MANPATH="$MANPATH"
fi
if [ -z "$ORIGINAL_INFOPATH" ]; then
export ORIGINAL_INFOPATH="$INFOPATH"
fi
@josmardias
josmardias / classes_howto.js
Last active August 29, 2015 14:04
How to create objects from the same "class" in javascript.
console.log("----------------------------------------------------------");
console.log("-- first of all, in JS, functions can be used as is, or called from objects");
var myf = function () {
return 1;
};
// as function
console.log(myf());
//as object method
@josmardias
josmardias / odeskteam Fedora 20
Last active January 3, 2016 09:29
How to install odeskteam in Fedora 20
1) Install ATrpms repository (http://atrpms.net/)
sudo rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
echo '
[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/f$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1' | sudo tee /etc/yum.repos.d/atrpms.repo
@josmardias
josmardias / gist:6029662
Created July 18, 2013 14:12
salt-boostrap
$ curl -L http://bootstrap.saltstack.org | sudo sh -s -- -D -M -N git v0.15.3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 256 100 256 0 0 288 0 --:--:-- --:--:-- --:--:-- 1273
0 256 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 * INFO: PIPED THROUGH sh -- Version 1.5.5
* INFO: System Information:
* INFO: CPU: GenuineIntel
* INFO: CPU Arch: x86_64
* INFO: OS Name: Linux