Skip to content

Instantly share code, notes, and snippets.

@faisalman
faisalman / analytics-regexp.js
Created April 18, 2011 08:06
Regular Expression snippets to validate Google Analytics tracking code (in PHP, JavaScript)
/**
* Regular Expression snippets to validate Google Analytics tracking code
* see http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty
*
* @author Faisalman <movedpixel@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/faisalman
* @param str string to be validated
* @return Boolean
*/
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@cryptix
cryptix / LICENSE
Last active June 26, 2024 01:30
example of using JWT for http authentication in go
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@mlanett
mlanett / rails http status codes
Last active June 14, 2024 06:07
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
@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
);
@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++;
@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

@eladnava
eladnava / mongodb-s3-backup.sh
Last active March 11, 2024 10:21
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
@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 })