- In target terminal type
tty - copy the result (should be something like
/dev/pts/0 - in gdb window type
tty <pasted-result>
- enable
| import socket | |
| fd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM ) | |
| fd.settimeout(1) | |
| udp_ip = '10.82.2.254' | |
| udp_port = 4001 | |
| while(True): | |
| message = input("> ")+"\r" | |
| fd.sendto(message.encode(), (udp_ip, udp_port)) | |
| while(True): | |
| try: |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| typedef struct Node_t | |
| { | |
| int data; | |
| struct Node_t* left; | |
| struct Node_t* right; |
| static inline void Exchange(int* data, int a, int b) { | |
| int temp = data[a]; | |
| data[a]=data[b]; | |
| data[b]=temp; | |
| } | |
| //generates all permutations of initially sorted array `a` with `n` elements | |
| //returns 0 when no more permutations exist | |
| int genPermutation(int a[], int n) | |
| { |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| void sort(int A[], int N) { | |
| int i,count; | |
| int *R = calloc(N,sizeof(int)); | |
| do { | |
| count=0; | |
| for (i=0;i<N;i++) { if (A[i]) { count++; A[i]--;} } |
| /* | |
| WRS.c | |
| (c) AShelly (github.com/ashelly) | |
| Weighted random sampling with replacement of N items in O(1) time. | |
| (After preparing a O(N) sized buffer in O(N) time.) | |
| The concept is: | |
| Randomly select a buffer index. Each index is selected with probablilty 1/N. | |
| Each index stores the fraction of hits for which this item should be selected, |
| import sys,os | |
| import termios | |
| import tty | |
| from contextlib import contextmanager | |
| import signal | |
| """ Allow single-key keyboard input (no <enter> needed) | |
| Sample Usage: |
| #!/usr/bin/python | |
| import sys,json,re,subprocess | |
| try: | |
| file = open(sys.argv[1]) | |
| l = file.read() | |
| try: | |
| json.loads(l) | |
| print "OK" | |
| except Exception as e: |
| //set only one of the following to 1. | |
| #define OPTION_PRIMARY 1 | |
| #define OPTION_ALTERNATE 0 | |
| #define OPTION_UNLIKELY 0 | |
| //Did you follow the rules? | |
| #if ((OPTION_PRIMARY+OPTION_ALTERNATE+OPTION_UNLIKELY)!=1) | |
| #error("Error configuring options") | |
| #endif |
| socat PTY,link=/dev/ttyFAKE0,raw,echo=0 READLINE | |