best apperence for coder in putty code example
Example 1: documentation for https://www.googleapis.com/oauth2/v4/token
>>>
>>> client_id = '<the id you get from google>.apps.googleusercontent.com'
>>> client_secret = '<the secret you get from google>'
>>> redirect_uri = 'https://your.registered/callback'
>>>
>>> authorization_base_url = "https://accounts.google.com/o/oauth2/v2/auth"
>>> token_url = "https://www.googleapis.com/oauth2/v4/token"
>>> scope = [
... "https://www.googleapis.com/auth/userinfo.email",
... "https://www.googleapis.com/auth/userinfo.profile"
... ]
>>> from requests_oauthlib import OAuth2Session
>>> google = OAuth2Session(client_id, scope=scope, redirect_uri=redirect_uri)
>>>
>>> authorization_url, state = google.authorization_url(authorization_base_url,
...
...
... access_type="offline", prompt="select_account")
>>> print 'Please go here and authorize,', authorization_url
>>>
>>> redirect_response = raw_input('Paste the full redirect URL here:')
>>>
>>> google.fetch_token(token_url, client_secret=client_secret,
... authorization_response=redirect_response)
>>>
>>> r = google.get('https://www.googleapis.com/oauth2/v1/userinfo')
>>> print r.content
Example 2: how to make a shell in c for beginners
int main(void) {
for (;;) {
char input[PRMTSIZ + 1] = { 0x0 };
char *ptr = input;
char *args[MAXARGS + 1] = { NULL };
int wstatus;
// prompt
printf("%s ", getuid() == 0 ? "#" : "$");
fgets(input, PRMTSIZ, stdin);
// ignore empty input
if (*ptr == '\n') continue;
// convert input line to list of arguments
for (int i = 0; i < sizeof(args) && *ptr; ptr++) {
if (*ptr == ' ') continue;
if (*ptr == '\n') break;
for (args[i++] = ptr; *ptr && *ptr != ' ' && *ptr != '\n'; ptr++);
*ptr = '\0';
}
// built-in: exit
if (strcmp(EXITCMD, args[0]) == 0) return 0;
// fork child and execute program
signal(SIGINT, SIG_DFL);
if (fork() == 0) exit(execvp(args[0], args));
signal(SIGINT, SIG_IGN);
// wait for program to finish and print exit status
wait(&wstatus);
if (WIFEXITED(wstatus)) printf("<%d>", WEXITSTATUS(wstatus));
}
}