Skip to content

Instantly share code, notes, and snippets.

View vanjos's full-sized avatar

Victor ... wait for it .... Anjos vanjos

View GitHub Profile
@vanjos
vanjos / innodb_memcheck.sql
Created January 31, 2013 20:22
Find out how much possible MEM MySQL would use (with INNODB)
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';
SHOW VARIABLES LIKE 'innodb_additional_mem_pool_size';
SHOW VARIABLES LIKE 'innodb_log_buffer_size';
SHOW VARIABLES LIKE 'thread_stack';
SET @kilo_bytes = 1024;
SET @mega_bytes = @kilo_bytes * 1024;
SET @giga_bytes = @mega_bytes * 1024;
SET @innodb_buffer_pool_size = 2 * @giga_bytes;
SET @innodb_additional_mem_pool_size = 16 * @mega_bytes;
SET @innodb_log_buffer_size = 8 * @mega_bytes;
@vanjos
vanjos / bpnn.py
Created February 4, 2013 18:09
Backward Propagation Neural Network (XOR)
#!/usr/bin/env python
import math
import random
import string
random.seed(0)
# calculate a random number where: a <= rand < b
@vanjos
vanjos / datastax_cassandra.sh
Last active April 4, 2017 10:51
Very quick and easy Cassandra (1.2) Installation on an EC2 (or really any) Ubuntu offering.
#!/bin/bash
###
#
# Find out which ami to use on http://www.alestic.com
#
# at the time of this writing, Ubuntu 12.04 (Precise) was ami-23d9a94a
# with EBS boot
#
# In order for this to work, tuned your firewall for the following:
@vanjos
vanjos / NC-MySQLDUMP.sh
Last active January 2, 2023 00:15
Easy way to do a mysqldump and restore using netcat (this is NOT encrypted)
#####
# You'll be needing two machines, the target machine and source one (makes sense, right)?
#####
# On the target machine
nc -l 55555 | gzip -d -c | mysql <database name> -u<user> -p<password> [ | <decrypt> ]
#####
# On the source machine
mysqldump -u<user> -p<password> <database name> | gzip | nc <ip of target server> 55555 [ | <encrypt> ]
@vanjos
vanjos / ccm_cassandra.sh
Last active December 20, 2015 17:39
CCM Installation to have the stack work FAST
#!/bin/bash
###
#
# Find out which ami to use on http://www.alestic.com
#
# at the time of this writing, Ubuntu 12.04 (Precise) was ami-23d9a94a
# with EBS boot
#
# In order for this to work, tuned your firewall for the following:
@vanjos
vanjos / Running_query_volume.sh
Created August 28, 2013 12:42
Find the volume of running MySQL queries. Helps nail down what gets run a lot in a high-volume system
mysql -e "show processlist" | grep -v Rows | grep -v Sleep | grep -oP -A1 "(SELECT|UPDATE|INSERT).*FROM \w+" | sort -h | uniq -c | sort -n
@vanjos
vanjos / ec2metadata_creator.php
Created August 28, 2013 19:18
Set up ec2metata_constants.php
<?php
/**
* This script gets EC2 metadata and saves it to an ini file. It should be run
* on boot before starting application stuff, such as php-fpm or video
* processing.
*/
// path to put file
$path = '/usr/local/viafoura';
@vanjos
vanjos / get_memcache_keys.php
Created October 16, 2013 19:30
Get ALL keys from memcache using PHP
<?php
$server = "localhost";
$port = 11211;
/**
* Taken directly from memcache PECL source
*
* http://pecl.php.net/package/memcache
*
*/
@vanjos
vanjos / kafka-upstart.conf
Created February 10, 2014 15:05
Upstart script for Kafka
description "Kafka Broker"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
env CONFIG_HOME="/etc/kafka"
env KAFKA_HOME="/usr/lib/kafka"
@vanjos
vanjos / stargate.md
Last active August 29, 2015 14:02
Stargate Explained (Lucene indexing ON Cassandra) to replace Lucandra/Solandra and SOLR (from DSE)

STARGATE INSTALL

  • Prerequisites
  • ubuntu
  • java 1.7
  • likely want openjdk-7-jre-headless openjdk-7-jre-lib openjdk-7-jdk