Skip to content

Instantly share code, notes, and snippets.

x <- sample(-50:50,50) # select 50 values between -50 and +50 with replacement - consider option replace=F
y <- 2*x + 1 # linearly correlated data
plot(x,y)
r <- runif(50, 1.0, 40.0) # generate 50 random numbers between 1 and 40
y_1 <- y+ r # Correlated but not exact
plot(x,y_1)
@mihids
mihids / correlated_data.R
Created July 27, 2012 01:38
correlated data
x <- sample(-50:50,50) # select 50 values between -50 and +50 with replacement - consider option replace=F
y <- 2*x + 1 # linearly correlated data
plot(x,y)
r <- runif(50, 1.0, 40.0) # generate 50 random numbers between 1 and 40
y_1 <- y+ r # Correlated but not exact
plot(x,y_1)
@mihids
mihids / 0_reuse_code.js
Created April 11, 2014 11:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#include <iostream>
using namespace std;
int main()
{
int numbers[] = {11,21,13,41,9,10,29,2,12,0,12};
int highest = numbers[0];
int second_highest = numbers[1];
@mihids
mihids / AirCraft.cpp
Created May 23, 2014 09:55
Mediator_Pattern
#include "AirCraft.h"
#include "Mediator.h"
AirCraft::AirCraft(Mediator* med) {
med_ = med;
}
AirCraft::AirCraft(const AirCraft& orig) {
}
@mihids
mihids / StringToTime.h
Created June 13, 2014 04:00
Convert a string in the 24h format HH:mm:ss to time_t
#include <time.h>
#include <string>
#include <stdlib.h>
inline time_t StringToTime(std::string time_24h) {
time_t theTime = time(NULL);
struct tm *aTime = localtime(&theTime);
std::string delimiter = ":";
@mihids
mihids / Logger.cpp
Last active August 29, 2015 14:02
A freind fnction and a friend class
#include <iostream>
#include <ctime>
#include <sstream>
#include <fstream>
using namespace std;
// timestamp returns the current time as a string
std::string timestamp();
@mihids
mihids / problem1
Created September 2, 2014 11:00
Factorial for any number
/*
* File: main.cpp
* Author: mihiranad
*
* Created on August 28, 2014, 12:18 PM
*/
#include <cstdlib>
#include <cstring>
#include <iostream>
@mihids
mihids / primes
Created September 3, 2014 06:40
Prime Numbers
void printPrimeNumbers(unsigned int num) {
std::list<unsigned int> listPrimes;
listPrimes.push_back(2);
listPrimes.push_back(3);
listPrimes.push_back(5);
listPrimes.push_back(7);
std::string sNum;
unsigned int iNum;
unsigned int sqrt1;
#!/bin/bash
print_usage (){
echo “USAGE:”
echo -e “\t $figtex2ps inputfile.fig”
}
#Compile Xfig figures with LaTeX commands
if [ "$1" = "" ]; then
print_usage