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
class AddBackgroundToSpreeTaxons < ActiveRecord::Migration | |
def change | |
add_column :spree_taxons, :background_file_name, :string | |
add_column :spree_taxons, :background_content_type, :string | |
add_column :spree_taxons, :background_file_size, :integer | |
add_column :spree_taxons, :background_updated_at, :timestamp | |
end | |
end |
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
#! /bin/sed -f | |
# add begin transaction | |
1s/^SET .*$/END;\nBEGIN;\n/ | |
1s/^-- .*$/END;\nBEGIN;\n/ | |
1s/^/BEGIN;\n/ | |
# remove configuration settings | |
/^SET /d |
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
1. Dump the data only sql to file | |
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql | |
2. scp to local | |
3. Remove the SET statements at the top | |
such as: | |
SET statement_timeout = 0; | |
SET client_encoding = 'SQL_ASCII'; | |
4. Remove the setval sequence queries |
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
UPDATE Entities SET depth = (LENGTH(path) - LENGTH(REPLACE(path, '/', ''))) + 2 WHERE path <> ''; |
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
function numDigits(x) { | |
return (Math.log10((x ^ (x >> 31)) - (x >> 31)) | 0) + 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
function bestTick(largest, mostticks) { | |
var minimum = largest / mostticks; | |
var magnitude = Math.pow(10, Math.floor(Math.log(minimum) / Math.log(10))); | |
var residual = minimum / magnitude; | |
var tick; | |
if (residual > 5) { | |
tick = 10 * magnitude; | |
} else if (residual > 2) { | |
tick = 5 * magnitude; | |
} else if (residual > 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
#!/bin/sh | |
# Make sure to: | |
# 1) Name this file `backup.sh` and place it in /home/ubuntu | |
# 2) Run sudo apt-get install awscli to install the AWSCLI | |
# 3) Run aws configure (enter s3-authorized IAM user and specify region) | |
# 4) Fill in DB host + name | |
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket) | |
# 6) Run chmod +x backup.sh | |
# 7) Test it out via ./backup.sh |
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' | |
const timeout = ms => new Promise(res => setTimeout(res, ms)) | |
function convinceMe (convince) { | |
let unixTime = Math.round(+new Date() / 1000) | |
console.log(`Delay ${convince} at ${unixTime}`) | |
} | |
async function delay () { |
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
const data = Mydataspace.request('entities.get', { | |
root: 'MyDemoRoot', | |
path: 'data', | |
children: true, | |
filter: { | |
field1: 'test' | |
}, | |
offset: 10, | |
limit: 200 | |
}); |
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
#!/bin/sh | |
palette="/tmp/palette.png" | |
filters="fps=15,scale=1000:-1:flags=lanczos" | |
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette | |
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 |