Skip to content

Instantly share code, notes, and snippets.

View u007's full-sized avatar
🏠
Working from home

James u007

🏠
Working from home
View GitHub Profile
@u007
u007 / StaticIframe.js
Last active October 19, 2017 16:24
react and iframe without rerendering
'use strict';
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
var input, wrapper
class StaticIframeComponent extends Component {
constructor(props) {
@u007
u007 / application.js
Last active October 12, 2017 04:30
underscore, moment, jquery in webpack
//underscore
global._ = require('underscore')
//jquery
window.$ = window.jQuery = require("jquery")
//moment
window.moment = require('moment')
@u007
u007 / select2.js
Last active April 6, 2017 16:54
react and select2
//taming select2
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
var input = null
class SelectFieldComponent extends Component {
componentDidMount() {
//UserRoleForm.onRendered()
@u007
u007 / action_signup.go
Last active April 14, 2017 10:11
go buffalo mailer
// actions/action_signup.go //in action handler file
import (
g "project/actions/shared"
"project/models"
"github.com/gobuffalo/buffalo"
// "github.com/pkg/errors"
// "fmt"
"project/actions/mailer/user"
)
@u007
u007 / app.go
Last active March 10, 2017 11:20
buffalo i18n locale
// in actions/app.go
/*
directory structure
app/
locales/en-us.yaml
assets/js/locales/
middleware/
actions/tools
*/
import(
@u007
u007 / README.md
Last active February 17, 2017 06:58
full git deployment with auto boot of puma for ruby on rails via rvm, with nightly restart of rails

SETTING UP

  • 1st, add production origin to git.
  • Next, ssh to remote and do a git init
  • Then on local git:
    • git pull production master
    • git push production master
func Auth(c *revel.Controller) bool {
if LoggedInCheck() {//write your own
return true
}
email, pass, _ := c.Request.BasicAuth()
//login n password
//TODO check login here
//...
bundle exec pumactl -P /home/project/rails/shared/tmp/pids/puma.pid restart as project@live.sitename.com
DEBUG [50915bef] Command: cd /home/project/rails/releases/20160919165940 && /usr/bin/env RAILS_ENV=production /usr/local/rvm/bin/rvm 2.3.1 do bundle exec pumactl -P /home/project/rails/shared/tmp/pids/puma.pid restart
DEBUG [50915bef] Puma starting in single mode...
DEBUG [50915bef]
DEBUG [50915bef] * Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
DEBUG [50915bef]
DEBUG [50915bef] * Min threads: 1, max threads: 2
DEBUG [50915bef]
DEBUG [50915bef] * Environment: production
DEBUG [50915bef]
# ruby
res = params.require(:table).permit(:field1,
table_sub_table_attributes: [:key_field_id, :id, :_destroy])
res[:table_sub_table_attributes] = reduce_params(res[:table_sub_table_attributes], :key_field_id)
# reduce delete to delete existing which is not selected
# and insert only when is not an existing
# does not handle updating existing (which is not used)
def reduce_params(attributes, key_field)
res = []
@u007
u007 / config - boot.rb
Last active July 24, 2016 13:14
fix for padrino with activerecord concern reload issue
Padrino::Reloader.module_eval do
def reload!
list = []
extras = []
rotation do |file|
next unless file_changed?(file)
list << file
end