Skip to content

Instantly share code, notes, and snippets.

View Rolilink's full-sized avatar

Rolando Perez Rolilink

View GitHub Profile
var model1 = new Model();
var model2 = new Model();
model1.save(); // Kinda slow
doSomething(model1);
model2.save(); // Kinda slow
doSomething(model2);
var model1 = new Model();
var model2 = new Model();
model1.save(function(){
doSomething(model1); // get executed only when model1 is saved
}); // Kinda slow
model2.save(function(){
doSomething(model2); // get executed only when model2 is saved
}); // Kinda slow
@Rolilink
Rolilink / test.js
Created October 1, 2015 20:21
voyage class
'use strict';
var expect = require('chai').expect;
var Voyage = require('../../lib/resources/voyage.js');
var _ = require("underscore");
describe('Voyage Class', function(){
it('should have a method called getVoyages', function(){
expect(Voyage.getVoyages).to.be.a('function');
# Saving a product from database
product = ShopifyAPI::Product.find(179761209) # This does an get http request to shopify api
db_product = DBProduct.new # You have to create a new rails model
db_product.shopify_id = product.id
db_product.save
# Saving a product to shopify
product.title = 'changed'
product.save # updates product in shopify, http put request
{
"answer": {
"text": "Persona a tu izquierda.",
"type": "answer",
"id": 116,
"answers": 0
},
"keen": {
"timestamp": "2017-07-26T03:16:18.688Z",
"created_at": "2017-07-26T03:16:18.688Z",
{
total: 151540, // esto es accountBalance
funds:
[
{ category: 'userFunds', amount: 9000 },
{ category: 'pendingPayments', amount: 6000 },
{ category: 'workingCapital', amount: 60770 }
],
lastUpdated: 2017-08-02T21:06:35.700Z,
numericFormat: 'pennies',
const sum = (n1, n2) => (n1 + n2);
describe('#sum', () => {
it('should add both numbers', () => {
expect(sum(1,2)).toMatchSnapshot();
});
});
import React from 'react';
import PropTypes from 'prop-types';
import ListGroup from 'react-bootstrap/lib/ListGroup';
export default class List extends React.Component {
static propTypes = {
renderListItem: PropTypes.func.isRequired,
items: PropTypes.arrayOf(PropTypes.any).isRequired,
className: PropTypes.string,
}
@Rolilink
Rolilink / LoginForm.jsx
Created October 4, 2017 20:37
LoginForm
import React from 'react';
import PropTypes from 'prop-types';
export const getDefaultState = (
{
username = '',
password = '',
shouldRememberUser = false,
error = null,
} = {}
@Rolilink
Rolilink / docker-compose.yml
Last active April 26, 2020 21:57
Initial Architecture
version: '3'
services:
cats-mongo:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: mongo
MONGO_INITDB_ROOT_PASSWORD: mongo
MONGO_INITDB_DATABASE: cats
volumes:
- cats_mongodb_data:/data/db