Skip to content

Instantly share code, notes, and snippets.

View infomaven's full-sized avatar

Nadine Whitfield infomaven

  • Independent Software Developer
  • USA
View GitHub Profile
@infomaven
infomaven / fizzbuzz.js
Created March 1, 2015 07:39
FizzBuzz algorithm in javascrjipt
for (var i =1; i < 21; i++) {
if( i%3 === 0 && i%5 === 0 ) {
console.log("FizzBuzz");
} else if ( i%5 === 0 ) {
console.log("Buzz");
} else if (i%3 === 0 ) {
console.log("Fizz");
} else {
console.log(i);
}
package sensorData
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._ // maybe not needed?
import scala.concurrent.duration._
import com.redis._
import io.gatling.redis.feeder._
object Settings {
final val Host = "host"
final val Protocol = "protocol"
object User {
final val Name = "username"
final val Password = "password"
}
object Subject {
@infomaven
infomaven / GatlingMultiConfigSimulation
Created November 5, 2014 08:36
Enables user to select between different execution profiles from the same Gatling Simulation class file
val httpProtocol = http.baseURL("http://localhost:8000")
case class TestSetup(repeat: Int, users: InjectionStep, label: String) // <-- config holder
val sequentialUserTest = TestSetup(repeat = 100, atOnce(1 user), "sequential 1 user")
val oneUserPer4sTest = TestSetup(repeat = 2, constantRate(0.25 userPerSec).during(5 minutes), "1 usr/4s, 2 req / user")
val threeCentIn5Mins = TestSetup(repeat = 5, ramp(300).over(5 minute), "300 usr w/ 5 req in 5 mins")
val testSetUp = sequentialUserTest // <-- config selection (could be also done at runtime)
While you can get the public and private IP address of your Amazon EC2 instance via the AWS Console, it may be extremely useful to query it from anywhere you can make an HTTP request, such a shell script. The operation is really simple, just make a GET request to the following URL from within your EC2 instance:
Local IP:
curl http://169.254.169.254/latest/meta-data/local-ipv4
Public IP:
curl http://169.254.169.254/latest/meta-data/public-ipv4
I often use this feature to pre-configure services and update configuration files, as in EC2 you get a new IP Address each time you reboot
// create an alternative method for getting a list of defined enums to avoid system creating a clone of the String array
// this is the .values() method
public enum Car {
TESLA, VOLVO, TOYOTA;
}
// normally what would happen
public static Car[] values() {
return (Car[])$VALUES.clone();
@infomaven
infomaven / gist:b68be75d6634bb91c6bc26c0f766bb26
Created December 19, 2016 20:02
HowTo: convert Maven to Gradle && Gradle to Maven
/* MAVEN TO GRADLE */
- Navigate to directory where the POM is located
- Run gradle init
> this will convert the Maven build to Gradle build (new settings.gradle & one or more build.gradle files)
/* GRADLE TO MAVEN */
- Add Maven plugin to build.gradle file
ex.
apply plugin: 'java'
@infomaven
infomaven / gist:783c39cbddaf65c5a4c261d9c9ab9ae0
Created December 20, 2016 18:58
String array manipulations
/*
Take note of length - it is used as a String[] property > strings.length AND as a method for a String
array element > strings[i].length().
*/
public Map<String, String> pairs(String[] strings) {
Map<String,String> map = new HashMap<String,String>();
for (int i = 0; i < strings.length; i++ ) {
if (strings[i].length() == 1 ) {
Character first = strings[i].charAt(0);
@infomaven
infomaven / JS-questions.txt
Last active March 19, 2017 05:02
Technical questions
What is the difference between "express": "^4.13.3" and "express": "~4.13.3" ?
What happens if I use `npm install <package> --save` instead of `npm install <package> --save-dev` ?
@infomaven
infomaven / aws_launch_init.sh
Last active June 18, 2017 23:19
aws_healthcheck.html
#!bin/bash
yum install httpd -y
yum update -y
aws s3 cp s3://mywebbucket-cloudguru /var/www/html/ --recursive
service httpd start
chkconfig httpd on