SlideShare a Scribd company logo
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 data
Kevin Miguel Milla
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
Damien 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 17
Security Ninja
 
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
Nullbyte Security Conference
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
nbb3i
 
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 - Notes
Malathi Senthil
 
FizzBuzz Trek
FizzBuzz TrekFizzBuzz Trek
FizzBuzz Trek
Kevlin Henney
 
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
LINAGORA
 
Fizzbuzzalooza
FizzbuzzaloozaFizzbuzzalooza
Fizzbuzzalooza
Kevlin Henney
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model a
Golden Saragih
 
cape computer science unit 1 2016
cape computer science unit 1 2016cape computer science unit 1 2016
cape computer science unit 1 2016
DE Realest Thomas
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
Takahiro Inoue
 
Delta5 Summary
Delta5 SummaryDelta5 Summary
Delta5 Summary
Frederike_schweers
 
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
simmonsmqpydcoqqy
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
Ryan McGeary
 
123
123123
Tabledown
TabledownTabledown
Tabledown
T.C. Chou
 
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 Slater
Helen Slater
 
Kriyathmak anusantaan
Kriyathmak anusantaan Kriyathmak anusantaan
Kriyathmak anusantaan
simisanto
 
Airtel
AirtelAirtel
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 annunciata
Giovanna 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 2012
Vincent Everts
 
Hugo Chavez Sueldos De La Bolioligraquia
Hugo Chavez   Sueldos De La BolioligraquiaHugo Chavez   Sueldos De La Bolioligraquia
Hugo Chavez Sueldos De La Bolioligraquia
revedery
 
X 47 B
X 47 BX 47 B
X 47 B
Winson Ng
 
Worst Photoshop mistakes ever
Worst Photoshop mistakes everWorst Photoshop mistakes ever
Worst Photoshop mistakes ever
MicAymeric
 

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

Esperwhispering
EsperwhisperingEsperwhispering
Esperwhispering
Theo Schlossnagle
 
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 Security
James 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 .docx
RAHUL126667
 
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
 
SUMO simulation CODES AND STEPS
SUMO simulation CODES AND STEPSSUMO simulation CODES AND STEPS
SUMO simulation CODES AND STEPS
shrikrishna kesharwani
 
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
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
Ankit Gupta
 
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
JIGAR MAKHIJA
 
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
 
Drupal Mobile
Drupal MobileDrupal Mobile
Drupal Mobile
Ruben Teijeiro
 
Pop3ck sh
Pop3ck shPop3ck sh
Pop3ck sh
Ben Pope
 
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 dashboard
Georg Sorst
 
R57shell
R57shellR57shell
R57shell
ady36
 
Fbd@cfg
Fbd@cfgFbd@cfg
Instant Dynamic Forms with #states
Instant Dynamic Forms with #statesInstant Dynamic Forms with #states
Instant Dynamic Forms with #states
Konstantin Käfer
 
Mug17 gurgaon
Mug17 gurgaonMug17 gurgaon
Mug17 gurgaon
Ankur Raina
 

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

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

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