This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict";var t=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.parsePDF=void 0;const e=t(require("fs")),n=t(require("pdf-parse")),s=require("json2csv");async function r(t,r){const l=e.default.readFileSync(t),o=(await n.default(l)).text.split("TransactionDebitCreditBalance");o.shift();let a=[],c=0;for(let t of o){const{results:e,finalBalance:n}=i(t,c);c=n,a=[...a,...e]}if(r&&r.endsWith(".json"))e.default.writeFileSync(r,JSON.stringify(a,null,2));else if(r&&r.endsWith(".csv")){const t=s.parse(a);e.default.writeFileSync(r,t)}else console.log(a)}function i(t,e=0){const{openingBalance:n,firstPassResults:s}=function(t){const e=t.split("\n");let n;e.shift();const s=[];if(function(t){return t.includes("OPENING BALANCE")}(e[0])){n=l((e.shift()||"").split("$")[1])}let r=!1;for(const t of e)if(!0!==r){if(""===t)break;if(t.includes("CLOSING BALANCE"))break;t.includes("CREDIT INTEREST EARNED")?r=!0:s.push(t)}else r=!1;return{f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = Aws::S3::Client.new(access_key_id: 'xxx', secret_access_key: 'xxx', region: 'ap-southeast-2') | |
client.put_object_acl({bucket: 'bucket_name', key: 'object_key', acl: 'public-read'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line = 'something very long that we need to split it ----llll aaa ' | |
# the size/limit is 30 | |
line.scan(/.{1,30}\b|.{1,30}/).map(&:strip) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'json' | |
country = 'ph' | |
tests = File.read("/Users/zz/Downloads/#{country}.json") | |
csv = CSV.open("/Users/zz/downloads/#{country}_final_#{Time.now.to_i}.csv", 'w') | |
csv << %w[index response_code suggested_or_not suggest_address delivery_suburb delivery_postcode raw_request raw_response] | |
orders = JSON.parse(tests) | |
succeed = 0 | |
failed_with_suggestion = 0 | |
completed_failed = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^(\+61|0)[2-478][0-9]{8}$)|(^\+64[0-9]{8,9}$) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AllCops: | |
Rails: | |
Enabled: true | |
Exclude: | |
- 'vendor/**/*' | |
- 'spec/fixtures/**/*' | |
- 'tmp/**/*' | |
- 'db/**/*' | |
TargetRubyVersion: 2.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :gps do | |
task ga4: :environment do | |
pdf = Couriers::Base::A4PackingSlipPublisher.new(Order.last) | |
pdf.render_file '/Users/ZZ/Desktop/a.pdf' | |
end | |
task ga6: :environment do | |
pdf = Couriers::Base::A6PackingSlipPublisher.new(Order.last) | |
pdf.render_file '/Users/ZZ/Desktop/a.pdf' | |
end |