Skip to content

Instantly share code, notes, and snippets.

@vutran0111
vutran0111 / rdrc2016.md
Created June 26, 2016 15:46 — forked from cheeaun/rdrc2016.md
RedDotRubyConf 2016 links & resources 😘
@vutran0111
vutran0111 / gist:1864afec89fc862d61f2f729b3121b31
Created August 4, 2017 03:40
bundle exec rspec spec/models/segment_hook_handler_spec.rb
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 14787
SegmentHookHandler
page hooks
sends the event to keen as a segment_page_view (FAILED - 1)
identify hooks
hook_data = {
"anonymousId"=>nil,
"channel"=>"server",
"context"=>{"library"=>{"name"=>"simple_segment", "version"=>"0.1.1"}},
"event"=>"signup",
"integrations"=>{},
"messageId"=>"api-bV5ZmieDrhHeMrqwsAqqUytqWec3q6EY",
"originalTimestamp"=>"2016-11-10T00:32:29+08:00",
"projectId"=>"3jjqD3uFsq",
"properties"=>nil,
function editService($id = null){
if($this->request->is(array('post','put'))){
$currentUser = $this->Auth->user();
if($this->request->data['Service']['user_id'] != $currentUser['SppUser']['id']){
$this->Session->setFlash(__('Bạn không có quyền chỉnh sửa thông tin của dịch vụ này.'));
return $this->redirect($this->referer());
}else{
if($this->Service->save($this->request->data)){
$this->Session->setFlash(__('Đã cập nhật thành công.'));
return $this->redirect(array('action' => 'index'));
@vutran0111
vutran0111 / index.md
Created August 8, 2017 04:20 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

{
"member": {
"sources": {
"dummysource1": {
"traits": {
"age": "20.0",
"avatar": "avatar_url_11",
"email": "peter3@gmail.com"
},
"uids": {
user_id='iden1'
event_name = "new_event"
hook_data= {
"anonymousId"=>nil,
"channel"=>"server",
"context"=>{"library"=>{"name"=>"simple_segment", "version"=>"0.1.1"}},
"event"=>event_name,
"integrations"=>{},
"messageId"=>"api-bV5ZmieDrhHeMrqwsAqqUytqWec3q6EY",
"originalTimestamp"=>"2017-09-10T00:32:29+08:00",
@vutran0111
vutran0111 / map.html
Created October 11, 2017 09:21 — forked from phirework/map.html
Create a Google map using JSON data with check-box filtering for categories. Map data set-up: name, url, place (address), ltt (latitude), lgt (longitude), cat (category). Set up custom icons that correspond to the name of each category in PNG format. Sample: http://dev.phirephoenix.com/map/maps.html
<div id="map" style="width: 550px; height: 450px"></div>
<form action="#">
Eat: <input type="checkbox" id="eatbox" onclick="boxclick(this,'eat')" /> &nbsp;&nbsp;
Stay: <input type="checkbox" id="staybox" onclick="boxclick(this,'stay')" /> &nbsp;&nbsp;
Shop: <input type="checkbox" id="shopbox" onclick="boxclick(this,'shop')" />&nbsp;&nbsp;
Play: <input type="checkbox" id="playbox" onclick="boxclick(this,'play')" />&nbsp;&nbsp;
Community: <input type="checkbox" id="communitybox" onclick="boxclick(this,'community')" /><br />
</form>