Skip to content

Instantly share code, notes, and snippets.

View rjattrill's full-sized avatar

Ross Attrill rjattrill

View GitHub Profile
@rjattrill
rjattrill / multiline-values.yaml
Created November 18, 2013 06:33
Break YAML over multiple lines
# Join multiple lines without new line
value: >
part 1
part 2
# Join with newline
value2: |
line 1
line 2
We can't make this file beautiful and searchable because it's too large.
M4id,Date,Value
H1,2015-01-07 12:00:00,605.0
H1,2015-01-07 13:00:00,586.0
H1,2015-01-07 14:00:00,586.0
H1,2015-01-07 15:00:00,559.0
H1,2015-01-07 16:00:00,511.0
H1,2015-01-07 17:00:00,443.0
H1,2015-01-07 18:00:00,422.0
H1,2015-01-07 19:00:00,395.0
H1,2015-01-07 20:00:00,382.0
@rjattrill
rjattrill / autogluon_forecast.py
Created December 23, 2022 04:32
Issue with excluded_model_types with AutoGluon
import pandas as pd
from autogluon.timeseries import TimeSeriesPredictor, TimeSeriesDataFrame
# Load the data into a TimeSeriesDataFrame
df = pd.read_csv(
"m4_hourly.csv",
parse_dates=["Date"],
)
ts_dataframe = TimeSeriesDataFrame.from_data_frame(
@rjattrill
rjattrill / ReceiveYamlSinatra.rb
Last active December 16, 2020 19:04
Receive YAML file in Sinatra
post '/import' do
contents = request.body.read
# Remove wrappers from the client FormData wrapper
yaml = contents.gsub(/^------WebKitFormBoundary.*\n|^Content-Disposition.*\n|^Content-Type.*\n/, '')
puts "YAML: #{yaml}"
end
# See also: https://gist.github.com/rjattrill/dd2d2597d4993433bcc6de7792a3a903 for a React/JavaScript sender.
@rjattrill
rjattrill / SendYamlFromJavascript.js
Last active December 16, 2020 19:04
Sending YAML document from JavaScript (React)
import * as React from 'react'
function PickYamlFile() {
onInputChange = async (evt) => {
const file = evt.currentTarget.files[0]
const url = myHost() + '/import'
// Important to wrap the YAML with FormData encoding as YAML may contain % or other difficult characters.
const data = new FormData()
@rjattrill
rjattrill / TaskTemplateDocumentSend.mxml
Last active November 14, 2019 11:25
Bind a Flex component to two conditions using && in MXML
<s:Button id="sendBtn" label="Send" click="sendBtn_clickHandler(event)"
enabled="{!model.documentSending &amp;&amp; model.documentCreated}"/>
@rjattrill
rjattrill / dsnless-odbc-sequel.rb
Created December 5, 2012 22:53
DSN-less ODBC Connection with ruby-sequel
require 'sequel'
DB = Sequel.connect(:adapter=>'odbc',:driver=>'SQL Server Native Client 10.0',:server=>'localhost',:port=>1433, :uid=>'myuser',:pwd=>'mypass',:db_type=>'mssql')
DB.fetch("SELECT * FROM artist") do |row|
puts row
end
@rjattrill
rjattrill / GetParsleyContext.as
Created November 25, 2012 23:04
How to get current Parsley Context
// To get Parsley context for the current module - you just inject on the type Context (of course).
import org.spicefactory.parsley.core.context.Context;
[Inject]
public var context:Context;
@rjattrill
rjattrill / DynamicMethodInvocation.as
Created December 6, 2013 03:31
Call a method or access a property dynamically in ActionScript given a string matching the method name or property
public function checkFunc() : void {
Alert.show("inside function");
}
public var myfunc:String = "checkFunc";
public var newFunc:Function = this[myfunc];
newFunc(); // This will invoke checkFunc
@rjattrill
rjattrill / DBIxDataModelWhereIn.pl
Created December 5, 2013 02:50
IN clause with DBIx::DataModel or SQL::Abstract
-where => {
employee_code => {-in => [qw(CA CT CX)]}
},