Skip to content

Instantly share code, notes, and snippets.

View gon1332's full-sized avatar
🛀
bitbathing

Ioannis Konstantelias gon1332

🛀
bitbathing
  • Camlin Group
  • Belfast, UK
View GitHub Profile
@gon1332
gon1332 / fix_vbox_usb.sh
Last active October 14, 2023 15:15
VirtualBox+Ubuntu: Fix USB device list not showing
#!/bin/bash
#
# Heavily inspired by https://github.com/dnschneid/crouton/wiki/VirtualBox-udev-integration
#
vbox_usbnode_path=$(find / -name VBoxCreateUSBNode.sh 2> /dev/null | head -n 1)
if [[ -z $vbox_usbnode_path ]]; then
echo Warning: VBoxCreateUSBNode.sh file has not been found.
exit 1
@gon1332
gon1332 / isletter2.c
Last active May 31, 2017 08:13
Alternative way to check whether an ascii character is a letter or not.
#include <stdio.h>
#define TOLOWER(c) ((c) | 0x20)
#define ISLETTER(c) ((unsigned char)(TOLOWER(c) - 'a') < 26)
int main(int argc, char *argv[])
{
if (argc != 2 || argv[1][1] != '\0') {
puts("Usage: isletter <character>");
return 1;
@gon1332
gon1332 / isletter1.c
Last active May 31, 2017 07:57
Check whether an ascii character is a letter or not.
/*
* Thanks to my friend Chrysostomos for the solution.
*/
#include <stdio.h>
int bin_search(int key, int left, int right)
{
while (left <= right) {
int middle = (left + right) / 2;
@gon1332
gon1332 / human_strcmp.c
Last active August 29, 2015 14:04
Compare strings in C in a more physical way
#include <stdio.h>
#include <string.h>
#define STRCMP(a, R, b) (strcmp(a,b) R 0)
int main(void)
{
char *s = "John";
if (STRCMP("john", ==, s))
fputs("The same", stdout);
@gon1332
gon1332 / line_seperator.c
Last active August 29, 2015 14:04
Print separated data in C the right way
#include <stdio.h>
void generate_initializer(char *string, const char *separator)
{
static char *sep = "";
printf("%s%s", sep, string);
sep = separator;
}
int main(void)