SlideShare a Scribd company logo
1 of 23
transmogrifier
   A JavaScript Utility
for Transforming Objects
trans·mog·ri·fy
•It’s a real word
   trăns-mŏg'rə-fī', trănz-
   tr.v, -fied, -fy·ing, -fies.

   To change into a different
   shape or form, especially one
   that is fantastic or bizarre.
   http://www.answers.com/transmogrify
trans·mog·ri·fy
•It’s a real word
   trăns-mŏg'rə-fī', trănz-
   tr.v, -fied, -fy·ing, -fies.

   To change into a different
   shape or form, especially one
   that is fantastic or bizarre.
   http://www.answers.com/transmogrify
what’s it for?
what’s it for?
really, what’s it for?


•To sanitize and simplify complex
  objects, like those returned by
  MLB’s services
•Inspired by getDeepValue and
  setDeepValue
•Implemented in $Q for transforming
  objects as defined in .select method
wywinwyg
wywinwyg
 what you want is not what you get
what you need
{

   "id":

   "type":

   "status":

   "venue":

   "teams": {

   
    "away": {

   
    
    "id":

   
    
    "name":

   
    
    "code":

   
    },

   
    "home": {

   
    
    "id":

   
    
    "name":

   
    
    "code":

   
    }

   },

   "pitchers": [],

   "apple":

   "banana":

   "yellow":
}
what you ge...
{

        "game_id": "2009/09/24/cinmlb-pitmlb-1",

        "game_pk": "246475",

        "game_time_is_tbd": false,

        "game_venue": "PNC Park",

        "game_time": "1253810100000",

        "game_time_offset_eastern": "-4",

        "pitcher": {

        
        "loss_id": "450203",

        
        "win_id": "276520",

        
        "win": "Arroyo",

        
        "loss_stat": "4-9",

        
        "win_stat": "14-13",

        
        "save": "Cordero",

        
        "save_stat": "39",

        
        "loss": "Morton",

        
        "save_id": "150188"

        },

        "game_location": "Pittsburgh",

        "home": {

        
        "file_code": "pit",

        
        "probable_stat": "5-9",

        
        "tv": null,

        
        "id": "134",

        
        "split": false,

        
        "probable_name_display_first_last": "Charlie Morton",

        
        "probable_report": "Morton showed some improved command in his last start, a sign that maybe he's beginning to figure out how
to use the movement he can get on his pitches to his benefit. The consistency of his command has been the biggest problem for Morton all
season, but after allowing an early run and getting out of an early jam, Morton found just that against the Padres. He matched his career high
with seven innings and has now allowed three or fewer runs in four of his past five starts. Morton is 1-1 with a 6.35 ERA in two previous
starts against Cincinnati.",

        
        "recap": "/news/gameday_recap.jsp?ymd=20090924&content_id=7131310&vkey=recap&fext=.jsp&c_id=pit",

        
        "full": "Pirates",

        
        "tickets": null,

        
        "radio": "WPGB-FM 104.7",

        
        "game_time_offset": "-4",

        
        "display_code": "PIT",
...eeeeee...

        
        "preview": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'preview',lurl:'/news/article.jsp?
ymd=20090923&content_id=7109806&vkey=news_pit&fext=.jsp&c_id=pit'}))",

        
        "wrapup": "/news/wrap.jsp?ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&team=home&c_id=pit",

        
        "audio_uri":
"javascript:bam.media.launchPlayer({content_id:'6765579',view_key:'MLBTV_MP_4',media_type:'audio',calendar_event_id:'14-246475-2009-09-24'})",

        
        "probable": "Morton",

        
        "probable_era": "4.55",

        
        "league": "104",

        
        "probable_id": "450203",

        
        "result": "1"

        },

        "division_id": "205",

        "game_time_offset_local": "-4",

        "scheduledTime": null,

        "game_status": "F",

        "mlbtv": true,

        "is_suspension_resumption": false,

        "video_uri":
"javascript:bam.media.launchPlayer({content_id:'6765575',view_key:'MLBTV_MP_4',media_type:'video',calendar_event_id:'14-246475-2009-09-24'})",

        "sport_code": "mlb",

        "venue_id": "31",

        "wrapup": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'wrap',lurl:'/news/wrap.jsp?
ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&c_id=mlb'}))",

        "preview": null,

        "game_type": "R",

        "resumptionTime": null,

        "away": {

        
        "file_code": "cin",

        
        "probable_stat": "15-13",

        
        "tv": null,

        
        "id": "113",

        
        "split": false,

        
        "probable_name_display_first_last": "Bronson Arroyo",

        
        "probable_report": "Arroyo was perfect through three innings Saturday against Florida, but a couple of costly mistakes led to
a loss, most notably a changeup to pinch-hitter Ross Gload that resulted in a two-run home run in the eighth, which lifted the Marlins to a
3-2 victory. Arroyo allowed three runs on six hits. He walked one and struck out six but allowed two home runs. Despite the loss, Arroyo
extended his streak of consecutive quality starts to 11.",

        
        "recap": "/news/gameday_recap.jsp?ymd=20090924&content_id=7131308&vkey=recap&fext=.jsp&c_id=cin",

        
        "full": "Reds",

        
        "tickets": null,
...et

        
        "radio": "WLW 700",

        
        "game_time_offset": "-4",

        
        "display_code": "CIN",

        
        "preview": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'preview',lurl:'/news/article.jsp?
ymd=20090923&content_id=7109796&vkey=news_cin&fext=.jsp&c_id=cin'}))",

        
        "wrapup": "/news/wrap.jsp?ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&team=away&c_id=cin",

        
        "audio_uri":
"javascript:bam.media.launchPlayer({content_id:'6765579',view_key:'MLBTV_MP_4',media_type:'audio',calendar_event_id:'14-246475-2009-09-24'})",

        
        "probable": "Arroyo",

        
        "probable_era": "3.84",

        
        "league": "104",

        
        "probable_id": "276520",

        
        "result": "4"

        },

        "game_dh": null,

        "game_num": "1",

        "fruit": [

        
        {

        
        
        "name": "apple",

        
        
        "color": "green"

        
        },

        
        {

        
        
        "name": "banana",

        
        
        "color": "yellow"

        
        },

        
        {

        
        
        "name": "cherry",

        
        
        "color": "red"

        
        }

        ]
}
and that’s just one!
how it works
var gameTemplate = {
  id:      'game_id',                  // output.id === input.game_id
  type:    'game_type',                // output.type === input.game_type
  status: 'game_status',               // output.status === input.game_status
  venue: 'game_venue',                 // output.venue === input.game_venue
  teams: {                             // output.teams === {}
     away: {                           // output.teams.away === {}
       id:   'away.id',                // output.teams.away.id === input.away.id
       name: 'away.full',              // output.teams.away.name === input.away.full
       code: 'away.file_code'          // output.teams.away.code === input.away.file_code
     },
     home: {                           // output.teams.home === {}
       id:   'home.id',                // output.teams.home.id === input.home.id
       name: 'home.full',              // output.teams.home.name === input.home.full
       code: 'home.file_code'          // output.teams.home.code === input.home.file_code
     }
  },
  time: function convertGameTime (obj) {
     var d = new Date(+obj.game_time),
         e = +obj.game_time_offset_eastern,
         h, m, a;
     d.setHours(d.getUTCHours() + e);
     h = d.getHours();
     m = d.getMinutes();
     h = h % 12 || 12;
     m = m < 10 ? '0' + m : m;
     a = h < 12 ? 'am' : 'pm';
     return h + ':' + m + a;           // output.time === input.game_time (h:mmaa)
  },
  pitchers: [                          // output.pitchers === []
     'pitcher.win',                    // output.pitchers[0] === input.pitcher.win
     'pitcher.loss',                   // output.pitchers[1] === input.pitcher.loss
     'pitcher.save'                    // output.pitchers[2] === input.pitcher.save
  ],
  apple: 'fruit.0',                    // output.apple === input.fruit[0]
  banana: 'fruit[1]',                  // output.banana === input.fruit[1]
  yellow: 'fruit[1].color'             // output.yellow === input.fruit[1].color
};

var gameTransmogrifier = new Transmogrifier(gameTemplate);
gameTransmogrifier.zap(gameObj);

{

   "id": "2009/09/24/cinmlb-pitmlb-1",

   "type": "R",

   "status": "F",

   "venue": "PNC Park",

   "teams": {

   
      "away": {

   
      
      "id": "113",

   
      
      "name": "Reds",

   
      
      "code": "cin"

   
      },

   
      "home": {

   
      
      "id": "134",

   
      
      "name": "Pirates",

   
      
      "code": "pit"

   
      }

   },

   "time": "12:35pm",

   "pitchers": [

   
      "Arroyo",

   
      "Morton",

   
      "Cordero"

   ],

   "apple": {

   
      "name": "apple",

   
      "color": "green"

   },

   "banana": {

   
      "name": "banana",

   
      "color": "yellow"

   },

   "yellow": "yellow"
}
two methods
.zap (objOrArr)
Transforms a single object or array
.nuke (arrOfObjs)
 Applies .zap to members of array
Transmogrify
Transmogrify

More Related Content

What's hot

Kevin milla arbieto informatica piktochart backup data
Kevin milla arbieto informatica   piktochart backup dataKevin milla arbieto informatica   piktochart backup data
Kevin milla arbieto informatica piktochart backup dataKevin Miguel Milla
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 
ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมธงชัย พาศรี
 
The Security Risks of Web 2.0 - DEF CON 17
The Security Risks of Web 2.0 - DEF CON 17The Security Risks of Web 2.0 - DEF CON 17
The Security Risks of Web 2.0 - DEF CON 17Security Ninja
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11nbb3i
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南 Leo Zhou
 
CBSE, Grade12, Computer Science, Random Numbers - Notes
CBSE, Grade12, Computer Science, Random Numbers - NotesCBSE, Grade12, Computer Science, Random Numbers - Notes
CBSE, Grade12, Computer Science, Random Numbers - NotesMalathi Senthil
 
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORA
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORAComment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORA
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORALINAGORA
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aGolden Saragih
 
cape computer science unit 1 2016
cape computer science unit 1 2016cape computer science unit 1 2016
cape computer science unit 1 2016DE Realest Thomas
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to TinkerpopTakahiro Inoue
 
This drone crashed the White House lawn
This drone crashed the White House lawnThis drone crashed the White House lawn
This drone crashed the White House lawnsimmonsmqpydcoqqy
 
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)James Titcumb
 

What's hot (20)

Kevin milla arbieto informatica piktochart backup data
Kevin milla arbieto informatica   piktochart backup dataKevin milla arbieto informatica   piktochart backup data
Kevin milla arbieto informatica piktochart backup data
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
ใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรมใบงานเรื่องการคอมไพล์โปรแกรม
ใบงานเรื่องการคอมไพล์โปรแกรม
 
The Security Risks of Web 2.0 - DEF CON 17
The Security Risks of Web 2.0 - DEF CON 17The Security Risks of Web 2.0 - DEF CON 17
The Security Risks of Web 2.0 - DEF CON 17
 
Speeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorallSpeeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorall
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
 
Python 炒股指南
Python 炒股指南 Python 炒股指南
Python 炒股指南
 
CBSE, Grade12, Computer Science, Random Numbers - Notes
CBSE, Grade12, Computer Science, Random Numbers - NotesCBSE, Grade12, Computer Science, Random Numbers - Notes
CBSE, Grade12, Computer Science, Random Numbers - Notes
 
FizzBuzz Trek
FizzBuzz TrekFizzBuzz Trek
FizzBuzz Trek
 
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORA
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORAComment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORA
Comment faire ses mappings ElasticSearch aux petits oignons ? - LINAGORA
 
Fizzbuzzalooza
FizzbuzzaloozaFizzbuzzalooza
Fizzbuzzalooza
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model a
 
cape computer science unit 1 2016
cape computer science unit 1 2016cape computer science unit 1 2016
cape computer science unit 1 2016
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
 
Delta5 Summary
Delta5 SummaryDelta5 Summary
Delta5 Summary
 
This drone crashed the White House lawn
This drone crashed the White House lawnThis drone crashed the White House lawn
This drone crashed the White House lawn
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
123
123123
123
 
Tabledown
TabledownTabledown
Tabledown
 
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
 

Viewers also liked

신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지
신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지
신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지foskfs
 
Tales of Suckage and Awesomeness (Full Frontal 2012)
Tales of Suckage and Awesomeness (Full Frontal 2012)Tales of Suckage and Awesomeness (Full Frontal 2012)
Tales of Suckage and Awesomeness (Full Frontal 2012)Chris Wilson
 
The Hotel By Helen Slater
The  Hotel   By  Helen  SlaterThe  Hotel   By  Helen  Slater
The Hotel By Helen SlaterHelen Slater
 
Kriyathmak anusantaan
Kriyathmak anusantaan Kriyathmak anusantaan
Kriyathmak anusantaan simisanto
 
Biserica densus (cl)
Biserica densus (cl)Biserica densus (cl)
Biserica densus (cl)VASILE Viorel
 
Hybris Biblia - Vendetta annunciata
Hybris Biblia - Vendetta annunciataHybris Biblia - Vendetta annunciata
Hybris Biblia - Vendetta annunciataGiovanna Esse
 
Un Bain De Lumiere
Un Bain De LumiereUn Bain De Lumiere
Un Bain De Lumierewestberti71
 
Sexy factureren Factureringscongres 2012
Sexy factureren Factureringscongres 2012Sexy factureren Factureringscongres 2012
Sexy factureren Factureringscongres 2012Vincent Everts
 
Hugo Chavez Sueldos De La Bolioligraquia
Hugo Chavez   Sueldos De La BolioligraquiaHugo Chavez   Sueldos De La Bolioligraquia
Hugo Chavez Sueldos De La Bolioligraquiarevedery
 
Worst Photoshop mistakes ever
Worst Photoshop mistakes everWorst Photoshop mistakes ever
Worst Photoshop mistakes everMicAymeric
 

Viewers also liked (17)

신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지
신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지
신용대출빠른곳『BU797』.『COM』현대해상보험회사 국내가족여행지
 
Tales of Suckage and Awesomeness (Full Frontal 2012)
Tales of Suckage and Awesomeness (Full Frontal 2012)Tales of Suckage and Awesomeness (Full Frontal 2012)
Tales of Suckage and Awesomeness (Full Frontal 2012)
 
The Hotel By Helen Slater
The  Hotel   By  Helen  SlaterThe  Hotel   By  Helen  Slater
The Hotel By Helen Slater
 
Kriyathmak anusantaan
Kriyathmak anusantaan Kriyathmak anusantaan
Kriyathmak anusantaan
 
Airtel
AirtelAirtel
Airtel
 
Biserica densus (cl)
Biserica densus (cl)Biserica densus (cl)
Biserica densus (cl)
 
Hybris Biblia - Vendetta annunciata
Hybris Biblia - Vendetta annunciataHybris Biblia - Vendetta annunciata
Hybris Biblia - Vendetta annunciata
 
Un Bain De Lumiere
Un Bain De LumiereUn Bain De Lumiere
Un Bain De Lumiere
 
Ppt a13c.ppsx
Ppt a13c.ppsxPpt a13c.ppsx
Ppt a13c.ppsx
 
Heimwerker
HeimwerkerHeimwerker
Heimwerker
 
Sexy factureren Factureringscongres 2012
Sexy factureren Factureringscongres 2012Sexy factureren Factureringscongres 2012
Sexy factureren Factureringscongres 2012
 
Ce au devenit(1)
Ce au devenit(1)Ce au devenit(1)
Ce au devenit(1)
 
Asta e africa (ab)
Asta e africa (ab)Asta e africa (ab)
Asta e africa (ab)
 
Jardins
JardinsJardins
Jardins
 
Hugo Chavez Sueldos De La Bolioligraquia
Hugo Chavez   Sueldos De La BolioligraquiaHugo Chavez   Sueldos De La Bolioligraquia
Hugo Chavez Sueldos De La Bolioligraquia
 
X 47 B
X 47 BX 47 B
X 47 B
 
Worst Photoshop mistakes ever
Worst Photoshop mistakes everWorst Photoshop mistakes ever
Worst Photoshop mistakes ever
 

Similar to Transmogrify

WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめようYuriko IKEDA
 
Dip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityJames Titcumb
 
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docxcalc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docxRAHUL126667
 
Dip Your Toes In The Sea Of Security (PHPNW16)
Dip Your Toes In The Sea Of Security (PHPNW16)Dip Your Toes In The Sea Of Security (PHPNW16)
Dip Your Toes In The Sea Of Security (PHPNW16)James Titcumb
 
Dip Your Toes in the Sea of Security (IPC Fall 2017)
Dip Your Toes in the Sea of Security (IPC Fall 2017)Dip Your Toes in the Sea of Security (IPC Fall 2017)
Dip Your Toes in the Sea of Security (IPC Fall 2017)James Titcumb
 
Dip Your Toes in the Sea of Security (CoderCruise 2017)
Dip Your Toes in the Sea of Security (CoderCruise 2017)Dip Your Toes in the Sea of Security (CoderCruise 2017)
Dip Your Toes in the Sea of Security (CoderCruise 2017)James Titcumb
 
Dip Your Toes in the Sea of Security (phpDay 2016)
Dip Your Toes in the Sea of Security (phpDay 2016)Dip Your Toes in the Sea of Security (phpDay 2016)
Dip Your Toes in the Sea of Security (phpDay 2016)James Titcumb
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...DevGAMM Conference
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardGeorg Sorst
 
R57shell
R57shellR57shell
R57shellady36
 
Instant Dynamic Forms with #states
Instant Dynamic Forms with #statesInstant Dynamic Forms with #states
Instant Dynamic Forms with #statesKonstantin Käfer
 

Similar to Transmogrify (20)

Esperwhispering
EsperwhisperingEsperwhispering
Esperwhispering
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
 
Dip Your Toes in the Sea of Security
Dip Your Toes in the Sea of SecurityDip Your Toes in the Sea of Security
Dip Your Toes in the Sea of Security
 
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docxcalc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
calc3build# calc3bison -y -d calc3.yflex calc3.lgcc -c .docx
 
Dip Your Toes In The Sea Of Security (PHPNW16)
Dip Your Toes In The Sea Of Security (PHPNW16)Dip Your Toes In The Sea Of Security (PHPNW16)
Dip Your Toes In The Sea Of Security (PHPNW16)
 
SUMO simulation CODES AND STEPS
SUMO simulation CODES AND STEPSSUMO simulation CODES AND STEPS
SUMO simulation CODES AND STEPS
 
Dip Your Toes in the Sea of Security (IPC Fall 2017)
Dip Your Toes in the Sea of Security (IPC Fall 2017)Dip Your Toes in the Sea of Security (IPC Fall 2017)
Dip Your Toes in the Sea of Security (IPC Fall 2017)
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
Php functions
Php functionsPhp functions
Php functions
 
Dip Your Toes in the Sea of Security (CoderCruise 2017)
Dip Your Toes in the Sea of Security (CoderCruise 2017)Dip Your Toes in the Sea of Security (CoderCruise 2017)
Dip Your Toes in the Sea of Security (CoderCruise 2017)
 
Drupal Mobile
Drupal MobileDrupal Mobile
Drupal Mobile
 
Pop3ck sh
Pop3ck shPop3ck sh
Pop3ck sh
 
Dip Your Toes in the Sea of Security (phpDay 2016)
Dip Your Toes in the Sea of Security (phpDay 2016)Dip Your Toes in the Sea of Security (phpDay 2016)
Dip Your Toes in the Sea of Security (phpDay 2016)
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboard
 
R57shell
R57shellR57shell
R57shell
 
Fbd@cfg
Fbd@cfgFbd@cfg
Fbd@cfg
 
Instant Dynamic Forms with #states
Instant Dynamic Forms with #statesInstant Dynamic Forms with #states
Instant Dynamic Forms with #states
 
Mug17 gurgaon
Mug17 gurgaonMug17 gurgaon
Mug17 gurgaon
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Transmogrify

  • 1. transmogrifier A JavaScript Utility for Transforming Objects
  • 2. trans·mog·ri·fy •It’s a real word trăns-mŏg'rə-fī', trănz- tr.v, -fied, -fy·ing, -fies. To change into a different shape or form, especially one that is fantastic or bizarre. http://www.answers.com/transmogrify
  • 3. trans·mog·ri·fy •It’s a real word trăns-mŏg'rə-fī', trănz- tr.v, -fied, -fy·ing, -fies. To change into a different shape or form, especially one that is fantastic or bizarre. http://www.answers.com/transmogrify
  • 6. really, what’s it for? •To sanitize and simplify complex objects, like those returned by MLB’s services
  • 7. •Inspired by getDeepValue and setDeepValue •Implemented in $Q for transforming objects as defined in .select method
  • 9. wywinwyg what you want is not what you get
  • 10. what you need { "id": "type": "status": "venue": "teams": { "away": { "id": "name": "code": }, "home": { "id": "name": "code": } }, "pitchers": [], "apple": "banana": "yellow": }
  • 11. what you ge... { "game_id": "2009/09/24/cinmlb-pitmlb-1", "game_pk": "246475", "game_time_is_tbd": false, "game_venue": "PNC Park", "game_time": "1253810100000", "game_time_offset_eastern": "-4", "pitcher": { "loss_id": "450203", "win_id": "276520", "win": "Arroyo", "loss_stat": "4-9", "win_stat": "14-13", "save": "Cordero", "save_stat": "39", "loss": "Morton", "save_id": "150188" }, "game_location": "Pittsburgh", "home": { "file_code": "pit", "probable_stat": "5-9", "tv": null, "id": "134", "split": false, "probable_name_display_first_last": "Charlie Morton", "probable_report": "Morton showed some improved command in his last start, a sign that maybe he's beginning to figure out how to use the movement he can get on his pitches to his benefit. The consistency of his command has been the biggest problem for Morton all season, but after allowing an early run and getting out of an early jam, Morton found just that against the Padres. He matched his career high with seven innings and has now allowed three or fewer runs in four of his past five starts. Morton is 1-1 with a 6.35 ERA in two previous starts against Cincinnati.", "recap": "/news/gameday_recap.jsp?ymd=20090924&content_id=7131310&vkey=recap&fext=.jsp&c_id=pit", "full": "Pirates", "tickets": null, "radio": "WPGB-FM 104.7", "game_time_offset": "-4", "display_code": "PIT",
  • 12. ...eeeeee... "preview": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'preview',lurl:'/news/article.jsp? ymd=20090923&content_id=7109806&vkey=news_pit&fext=.jsp&c_id=pit'}))", "wrapup": "/news/wrap.jsp?ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&team=home&c_id=pit", "audio_uri": "javascript:bam.media.launchPlayer({content_id:'6765579',view_key:'MLBTV_MP_4',media_type:'audio',calendar_event_id:'14-246475-2009-09-24'})", "probable": "Morton", "probable_era": "4.55", "league": "104", "probable_id": "450203", "result": "1" }, "division_id": "205", "game_time_offset_local": "-4", "scheduledTime": null, "game_status": "F", "mlbtv": true, "is_suspension_resumption": false, "video_uri": "javascript:bam.media.launchPlayer({content_id:'6765575',view_key:'MLBTV_MP_4',media_type:'video',calendar_event_id:'14-246475-2009-09-24'})", "sport_code": "mlb", "venue_id": "31", "wrapup": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'wrap',lurl:'/news/wrap.jsp? ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&c_id=mlb'}))", "preview": null, "game_type": "R", "resumptionTime": null, "away": { "file_code": "cin", "probable_stat": "15-13", "tv": null, "id": "113", "split": false, "probable_name_display_first_last": "Bronson Arroyo", "probable_report": "Arroyo was perfect through three innings Saturday against Florida, but a couple of costly mistakes led to a loss, most notably a changeup to pinch-hitter Ross Gload that resulted in a two-run home run in the eighth, which lifted the Marlins to a 3-2 victory. Arroyo allowed three runs on six hits. He walked one and struck out six but allowed two home runs. Despite the loss, Arroyo extended his streak of consecutive quality starts to 11.", "recap": "/news/gameday_recap.jsp?ymd=20090924&content_id=7131308&vkey=recap&fext=.jsp&c_id=cin", "full": "Reds", "tickets": null,
  • 13. ...et "radio": "WLW 700", "game_time_offset": "-4", "display_code": "CIN", "preview": "javascript:void(launchGameday({gid:'2009_09_24_cinmlb_pitmlb_1',mode:'preview',lurl:'/news/article.jsp? ymd=20090923&content_id=7109796&vkey=news_cin&fext=.jsp&c_id=cin'}))", "wrapup": "/news/wrap.jsp?ymd=20090924&content_id=7131314&vkey=wrapup2005&fext=.jsp&team=away&c_id=cin", "audio_uri": "javascript:bam.media.launchPlayer({content_id:'6765579',view_key:'MLBTV_MP_4',media_type:'audio',calendar_event_id:'14-246475-2009-09-24'})", "probable": "Arroyo", "probable_era": "3.84", "league": "104", "probable_id": "276520", "result": "4" }, "game_dh": null, "game_num": "1", "fruit": [ { "name": "apple", "color": "green" }, { "name": "banana", "color": "yellow" }, { "name": "cherry", "color": "red" } ] }
  • 16. var gameTemplate = { id: 'game_id', // output.id === input.game_id type: 'game_type', // output.type === input.game_type status: 'game_status', // output.status === input.game_status venue: 'game_venue', // output.venue === input.game_venue teams: { // output.teams === {} away: { // output.teams.away === {} id: 'away.id', // output.teams.away.id === input.away.id name: 'away.full', // output.teams.away.name === input.away.full code: 'away.file_code' // output.teams.away.code === input.away.file_code }, home: { // output.teams.home === {} id: 'home.id', // output.teams.home.id === input.home.id name: 'home.full', // output.teams.home.name === input.home.full code: 'home.file_code' // output.teams.home.code === input.home.file_code } }, time: function convertGameTime (obj) { var d = new Date(+obj.game_time), e = +obj.game_time_offset_eastern, h, m, a; d.setHours(d.getUTCHours() + e); h = d.getHours(); m = d.getMinutes(); h = h % 12 || 12; m = m < 10 ? '0' + m : m; a = h < 12 ? 'am' : 'pm'; return h + ':' + m + a; // output.time === input.game_time (h:mmaa) }, pitchers: [ // output.pitchers === [] 'pitcher.win', // output.pitchers[0] === input.pitcher.win 'pitcher.loss', // output.pitchers[1] === input.pitcher.loss 'pitcher.save' // output.pitchers[2] === input.pitcher.save ], apple: 'fruit.0', // output.apple === input.fruit[0] banana: 'fruit[1]', // output.banana === input.fruit[1] yellow: 'fruit[1].color' // output.yellow === input.fruit[1].color }; var gameTransmogrifier = new Transmogrifier(gameTemplate);
  • 17.
  • 18. gameTransmogrifier.zap(gameObj); { "id": "2009/09/24/cinmlb-pitmlb-1", "type": "R", "status": "F", "venue": "PNC Park", "teams": { "away": { "id": "113", "name": "Reds", "code": "cin" }, "home": { "id": "134", "name": "Pirates", "code": "pit" } }, "time": "12:35pm", "pitchers": [ "Arroyo", "Morton", "Cordero" ], "apple": { "name": "apple", "color": "green" }, "banana": { "name": "banana", "color": "yellow" }, "yellow": "yellow" }
  • 20. .zap (objOrArr) Transforms a single object or array
  • 21. .nuke (arrOfObjs) Applies .zap to members of array