Skip to content

Instantly share code, notes, and snippets.

@serebro
serebro / backupMongo_bucket.sh
Created September 13, 2016 00:02 — forked from njadhav1/backupMongo_bucket.sh
Backup MongoDB collection and upload to AWS s3
#!/bin/bash
########
# Purpose :- To take a backup of MongoDB Collections and upload to AWS s3
# Requirement :- Make Sure Collection.config file is present in /data/Backup/mongodb
# format for Collection.config is db|collection
# For example
# db1|collections1
@serebro
serebro / ReadMe.md
Created November 10, 2015 00:09 — forked from mattmccray/Loot-ReadMe.md
Loot.js - Smart stores for Riot (like flux, based on ideas from RiotControl)

Loot.js!

Smart stores for Riot (like flux, based on ideas from RiotControl)

Small (<1.5Kb) flux-like store container.

Example

Make sure loot.js is included in your page after riot.js:

<?php
// PHP PThreads issue 329 diagnostic script by John Wellesz
// Also a nice example of shared object management...
const ONEMUSEC = 1000000;
printf('file age: %d', time() - filemtime(__file__));
echo PHP_EOL;
CREATE TYPE address AS (country text, city text, zip varchar(6), street text, number text, building text);
CREATE TABLE users (id SERIAL PRIMARY KEY, email text, adresses address[]);
INSERT INTO users(email, adresses) VALUES('user1@example.org', ARRAY[ROW('RU', 'Moscow', '123123', 'Lenina', '5', 'a')::address, ROW('RU', 'SPB', '123456', 'Gagarina', '102', '5')::address]);
SELECT * FROM users;
<?php
function resizeImage($source, $dest, $new_width, $new_height, $quality)
{
// Taken from http://salman-w.blogspot.com/2009/04/crop-to-fit-image-using-aspphp.html
$image = new Phalcon\Image\Adapter\GD($source);
$source_height = $image->getHeight();
$source_width = $image->getWidth();
$source_aspect_ratio = $source_width / $source_height;
$desired_aspect_ratio = $new_width / $new_height;
if ($source_aspect_ratio > $desired_aspect_ratio) {