Skip to content

Instantly share code, notes, and snippets.

View fuyi's full-sized avatar
🎯
Focusing

YI FU fuyi

🎯
Focusing
  • Stockholm, Sweden
View GitHub Profile
@fuyi
fuyi / gist:a27bc4046ab96901638b
Last active December 7, 2015 13:01
customer workaround
1. 3583 team level goal
2. 3424 assign team bonus
3. 3519 goal visualization, show number instead of percentage, count down goal, leaderboard more personalized
4. 3800 multiple level teams
5 goal setting for each team
6 recuring
7 reusable metrics
8 tracking industry
@fuyi
fuyi / new_gist_file.md
Last active August 9, 2016 08:51
Dropbear Documentation List
  • Webpack building process for both development/production
  • Batch Action Saga
  • Maintainance/ Package upgrade process and common issues
  • Server side rendering
  • Client side asynchronous rendering until data is ready
  • Internationalization
  • Model denormarlization
@fuyi
fuyi / normalize-denormalize.md
Last active January 12, 2017 12:54
Model normalize/denormalize flow

Flow

  1. Define nested Schema
  2. Saga middleware detect a _REQUEST Action, which trigger a API request
  3. API request success trigger a _REQUEST_SUCCESS Action, api client get API response, map it with model to be normalized to, if the match found, normalizer flatten the nested JSON objects into flat entities structure, then send to store
  4. Redux store puts the normalized entities in place automatically
  5. ?? We need to manually update associated key to parent object, can this be automated?
  6. When passing data from Store to Container, we denormalize the objects by recursively looking into the key -> object mapping, reassemble the parent object. If any child object is missing, we report a error in console
@fuyi
fuyi / new_gist_file_0
Created February 23, 2017 14:17
log for image uploading, sparta API
Started POST "/1/uploads?x=5&y=0&width=66.30434782608697&height=100&aspect=1" for 127.0.0.1 at 2017-02-23 15:11:28 +0100
Processing by Api::V1::UploadsController#create as
Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x007fc497995ee0 @tempfile=#<Tempfile:/var/folders/zg/0xs11dw947n3skmk4tlcdd8r0000gn/T/RackMultipart20170223-28337-b809co.jpg>, @original_filename="4MB.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"4MB.jpg\"\r\nContent-Type: image/jpeg\r\n">, "x"=>"5", "y"=>"0", "width"=>"66.30434782608697", "height"=>"100", "aspect"=>"1", "version"=>"1"}
User Load (1.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
Organization Load (1.1ms) SELECT "organizations".* FROM "organizations" WHERE "organizations"."id" = $1 ORDER BY "organizations"."id" ASC LIMIT 1 [["id", 2]]
Unpermitted parameters: aspect, format, version
Unpermitted parameters: aspect, format, version
Unpermitted
def get_object_type(value_list):
"""
value_list: an array of String class name reprentation
return: the first string represents Lime object class, not relation class
"""
if not value_list:
raise ValueError('Search to end, no object type found')
try:
t = locate(value_list[0]) # Use locate to get type from string representation
except ValueError:
def _check_relational_existence(list_of_values):
try:
limetype = self.application.limetypes.get_limetype(list_of_values[0]) # Get limetype of first element
except ValueError:
print('Bad limetype provided')
is_relation = limetype.is_relation()
if len(list_of_values) == 1:
if is_relation:
def _check_relational_existence(list_of_values, root_limetype):
"""
check if the last element of the array is a valid lime property,
other elements must be valid lime type and has BelongTo relationship to next element
input:
list_of_values: an array contains lime type chain
root_limetype: the limetype to start property checking
return:
raise Exception if not valid limetype detect, otherwise return True
"""
import { Batch } from 'redux/modules/batch/helpers';
import batchStarter from 'redux/modules/batch/actions/batchStart';
import { bindActionCreators } from 'redux';
import fetchToken from 'redux/modules/user/actions/fetchToken';
export default (store) => (nextState, replace, cb) => {
const { batchStart } = bindActionCreators({ batchStart: batchStarter }, store.dispatch);
const batch = new Batch(batchStart);
batch.subBatch({ fetchToken: fetchToken() });
batch.subBatch({ routing: () => cb() });
cdebc563d04db6f86b8cbfc7ea9c93cf26e0fca8
@fuyi
fuyi / yi-tmp.yaml
Last active July 5, 2019 08:48
Template file to Create a tmp pod in kubernates
apiVersion: v1
kind: Pod
metadata:
name: tmp-shell-yi
namespace: event-producer-service
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65535
runAsGroup: 65535