Skip to content

Instantly share code, notes, and snippets.

View nachivpn's full-sized avatar

Nacho nachivpn

View GitHub Profile
@nachivpn
nachivpn / cfu.sh
Last active August 29, 2015 14:01
Script to check for result updates on nitc results page
##!/bin/bash
file1="index.html"
file2="old_index.html"
link_file1="link"
link_file2="old_link"
clear
#downloading index.html
@nachivpn
nachivpn / EO_example.c
Last active August 29, 2015 14:01
LEX Program to scan for even and oddd numbers
%{
/*
1.Request input of an even and an odd number
2.indicate input characteristic : Even/Odd
3.check for input's correctness and print result
*/
#include <stdlib.h>
#include <stdio.h>
@nachivpn
nachivpn / yywrap_usage_example.c
Created May 23, 2014 09:17
Custom usage of yywrap() in a LEX program
/* Declarations */
%%
/* Rules */
%%
int yywrap()
{
@nachivpn
nachivpn / yytext_usage_example.c
Last active August 29, 2015 14:01
Example usage of yytext in a LEX program
{%
#include <stdlib.h>
#include <stdio.h>
%}
number [0-9]+
%%
{number} {printf("Found : %d",atoi(yytext));}
@nachivpn
nachivpn / TS_example.c
Last active August 29, 2015 14:01
LEX Program to simulate tokens
%{
/* Scan and return a token for identifiers of the format :
string number
Note: strings are not case sensitive
Examples: a0 , A1 , ab2 , AB4 , aBc5
*/
@nachivpn
nachivpn / yyin_usage_example.c
Created May 23, 2014 10:00
Custom usage of yyin in a LEX program
/* Declarations */
%%
/* Rules */
%%
main(int argc, char* argv[])
{
if(argc > 1)
{
@nachivpn
nachivpn / yylex_usage_example.c
Created May 23, 2014 10:05
Usage of yylex() in a LEX program
/* Declarations */
%%
{number} {return atoi(yytext);}
%%
int main()
{
@nachivpn
nachivpn / autossh.sh
Created July 13, 2014 07:23
Script to automate ssh connections (for mac as brew won't let you install sshpass -.-)
#!/usr/bin/expect -f
#
#credits: http://casual-effects.blogspot.in/2013/05/ssh-with-command-line-password-on-os-x.html
set host "host"
set password "password"
spawn ssh $host
expect {
@nachivpn
nachivpn / noscpcopy.sh
Created July 16, 2014 07:15
Copy a file via ssh
cat file | ssh -p [port] user@host "cat > remotefile"
@nachivpn
nachivpn / autossh&.sh
Last active August 9, 2023 23:03
Running an expect script in the background
#!/usr/bin/expect -f
set host "host"
set password "password"
spawn ssh $host
expect {
"(yes/no)?" {
send -- "yes\r"