Instantly share code, notes, and snippets.

View nodejs
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - \
&& sudo apt-get install -y nodejs
View hello_world.sh
#!/bin/bash
# My first script
echo "Hello $USER"
echo "Hey I am " $USER " and will be telling you about the current processes"
echo "Running processes list"
ps
View copy.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
int main(int argc, int **argv) {
char ch;
FILE *source, *target;
char source_file[40], target_file[40];
View opendir.c
/**
This example reads the contents of a root directory.
Reference: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxbd00/rtread.htm
*/
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
View fread.c
/**
Author: Adrian Statescu <http://adrianstatescu.com>
How does fread really work?!
The declaration of FREAD is as following:
size_t fread(void *ptr, size_t size, size_t nmem, FILE *stream)
There may or may not be any difference in performance. There is a difference in semantics.
fread(a, 1, 1000, stdin); -> attempts to read 1000 data elements each of which is 1 byte long
fread(a, 1000, 1, stdin); -> attempts to read 1 data element which is 1000 bytes long
View Combsort.c
#include <stdio.h>
#include <malloc.h>
#define FIN "algsort.in"
typedef int (*Comparer)(int, int);
typedef void (*fnPtr)(int*, int, Comparer);
int sort_asc(int a, int b) {
View perianderOfCorinth.c
#include <stdio.h>
#include <malloc.h>
#define FIN "algsort.in"
#define FOUT "algsort.out"
//pointer to function
typedef void (*fnPtr)(int*,int);
void combsort(int *p, int n) {
View erathostenes.cpp
#include <iostream>
#include <fstream>
typedef unsigned long ulong;
typedef unsigned int uint;
namespace Erathostenes {
ulong getCount(ulong n) {
View subsets.cpp
#include <iostream>
#include <fstream>
#include <vector>
#define FIN "submultimi.in"
#define FOUT "submultimi.out"
using namespace std;
int main() {
View belongPointCircle.c
/**
* Adrian Statescu <http://adrianstatescu.com>
* Input -> n circle and one Point
* Output -> belong or not on disk.
*/
#include <stdio.h>
#include <math.h>
#define SIZE 50
typedef struct TypePoint {