Skip to content

Instantly share code, notes, and snippets.

View highercomve's full-sized avatar
🏠
Working from home for Pantacor 👍

Sergio Marin highercomve

🏠
Working from home for Pantacor 👍
View GitHub Profile
const _tap = function _tap(input) {
return new Tap(input);
}
class Tap {
constructor(value) {
this.value = value
}
valueOf () {
return this.value

testing same problem speed

Take and array and remove the first element, keep the next one, remove the third and continue in that way until you have only one element in the array, example:

start with [1,2,3,4,5,6]

remove 1, keep 2, remove 3, keep 4, remove 5, keep 6, remove 2, keep 4, remove 6, then return 4.

  • remover [1,2,3] => 2
  • remover [1,2,3,4] => 4

A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such that 0 ≤ P < N and the sum of elements of lower indices is equal to the sum of elements of higher indices, i.e. A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] + A[N−1]. Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1.

For example, consider the following array A consisting of N = 8 elements:

A[0] = -1 A[1] = 3 A[2] = -4 A[3] = 5

@highercomve
highercomve / other_type_of_permutation.js
Created December 10, 2015 06:53
JS Array permutation
function permute(arr) {
if (arr.length === 2) {
return [arr.slice(), arr.slice().reverse()]
}
return arr.map(function(element, index, array) {
var new_array = array.slice()
var last_element = new_array.splice(index, 1)
return permute(new_array).map(function(x) {
return last_element.concat(x)
@highercomve
highercomve / genymotionwithplay.txt
Created March 30, 2016 19:56 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
@highercomve
highercomve / base_gateway_api.rb
Created May 5, 2016 03:38
Ruby example files
module Gateways
class Base
class << self
def find_all_and_update
raise NotImplementedError
end
def create
raise NotImplementedError
end

A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.

Array A contains only 0s and/or 1s:

0 represents a car traveling east, 1 represents a car traveling west. The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P is traveling to the east and Q is traveling to the west.

For example, consider array A such that:

@highercomve
highercomve / object_resolve.js
Last active March 11, 2019 20:37
Object path resolution even thought some part get undefined
function resolve (obj, path, defaultReturn) {
return path.split('.').reduce(function(prev, curr) {
return prev && prev.hasOwnProperty(curr) ? prev[curr] : defaultReturn
}, obj)
}
@highercomve
highercomve / docker-compose-daemon.sh
Created October 10, 2016 16:14 — forked from domachine/docker-compose-daemon.sh
run docker-compose in daemon mode and attach to web container
docker-compose up -d
docker attach myapp_web_1

I am deploying with this IAM using Codeship and Circle CI to Elastic Beanstalk. I had a lot of trouble with this config. I talked to the aws support for about 6 hours until this worked properly, so, I guess it is worth to share.

UPDATE: In the end, I have to use the AWSElasticBeanstalkFullAccess policy. My custom policy keep breaking every week with some new added permission or some EB internal change. Anyway, the IAM I was using is below.

This works for me with CircleCI and EB Cli.

{
    "Version": "2012-10-17",
    "Statement": [
        {