Skip to content

Instantly share code, notes, and snippets.

View arabyniuk's full-sized avatar
🎯
Focusing

Andrew arabyniuk

🎯
Focusing
View GitHub Profile
@arabyniuk
arabyniuk / gist:0b4b9411eab882b8c5ea
Created August 27, 2015 07:15
gps current metadata - materialized view
connection.execute <<-SQL
CREATE MATERIALIZED VIEW last_current_metadata AS
SELECT id, hour_start, distance, last_time, max_speed, all_data_records, current_data_record, gl.gps_logger_metadata_item_id
FROM gps_logger_current_data_items gl
INNER JOIN (
SELECT gps_logger_metadata_item_id, MAX(hour_start) AS max_hour_start
FROM gps_logger_current_data_items
GROUP BY gps_logger_metadata_item_id
) ingl ON ingl.gps_logger_metadata_item_id = gl.gps_logger_metadata_item_id AND ingl.max_hour_start = gl.hour_start
SQL
task duplicate_imei: :environment do
Company.active.each do |company|
begin
SwitchTenant.switch!(company.tenant)
duplicate_imei_ids = []
GpsLoggerMetadataItem.select(:id, :imei).each do |l|
duplicate_imei_ids << GpsLogger.find_by(imei: l.imei).id if GpsLogger.where(imei: l.imei).size > 1
end
unless duplicate_imei_ids.blank?
description "A test job file for experimenting with Upstart"
author "Andrii Rabinyuk"
respawn
respawn limit unlimited
start on runlevel [2345] or started postgresql
stop on runlevel [016] or stopping postgresql
class MachineMapsBoard < BasicBoard
def machines
@machines ||= machines_in_regions.find_all do |m|
m.was_available_in_time_range(from_date: from_time.to_date,
to_date: to_time.to_date)
end
end
def selected_machine_groups
if machine_groups_ids.any?
class Scraper
def self.scrape_reviewer_profile_url
User.find_each do |user|
next unless user.amazon_profile_url || !user.amazon_profile_url.blank?
begin
browser = Watir::Browser.new :firefox
browser.goto user.amazon_profile_url
sleep 2
browser.span(class: 'a-expander-prompt').click
require 'rubygems'
require 'selenium-webdriver'
LOGIN = "me@danielsim.co.uk"
PASSWORD = "***"
DOMAINS = ["example1.myshopify.com", "example2.myshopify.com"]
CUSTOM_MESSAGE = "custom message"
window.Components = window.Components || {};
window.Components.Telematics = Components.Telematics || {};
window.Components.Telematics.Sensor = Components.Telematics.Sensor || {};
Components.Telematics.Sensor.Chart = React.createClass({
_tooltip: function(props){
this._tooltipFactory = this._tooltipFactory || React.createFactory(Components.Telematics.Sensor.Tooltip);
return this._tooltipFactory(props);
},
_callTooltipHandler: true,
import Ember from 'ember';
import DS from 'ember-data';
const { set, get } = Ember;
export default DS.JSONAPISerializer.extend({
serialize: function(snapshot, options) {
let json = this._super(snapshot, options);
const targetImagingAttributes = get(json, 'data.attributes.target-imaging-attributes');
@arabyniuk
arabyniuk / components.my-ui-sidebar.js
Last active September 5, 2017 10:29
bootstrap-sidebar
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
}
});
@arabyniuk
arabyniuk / rb
Last active September 15, 2023 13:09
simple stripe webhook
сlass WebhooksController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
def create
payload = request.body.read
sig_header = request.env['HTTP_STRIPE_SIGNATURE']
event = nil
begin