Skip to content

Instantly share code, notes, and snippets.

@mihids
mihids / GenerateFiles.sh
Last active March 23, 2018 17:16
shell script samples for studying loops and creating removing folders/files
LOGIN_FILE="login"
space=" "
for i in `seq 1 10`;
do
CURR_FILE="$LOGIN_FILE""$i"
rm $CURR_FILE 2> /dev/null
touch $CURR_FILE
cat header.in | tr -d '\n' >> $CURR_FILE
touch temp.in
@mihids
mihids / convBoost.cpp
Created April 28, 2015 07:26
Converting data types to adn from strings in C++
#include <boost/lexical_cast.hpp>
inline std::string IntToString(unsigned int _uiIntToConvert) {
MODT_LOG_DEBUG(octopus::getRootLogger(), "EODUtils::IntToString", "Int to convert: [" << _uiIntToConvert << "]");
std::string sRet;
try {
sRet = boost::lexical_cast< std::string >(_uiIntToConvert);
} catch (boost::bad_lexical_cast&) {
sRet = "";
#include <stdio.h>
#include <iostream>
#include <string.h>
struct Item {
int i;
char buf1[10];
char buf2[20];
};
@mihids
mihids / bind_callbacks.cpp
Last active November 16, 2016 13:36
boost bind and boost function for callbacks
#include <cstdlib>
#include <boost/bind.hpp>
#include <boost/function.hpp>
class A {
public:
void print(const std::string &s) {
std::cout << s << std::endl;
}
@mihids
mihids / func_pointer.cpp
Last active August 29, 2015 14:14
Using function pointers for C++ class member function callbacks
#include <cstdlib>
#include <iostream>
class A {
public:
int callback(float variable) {
int result =6;
std::cout << "Callback invoked with result: " << result + variable << std::endl;
return result;
}
@mihids
mihids / daemon.c
Last active August 29, 2015 14:14
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
#!/bin/sh
# $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $
# Convert PDF to encapsulated PostScript.
# usage:
# pdf2eps <page number> <pdf file without ext>
pdfcrop $2.pdf
pdftops -f $1 -l $1 -eps "$2-crop.pdf"
rm "$2-crop.pdf"
mv "$2-crop.eps" $2.eps
#!/bin/bash
print_usage (){
echo “USAGE:”
echo -e “\t $figtex2ps inputfile.fig”
}
#Compile Xfig figures with LaTeX commands
if [ "$1" = "" ]; then
print_usage
@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;
@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>