Skip to content

Instantly share code, notes, and snippets.

View ecmadao's full-sized avatar
🚶‍♂️
Travel around the world

ecmadao ecmadao

🚶‍♂️
Travel around the world
View GitHub Profile
@ecmadao
ecmadao / Django Mock Request Object.py
Created August 2, 2016 00:08 — forked from tschellenbach/Django Mock Request Object.py
Fake django requests for testing purposes
from django.core.handlers.base import BaseHandler
from django.test.client import RequestFactory
class RequestMock(RequestFactory):
def request(self, **request):
"Construct a generic request object."
request = RequestFactory.request(self, **request)
handler = BaseHandler()
handler.load_middleware()
for middleware_method in handler._request_middleware:
@ecmadao
ecmadao / introrx.md
Created November 14, 2016 12:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as a legal DOM attribute/property. You should ensure that your DOM elements do not have spurious props floating around.

There are a couple of likely reasons this warning could be appearing:

  1. Are you using {...this.props} or cloneElement(element, this.props)? Your component is transferring its own props directly to a child element (eg. https://facebook.github.io/react/docs/transferring-props.html). When transferring props to a child component, you should ensure that you are not accidentally forwarding props that were intended to be interpreted by the parent component.

  2. You are using a non-standard DOM attribute on a native DOM node, perhaps to represent custom data. If you are trying to attach custom data to a standard DOM element, consider using a custom data attribute (https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes).

  3. React does not yet reco

@ecmadao
ecmadao / render-react-with-rxjs.md
Created November 26, 2016 06:16 — forked from zxbodya/render-react-with-rxjs.md
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

@ecmadao
ecmadao / browser.js
Created January 23, 2017 15:40 — forked from nolanlawson/browser.js
Example Browserify and Webpack output, split index.js and browser.js
module.exports = function (string) {
return btoa(string);
};

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

@ecmadao
ecmadao / starcounter.js
Created February 21, 2017 01:03 — forked from yyx990803/starcounter.js
Count your total stars!
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
console.log(res.message)
return
}
var pages = Math.ceil(res.public_repos / 100),
@ecmadao
ecmadao / github.js
Created March 26, 2017 03:53 — forked from fat/github.js
simple basic-auth node github api
// Simple Use:
// ----------
// github('/user/repos', callback);
// github('/repos/:user/:repo/issues', { user: user, repo: repo }, callback);
var request = require('request');
var querystring = require('querystring');
var github = function (path, options, callback) {
var username = 'username';
@ecmadao
ecmadao / materialDesignShadowHelper.less
Created April 24, 2017 14:44 — forked from gefangenimnetz/materialDesignShadowHelper.less
Less css box-shadow helper for cards & modals according to Googles Material Design spec.
/**
* A mixin which helps you to add depth to elements according to the Google Material Design spec:
* http://www.google.com/design/spec/layout/layout-principles.html#layout-principles-dimensionality
*
* Please note that the values given in the specification cannot be used as is. To create the same visual experience
* the blur parameter has to be doubled.
*
* Author: Florian Kutschera (@gefangenimnetz), Conceptboard GmbH (@conceptboardapp)
*
* Example usage:
@ecmadao
ecmadao / eleme.py
Created May 5, 2017 01:41 — forked from SaulLawliet/eleme.py
查询饿了么品牌馆中有哪些是 <真·五折>
# coding: utf-8
import requests, json, re
# 替换成你自己的经纬度数据
# 查询方式 打开饿了么官网 -> 开发者模式 -> 输入送餐地址 -> 观察请求 -> 找到经纬度数据
latitude=31.23978
longitude=121.49968
URL_TEMPLATE="https://mainsite-restapi.ele.me/shopping/restaurants?\
latitude={}&\