GithubHelp home page GithubHelp logo

miguelvps / c Goto Github PK

View Code? Open in Web Editor NEW
15.0 5.0 14.0 151 KB

c is a 'cd' wrapper that fuzzy finds and cd into a directory.

License: GNU General Public License v3.0

C 92.39% Shell 1.09% Perl 6.52%

c's Introduction

NAME

c - a 'cd' wrapper

SYNOPSIS

c [-chisv] [-l LIBRARY] [-m MATCHER] [-t THRESHOLD] [directory]

DESCRIPTION

c is a 'cd' wrapper that fuzzy finds and cd into directory.

For instance, if you have foo/bar and fo/foo directories and run 'c f/b' you'll end up in foo/bar directory.

OPTIONS

-c

Do bash completion.

-h

Print usage information.

-i

Do insensitive case completion.

-l LIBRARY

Select the shared library where MATCHER is found.

-m MATCHER

Set the aproximate string matching function. See -l.

-s

Simulate. Print all matching directories.

-t THRESHOLD

Set the threshold ([0,1]).

-v

Print version information.

ENVIRONMENT

Defines a c() function that wraps shell 'cd'.

If set, $_C_OPTS will be passed as arguments.

EXAMPLE

c foo

cd to the directory with name most similar to foo.

c -t 0.75 foo

cd to the directory with name most similar to foo using a threshold of 75%.

c -l liblevenshtein.so -m normalized_levenshtein_distance foo

cd to the directory with name most similar to foo using a levenshtein distance algorithm instead of the default.

AUTHOR

Miguel Serrano <miguelvps at gmail.com>

HOMEPAGE

http://github.com/miguelvps/c

SEE ALSO

cd, cdargs, autojump, z

c's People

Contributors

miguelvps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

c's Issues

Infix

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* infixToPostfix(char* infix){
struct stack * sp = (struct stack *) malloc(sizeof(struct stack));
sp->size = 10;
sp->top = -1;
sp->arr = (char *) malloc(sp->size * sizeof(char));
char * postfix = (char *) malloc((strlen(infix)+1) * sizeof(char));
int i=0; // Track infix traversal
int j = 0; // Track postfix addition
while (infix[i]!='\0')
{
if(!isOperator(infix[i])){
postfix[j] = infix[i];
j++;
i++;
}
else{
if(precedence(infix[i])> precedence(stackTop(sp))){
push(sp, infix[i]);
i++;
}
else{
postfix[j] = pop(sp);
j++;
}
}
}
while (!isEmpty(sp))
{
postfix[j] = pop(sp);
j++;
}
postfix[j] = '\0';
return postfix;
}

int isOperator(char ch){
if(ch=='+' || ch=='-' ||ch=='*' || ch=='/')
return 1;
else
return 0;
}

int precedence(char ch){
if(ch == '*' || ch=='/')
return 3;
else if(ch == '+' || ch=='-')
return 2;
else
return 0;
}
struct stack
{
int size;
int top;
char arr;
};
int stackTop(struct stack
sp){
return sp->arr[sp->top];
}
int isEmpty(struct stack ptr)
{
if (ptr->top == -1)
{
return 1;
}
else
{
return 0;
}
}
int isFull(struct stack ptr)
{
if (ptr->top == ptr->size - 1)
{
return 1;
}
else
{
return 0;
}
}
void push(struct stack
ptr, char val){
if(isFull(ptr)){
printf("Stack Overflow! Cannot push %d to the stack\n", val);
}
else{
ptr->top++;
ptr->arr[ptr->top] = val;
}
}
char pop(struct stack
ptr){
if(isEmpty(ptr)){
printf("Stack Underflow! Cannot pop from the stack\n");
return -1;
}
else{
char val = ptr->arr[ptr->top];
ptr->top--;
return val;
}
}

int main()
{
char * infix = "x-y/z-k*d";
printf("postfix is %s", infixToPostfix(infix));
return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.