Skip to content

Instantly share code, notes, and snippets.

View ronsuez's full-sized avatar

Ronald Suez ronsuez

View GitHub Profile
function shouldIkeepSomethingInReactState() {
if (canIcalculateItFromProps()) {
// Don't duplicate data from props in state.
// Calculate what you can in render() method.
return false;
}
if (!amUsingItInRenderMethod()) {
// Don't keep something in the state
// if you don't use it for rendering.
@ronsuez
ronsuez / gist:0867af9819a5bf7e15d7c5f6dd03b6e0
Last active April 15, 2017 18:35
IOs Simulator commands from OSX cli
#Show Devices
ios-sim showdevicetypes
@ronsuez
ronsuez / gh-pages-deploy.md
Created April 4, 2017 18:39 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@ronsuez
ronsuez / after.php
Last active April 4, 2017 18:51
php-code-refactoring-challenge
<?php
public function post_confirm(Request $request) {
//validate the requrest params
$this->validate($request, [
'service_id' => 'required|integer',
'driver_id' => 'required|integer',
]);
//take only the specified values from the request
@ronsuez
ronsuez / api.js
Created April 1, 2017 17:35 — forked from killercup/api.js
Streamed CSV Export using node-restify and mongoose
/**
* # Some Demo API Service
*/
var restify = require('restify');
var map = require('map-stream');
var csvify = require('../helpers/csvify');
var Team = require("../models").Team;
@ronsuez
ronsuez / Place.js
Created March 21, 2017 23:48 — forked from PascalAnimateur/Place.js
Geospatial example in Sails.js using native MongoDB query
/* Place model */
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
@ronsuez
ronsuez / Dockerrun.aws.json
Created March 15, 2017 03:47 — forked from philipithomas/Dockerrun.aws.json
Staffjoy Elastic Beanstalk Deploy Script
{
AWSEBDockerrunVersion: "1",
Authentication: {
Bucket: "staffjoy-deploy",
Key: "docker.cfg"
},
Image: {
Name: "staffjoy/app:TAG",
Update: "true"
},
@ronsuez
ronsuez / watching.service.variables.js
Last active January 8, 2017 01:24
watching.service.variables.js
//Service
(function() {
'use strict';
angular
.module('module')
.factory('myService', factory);
factory.$inject = ['$http', '$q'];
#!/usr/bin/env python
import hashlib
import hmac
import time
import requests
import datetime
# Q. Do you have A Websocket API?
# A. Yes, and we strongly recommend you to use it. Please, check our JavaScript websocket implementation for our WebSocket API here:
# https://github.com/blinktrade/frontend/blob/master/jsdev/bitex/api/bitex.js
//put here
var getDistance = function(p1, p2) {
var R = 6378137; // Earth’s mean radius in meter
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(rad(p1.lat())) Math.cos(rad(p2.lat()))
Math.sin(dLong / 2) * Math.sin(dLong / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));