Skip to content

Instantly share code, notes, and snippets.

View ruyaoyao's full-sized avatar
❣️

Shiny ruyaoyao

❣️
View GitHub Profile
@ruyaoyao
ruyaoyao / common.yml
Created February 2, 2017 08:11 — forked from akurkin/common.yml
ROSI docker-compose.yml
#
# Shared definition of ruby microservice
#
microservice:
command: "runsvdir /etc/service"
environment:
PORT: 3000
RAILS_ENV: development
SERVICE_PLATFORM: "mia"
ports:
@ruyaoyao
ruyaoyao / helpers.js
Created November 4, 2016 02:39
Disable selected remote methods on Loopback
module.exports.disableAllMethods = function disableAllMethods(model, methodsToExpose)
{
if(model && model.sharedClass)
{
methodsToExpose = methodsToExpose || [];
var modelName = model.sharedClass.name;
var methods = model.sharedClass.methods();
var relationMethods = [];
var hiddenMethods = [];
@ruyaoyao
ruyaoyao / 0-model-override.js
Created November 4, 2016 01:41 — forked from spencermefford/0-model-override.js
An alternative to extending Loopback's built in models. In our application, we wanted to create a custom role called "ecm-administrator" that would have the ability to create and manage users.
module.exports = function (app) {
var _ = require('lodash');
var User = app.models.User;
var Role = app.models.Role;
var RoleMapping = app.models.RoleMapping;
var ACL = app.models.ACL;
/*
* Configure ACL's
*/
@ruyaoyao
ruyaoyao / gist:189db73f8ac775e6b2aed7bed3614362
Created October 20, 2016 07:18 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
@ruyaoyao
ruyaoyao / container.js
Created October 19, 2016 05:23 — forked from pulkitsinghal/container.js
Hooks for loopback file storage: after/before uploads, downloads etc.
/**
* Want to search github for sample code?
* Use the following `search criteria` in the github.com `search box` and then select `Code` from the search results:
* container upload remote language:javascript path:/common/models
*/
module.exports = function(Container) {
Container.beforeRemote('**', function(ctx, unused, next) {
console.log('4: good');
console.log('5: ctx.methodString', ctx.methodString);
@ruyaoyao
ruyaoyao / onblur.jsx
Created October 7, 2016 09:22 — forked from pstoica/OnBlurComponent.jsx
onBlur for entire react component
var HelloMessage = React.createClass({
render: function() {
return <div tabIndex="1" onBlur={this.onBlur}>
Hello <input type="text" value="wat"/>
</div>;
},
onBlur: function(e) {
var currentTarget = e.currentTarget;
@ruyaoyao
ruyaoyao / app.jsx
Created October 3, 2016 01:18 — forked from insin/app.jsx
React Form Handling - handleFormInputChange (Live version: http://bl.ocks.org/insin/raw/082c0d88f6290a0ea4c7/)
var INPUT_TYPES = 'color|date|datetime|datetime-local|file|month|number|password|range|search|tel|text|time|url|week'.split('|')
var App = React.createClass({
getInitialState: function() {
return {}
},
onChange: handleFormInputChange,
render: function() {
@ruyaoyao
ruyaoyao / jenkins-notes.md
Created September 28, 2016 04:54 — forked from misterbrownlee/jenkins-notes.md
Jenkins setup

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@ruyaoyao
ruyaoyao / iterm2-solarized.md
Created September 26, 2016 05:31 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font (OS X / macOS)

Solarized

@ruyaoyao
ruyaoyao / the-bind-problem.jsx
Created September 14, 2016 02:33 — forked from Restuta/the-bind-problem.jsx
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));