Skip to content

Instantly share code, notes, and snippets.

@Martin91
Martin91 / basic.jsx
Last active September 3, 2016 02:27
JSX learning
var Nav, Child;
var app = <Nav name="testNav" />; // XML elements, attributes and children are transformed into arguments that are passed to React.createElement
// JSX also allows specifying children using XML syntax
var nestedApp = <Nav name="testNavNested"><Child name="child-in-Nav"><Nav name="nested-nav" /> </Child></Nav>;
// Namespaced Components
// namespaced components let you use one component that has other components as attributes
var MyFormComponent = React.createClass({ });
// you just need to create your "sub-components" as attributes of the main component:
@Martin91
Martin91 / remove_network_services.sh
Created August 17, 2016 09:14
one line to delete network configurations can not be removed by network GUI on Mac
networksetup -listallnetworkservices | grep "云梯" | parallel networksetup -removenetworkservice
@Martin91
Martin91 / preferencable.rb
Created August 4, 2016 12:51
Simple model configuration/preference design
module Preferencable
module ClassMethods
# declare preference names for current class
#
# @note this method will define a pair of read/write class methods for each field to maintain preferences,
# they all conform to the below pattern:
#
# .preferenced_{field}
# .preferenced_{field}(value)
#
@Martin91
Martin91 / solr_check.rb
Last active April 24, 2016 13:03
check solr cores and their replications through script
#!/usr/bin/env ruby
# Author: Martin Hong
# Date: 2016/04/24
#
# Monitor Solr health including replication status
# inspired in the script on https://issues.apache.org/jira/browse/SOLR-1855
require 'net/http'
require 'optparse'
@Martin91
Martin91 / application.rb
Last active March 9, 2016 03:31
makara run in new context
module XXXProjectName
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.to_prepare do
# Load application's model / class decorators
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
@Martin91
Martin91 / mysql_information_schema.sql
Last active November 3, 2015 03:00
Mysql check default character set for schema, table and columns
/* For Schemas: */
SELECT default_character_set_name FROM information_schema.SCHEMATA
WHERE schema_name = "schemaname";
/* For Tables: */
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_schema = "schemaname"
AND T.table_name = "tablename";
@Martin91
Martin91 / sublime_folder_exclude_patterns.json
Last active August 29, 2015 14:27
Sublime Project Folder Exclude Patterns
{
"folders":
[
{
"path": "project-source",
"folder_exclude_patterns": ["*-source/doc", "*-source/tmp", "*-source/log", "*-source/.yardoc"]
},
{
"path": "project-notes"
}
@Martin91
Martin91 / git-selective-merge.md
Last active August 29, 2015 14:25 — forked from katylava/git-selective-merge.md
git selective merge

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git co -b temp
@Martin91
Martin91 / capistrano_variables.rb
Created July 17, 2015 07:10
Capistrano Variables
# http://theadmin.org/articles/capistrano-variables/
application – required
repository – required
scm – defaults to :subversion
deploy_via – defaults to :checkout
revision – defaults to the latest head version
rails_env – defaults to ‘production’
rake – defaults to ‘rake’
source – Capistrano::Deploy::SCM object