Skip to content

Instantly share code, notes, and snippets.

View all4miller's full-sized avatar

Angus Miller all4miller

View GitHub Profile
def process_past_48_hours_fast
st = (DateTime.now - 48.hours).beginning_of_hour
en = ((st + 48.hours) - 1.second)
Business.connection.select_all("
with biz as (
select businesses.id,
coalesce(businesses.cpc_in_dollars, 0.03) cpc_in_dollars,
businesses.fee_in_dollars,
businesses.plan
def process_past_48_hours
biz_ids = Businesss.where.not(id: 10).where(flag: true).pluck(:id)
biz_ids += Cards.where(state: 1).pluck(:biz_id)
biz_ids = biz_ids.uniq
# 4720 biz_ids recrds
h = {}
st = (DateTime.now - 48.hours).beginning_of_hour
en = ((st + 48.hours) - 1.second)
Businesss.where(id: biz_ids).order(:plan).each do |business|
Before:
<div class="col-12" style='display: flex; flex-direction: row; justify-content: flex-end;'>
<h1 style='display: inline-flex; font-size: 11px; font-weight: 300;'>
<div>
<% @past_years.map(&:year).sort.reverse.each do |year| %>
<%= link_to year.to_i ...., style: 'margin: 0 3px;font-size: 10px;' %>
<% end %>
</div>
</h1>
create table table_data (
code integer primary key not null,
data_value varchar(30) not null
);
create table stage_data (
id serial primary key,
code integer not null,
data_value varchar(30) not null
);
@all4miller
all4miller / sed.md
Last active December 24, 2019 05:03
SED Special Character Classes

Special Character Classes

The following list includes the special character classes which you can use:

[[:alpha:]] Pattern for any alphabetical character, either upper or lower case.
[[:alnum:]] Pattern for 0–9, A–Z, or a–z.
[[:blank:]] Pattern for space or Tab only.
[[:digit:]] Pattern for 0 to 9.
[[:lower:]] Pattern for a–z lower case only.
@all4miller
all4miller / wizard.rb
Last active February 23, 2017 10:31
Wizard
class School
SCHOOL_DATA = [
{
name: 'Beauxbatons Academy of Magic',
location: 'Pyrenees, France',
courses: {
muggle_studies: 5,
wand_practice: 41,
defence_against_the_dark_arts: 25,
herbology: 15,
@all4miller
all4miller / gist:c25ed2424935bc05adf4
Created February 11, 2016 13:24 — forked from nobuti/gist:3816985
MySQL tables for continent names, country names and their ISO codes
CREATE TABLE IF NOT EXISTS `continents` (
`code` CHAR(2) NOT NULL COMMENT 'Continent code',
`name` VARCHAR(255),
PRIMARY KEY (`code`)
) ENGINE=InnoDB;
INSERT INTO `continents` VALUES
('AF', 'Africa'),
('AS', 'Asia'),
('EU', 'Europe'),
@all4miller
all4miller / install-torquebox.sh
Last active August 29, 2015 14:05
Torquebox install script
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ -z "$1" ]; then
echo 'You need to supply a torquebox version param (e.g) "3.1.1"'
exit 1
fi
@render = ->
return if @data.error?
CloudBI.Charts.Real.chartArea CloudBI.Widget.Result.seriesCategories({@container, @data})
namespace 'CloudBI.Widget'
Result:
class Result extends CloudBI.Widget
@seriesCategories: (params) ->
result =
series: []
categories: []
container: params.container
for category_val in params.data.row_names
result.categories.push category_val