Skip to content

Instantly share code, notes, and snippets.

update contacts set contact=CONCAT("+99", floor(rand(current_timestamp())*999999999)) where type='phone';
update users set realname=CONCAT('Random ', floor(rand(current_timestamp())*9999999)), email=CONCAT(CONCAT('random', floor(rand(current_timestamp())*9999999)), '@example.com') where role <> 'admin';
update users set password='$2y$15$Ha7nHVZApHXfzhrD2HCukuUjjQhIUzPJ0JNWk7KooT6edQFTbeWr6'; /* "admin" .. DON'T RUN FOR STAGING */
update users set email='admin@example.com' where id=1;
delete from config where group_name='data-provider' and config_key in ('email', 'twitter');
delete from config where group_name='twitter';
truncate oauth_refresh_tokens;
truncate oauth_access_tokens;
truncate webhooks;
@tuxpiper
tuxpiper / aws_vault_ext.sh
Created January 19, 2019 11:52
Shell helper to switch AWS environments
# save somewhere under your home folder and source from .bash_profile
_aws_vault_session() {
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY \
AWS_REGION AWS_DEFAULT_REGION \
AWS_SECURITY_TOKEN AWS_SESSION_TOKEN \
AWS_VAULT ;
if [ -n "$1" ]; then
eval `aws-vault exec $1 -- bash -c "set -o posix; set; set +o posix" | grep ^AWS_`
export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY \
@tuxpiper
tuxpiper / ushahidi_v3_oauth_token.md
Last active June 21, 2016 15:54
ushahidi_v3_oauth_token.md

Obtaining access token and refresh token

request headers:

POST /oauth/token HTTP/1.1
Host: ( your API server host here, i.e. http://api.localhost:8080 )
Accept: application/json, text/plain, */*
Content-Type: application/json;charset=UTF-8
@tuxpiper
tuxpiper / tornado_state_file.py
Last active May 29, 2016 19:07
simple file-backed key value store on python2 + tornado
#!/usr/bin/env python
from threading import Thread
from tornado import gen, ioloop
from tornado.queues import Queue as AsyncQueue
import random, json, time, logging, Queue
import shelve
_db = None
_cmd_q = None # command queue (consumed by db loop)
@tuxpiper
tuxpiper / gist:2c6dde81e752356cdec6
Created May 12, 2014 16:02
IAM policy for user to self manage
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:ListUsers"
],
"Resource": ["arn:aws:iam::xxxxxxxxx:user/"]
},
@tuxpiper
tuxpiper / ebs_snapshot.sh
Created April 18, 2014 10:05
EBS snapshot based on DeviceName
#!/bin/bash
# Requirements:
# - awscli ( https://pypi.python.org/pypi/awscli )
# - jq ( http://stedolan.github.io/jq )
# - curl
# - configuring crendentials properly (see below)
# Invoke with devicename matching the EBS to be backed up (i.e. "/dev/sdm")
[ -z "$1" ] && { echo "Call me with the devicename of the EBS you want to back up!"; exit 1; }