Skip to content

Instantly share code, notes, and snippets.

View codervince's full-sized avatar

Vince codervince

  • Melbourne, Australia
View GitHub Profile
//MainLayout
const linkStyle={activeStyle: {color:'red'}}
export const MainLayout = props => {
<div>
...
//default Default loser
<Link to="/greeting/loser/default" {...LinkStyle}> Welcome,. Loser</Link>
//magic taken care of by REACT ROUTER see nested Routes in Router index.js
@codervince
codervince / react.redux.js
Created July 8, 2017 03:13
Redux and integrating in react - best to outsource the conversion
//actions.js
export const ADD_PRODUCT = 'ADD_PRODUCT';
export const CLEAR_FORM = 'CLEAR_FORM';
....
//NB Reducers MUST be pure functions
/* action creators */
export function addProduct(product){
@codervince
codervince / React.ExternalComponentWrapper.js
Created July 6, 2017 07:08
Creating an external wrapper to am npm component not written for react
//implements API, looks like a regular R component
//just displays data as JSON
//uses JSON-Formatter.js https://github.com/mohsen1/json-formatter-js
//bundler must have acess to node_modules/dist/bundle.js
//bind in HTML via <script)
//JSONViewer.js
export class JSONViewer extends React.Component {
@codervince
codervince / React.Component.js
Last active July 6, 2017 06:52
React.Component.js
// Add all useful state specific functions here
export class App extends ReactComponent {
constructor(props){
super(props)
this.state = {products: [{....}]}
//
_handleRemoveLast() {
this.setState({
@codervince
codervince / pyversuspandas1.py
Created May 27, 2016 05:14
PYTHON VS PANDAS
def convert_to_bin_places(seq):
rtn = ""
if '>' in seq:
'''remove > '''
seq = seq.split('>')
rtn = list(map(lambda x: '1' if x != '' and x == '1' else '0', seq))
return "".join(rtn)
def convert_to_fs_places(seq):
@codervince
codervince / gist:86f69d2143bc26057f2c
Created August 21, 2015 15:13
RACE AUDIO TRANSCRIPT
##file 1
http://streaming.hkjc.edgesuite.net/mobile/audio/audio_eng_20150712.mp3
http://www.hkjc.com/english/racing/OtherHorse.asp?HorseNo=N159
http://www.hkjc.com/english/racing/horse.asp?horseno=M327
There are two variants above plus a variant for retired horses
Each horse has a code a050 to t999
@codervince
codervince / gist:a5fc189d65f5743dd8f3
Last active August 29, 2015 14:27
BETTR BETTR AUG 20
#1
The data from getdata() is in the data.pkl file.
First create the users from tipsters = np.array(<USER.NAME>)
Then upload data from data.pkl, one row per user to the
TipsterPerformance table.
Note the racedate for the INIT data is say AUG 1 2015
All the SQLAlchemy code should be in a separate file.
TipsterPerformance replaces UserPerformance.
HKResults project
Phase 2
PRELIMINARIES:
take hkjc_spider.py from andrey-chabrov/racingpost
new repo https://github.com/codervince/hkjcresults.git
Add following fields, e.g.
http://racing.hkjc.com/racing/Info/Meeting/Results/English/Local/20150524/ST/11
parse_race
@codervince
codervince / gist:43ec73c9104a26cb3d2a
Created April 4, 2015 07:12
rpostraceday Itemloader
https://github.com/codervince/rpostraceday
Task:
1. if any page (esp. pedigreequery.com) returns 404 ie no item fields matching URL, still collect and return item as before
2. RacedayItemLoader should TakeFirst() for [] single element lists or Join for multiple element lists - matching pipeline definitions