Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Bjäreholt johan-bjareholt

View GitHub Profile
View Find country codes of all tcp connections
#!/bin/bash
# 1. ss
# 2. Remove header
# 3. Only print ip
# 4. RegEx away port number
IPS=$(ss --tcp | tail -n +2 | awk '{ print $5 }' | sed -e 's/\(.*\):.*/\1/g')
COUNTRIES=""
for IP in $IPS; do
# 1. Geoiplookup
@johan-bjareholt
johan-bjareholt / Speech recognition
Created Dec 8, 2015
Speech recognition on linux using Google Speech API
View Speech recognition
#!/bin/bash
# Record from mic
arecord -d 3 -f cd -t wav -r 16000 -c 1 -D pulse test.wav
# Get record volume
sox test.wav -n stats -s 16 2>&1 | grep 'Max level' | awk '{print $3}'
# Convert to flac for smaller footprint
flac -f test.wav
# Google speech recognition
LANG=en-us
View local_computers_scanner.py
#!/usr/bin/env python3
import socket
import subprocess
import os
import netifaces
debug = True
def start():
View gist:3b2432c42a04f99f83af
class EventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
return false;
}
};
/*
View floppy test 3
int directionPin = 0;
int activationPin = 1;
boolean activationState = LOW;
boolean directionState = LOW;
int currentPosition = 0;
int maxPosition = 1;
void setup(){
pinMode(directionPin, OUTPUT);
View floppy test 2
#include <TimerOne.h>
boolean firstRun = true; // Used for one-run-only stuffs;
//First pin being used for floppies, and the last pin. Used for looping over all pins.
const byte FIRST_PIN = 2;
const byte PIN_MAX = 17;
#define RESOLUTION 40 //Microsecond resolution for notes
View floppy test
int directionPin = 0;
int activationPin = 1;
int btnPin = 2;
int directionState = 0;
int btnState = 0;
int currentState = LOW;
int currentPosition = 0;
View gist:8761009
bool check_function(const char function_name[], const char input[]){
int len = 0;
while (function_name[len] != NULL){
len++;
}
if (strncmp(input, function_name, len) == 0) {
return true;
}
else {
return false;
You can’t perform that action at this time.