Skip to content

Instantly share code, notes, and snippets.

@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
class PrettyLoader extends React.Component {
constructor(props) {
super(props);
this.state = {
loading: false
};
this.setLoading = this.setLoading.bind(this);
}
componentDidMount() {
@ivanoats
ivanoats / gatsby-node.js
Last active November 17, 2017 14:17
Sitemap for Gatsby
import fs from 'fs-extra-promise'
import sm from 'sitemap' // npm install --save sitemap
function pagesToSitemap(pages) {
const urls = pages.map((p) => {
if (p.path !== undefined) {
return {
url: p.path,
changefreq: 'daily',
priority: 0.7
@ivanoats
ivanoats / fetch-from-contentful.js
Created June 17, 2016 18:45
fetch-from-contentful.js
#!/usr/bin/env babel-node
require('dotenv').config()
import contentful from 'contentful'
import fs from 'fs-extra-promise'
// Contentful Config
const apiToken = process.env.CONTENTFUL_DELIVERY_API_TOKEN
const spaceId = process.env.CONTENTFUL_SPACE_ID
const client = contentful.createClient({ accessToken: apiToken, space: spaceId })
@eladnava
eladnava / mongodb-s3-backup.sh
Last active September 13, 2024 11:42
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/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
@webron
webron / Instructions.md
Last active February 11, 2021 14:06
Load multiple resources to swagger-ui - work by @ponelat

Steps to follow:

  1. Create a new global SwaggerUi object, make sure to give the global variable a new name (in this case, swaggerUi2 - https://gist.github.com/webron/7c41db7f777471fcbc10#file-index-html-L59-L84.
  2. Assign a new URL - https://gist.github.com/webron/7c41db7f777471fcbc10#file-index-html-L60 - in this case, we use the same pet store URL, but just change the value to the swagger.json you want to display.
  3. Provide a unique dom_id - in this case we went with swagger-ui-container2 - https://gist.github.com/webron/7c41db7f777471fcbc10#file-index-html-L61
  4. Load the new SwaggerUi object - https://gist.github.com/webron/7c41db7f777471fcbc10#file-index-html-L103
  5. Add a <div> to display it. In it, make sure the id is set to the dom_id set in step 3, and that the class is swagger-ui-wrap so that the CSS is applied - https://gist.github.com/webron/7c41db7f777471fcbc10#file-index-html-L135

You can repeat the steps above as many times as needed, just make sure to provide a unique `dom_i

@tobyzerner
tobyzerner / app.js
Created April 8, 2015 02:38
Mithril ES6 Components
import Component from './component';
class Widget extends Component {
init(ctrl) {
var props = this.props;
ctrl.counter = props.initialValue;
ctrl.increment = function() {
ctrl.counter++;
@cantecim
cantecim / plpgsql_iso639-1_languages.sql
Last active January 20, 2023 12:40
PostgreSQL ISO639-1 Language Codes SQL
CREATE TABLE public.languages (
id serial NOT NULL,
code varchar(2) NOT NULL,
"language" varchar(30),
/* Keys */
CONSTRAINT languages_pkey
PRIMARY KEY (id)
) WITH (
OIDS = FALSE
);
@mlanett
mlanett / rails http status codes
Last active February 3, 2025 11:36
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing