Skip to content

Instantly share code, notes, and snippets.

View kevinvangelder's full-sized avatar

Kevin VanGelder kevinvangelder

View GitHub Profile
selectImage = () => {
const options = {
title: 'Select Image',
storageOptions: {
skipBackup: true,
path: 'images',
},
};
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
const imageAssetPath = Image.resolveAssetSource(require("./path/to/image.jpg");
const response = await fetch(imageAssetPath.uri, {}, { isBinary: true });
const rawImageData = await response.arrayBuffer();
imageToTensor(rawImageData: ArrayBuffer): tf.Tensor3D {
const TO_UINT8ARRAY = true;
const { width, height, data } = jpeg.decode(rawImageData, TO_UINT8ARRAY);
// Drop the alpha channel info for mobilenet
const buffer = new Uint8Array(width * height * 3);
let offset = 0; // offset into original data
for (let i = 0; i < buffer.length; i += 3) {
buffer[i] = data[offset];
buffer[i + 1] = data[offset + 1];
buffer[i + 2] = data[offset + 2];
@kevinvangelder
kevinvangelder / simple_time.rb
Created November 21, 2016 19:16
Simple Time class for string-only time in Ruby
class SimpleTime
# attr_accessor :time
def self.parse(time)
return time if time.is_a?(SimpleTime)
return nil if time.nil? || (time.is_a?(String) && time.empty?)
return nil unless (time.is_a?(String) && time.upcase.match(/\d{1,2}:\d{2} [AP]M/)) || (time.is_a?(Hash) && time[:hour].present? && time[:minute].present? && time[:meridiem].present?)
self.new(time)
end
Microsoft Windows [Version 10.0.14316]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\Kevin>bash
bash-3.1$ cd /d
bash-3.1$ pwd
/d

Keybase proof

I hereby claim:

  • I am kevinvangelder on github.
  • I am kevinvangelder (https://keybase.io/kevinvangelder) on keybase.
  • I have a public key whose fingerprint is 7C02 A2D9 DC74 68E8 D0CC 9A1C 9331 2B1A 429B 9309

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am kevinvangelder on github.
  • I am kevinvangelder (https://keybase.io/kevinvangelder) on keybase.
  • I have a public key whose fingerprint is B442 AD1A 3CFC 1582 5366 6E8C 819D 2FB2 8DD3 1EE0

To claim this, I am signing this object:

@kevinvangelder
kevinvangelder / satisfaction_survey.rb
Created August 26, 2013 17:31
Country Restoration Satisfaction New
def self.customer_satisfaction
count = SatisfactionSurvey.where("approved=?", true).count
average = SatisfactionSurvey.where("approved = ?", true).sum("overall_customer_service")
average = average + (103 * 9.733)
count = count + 103
total = ((average / count) * 1000) / 100
total.round(2)
end
@kevinvangelder
kevinvangelder / about.php
Created August 26, 2013 17:31
Country Restoration Satisfaction Old
$total = db_query_row("SELECT SUM(overall_customer_service) FROM surveys WHERE approved = 1");
$survey_count = db_count("surveys", "WHERE approved = 1");
$added_up = $total["SUM(overall_customer_service)"];
$average = ((103 * 9.733) + $added_up) / (103 + $survey_count); // this is taking into account the previous (103) unadded surveys
$rating = number_format((($average * 1000) / 100), 2);
= simple_form_for @important_date do |f|
= f.input :name
= f.input :date, as: :ui_date_picker, data: { date_format: "mm/dd/yy" }, value: @important_date.date.strftime("%m/%d/%Y")
= f.input :recurring
.form-actions
= link_to "Cancel", important_dates_url, class: "btn btn-inverse"
- if @important_date.id
= link_to "Delete", important_date_url(@important_date), method: :delete, class: "btn btn-danger"
= f.submit "Save", class: "btn btn-success"