Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from __future__ import print_function
import pygame
import serial
import sys
SABERTOOTH_PORT_NAME = '/dev/ttyUSB0'
SABERTOOTH_PORT_BAUDRATE = 9600
@d2rk
d2rk / pi_speech_recognition.sh
Created February 23, 2014 12:16
Speech recognition with Raspberry Pi and Google Speech API
#!/bin/bash
echo "Recording, press ctrl+c to stop..."
arecord -D "plughw:1,0" -q -f cd -t wav | ffmpeg -loglevel panic -y -i - -ar 16000 -acodec flac speech.flac > /dev/null 2>&1
echo "Processing..."
wget -q -U "Mozilla/5.0" --post-file speech.flac --header "Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium" | cut -d\" -f12 > speech.txt
echo -n "You said: "
cat speech.txt
@d2rk
d2rk / .emacs
Last active August 29, 2015 14:02
Emacs config
;; -*- coding: utf-8; mode: emacs-lisp; -*-
;;
;; Copyright (c) 2011-2014 Oleksandr Sviridenko
;; Show line number.
(setq linum-mode 1)
;; Help fill-paragraph.
(setq-default fill-column 80)
;; Show column number.
@d2rk
d2rk / Makefile
Last active August 29, 2015 14:10
Test four-wire stepper motor with Propeller QuickStart board and L298N stepper motor driver
.PHONY: all clean
TARGET = test_stepper_motor
WRITE_TO_EEPROM ?= true
# See https://sites.google.com/site/propellergcc/documentation for details.
MEMORY_MODEL ?= lmm
BOARD = QUICKSTART
@d2rk
d2rk / test_stepper_motor.c
Created December 27, 2014 10:45
Test four-wire stepper motor with Propeller QuickStart board and A4988 stepper motor driver
/*
* Press button FORWARD_BUTTON_ID to drive forward/backward and BACKWARD_BUTTON_ID to drive backward/forward respectively.
*
* How to compile:
* $ propeller-elf-gcc -mlmm -std=c99 test_stepper_motor.c -o test_stepper_motor
*
* How to load (EEPROM) and run:
* $ propeller-load -r -e test_stepper_motor
*/
@d2rk
d2rk / README.md
Last active March 16, 2020 14:37
OpenWrt 3.14.27 and OpenVPN client for CactusVPN

You can use Ubuntu configuration files from https://www.cactusvpn.com/downloads/ to setup OpenVPN.

How to setup OpenVPN client for CactusVPN:

  1. Update configuration files.
  2. Start OpenVPN as /etc/init.d/openvpn start or make it start at boot as /etc/init.d/openvpn enable.

You can also start OpenVPN client manually as follows:

@d2rk
d2rk / test.c
Created May 13, 2015 23:47
Crawler board test
#include <propeller.h>
#include <stdlib.h>
#define STP1_PIN 19
#define DIR1_PIN 18
#define STP2_PIN 17
#define DIR2_PIN 16
#define STEP_DELAY 10
import RPi.GPIO as GPIO
import time
LED_PINS = (31, 33, 35, 37)
BUTTON_PIN = 29
GPIO.setmode(GPIO.BOARD) # use board pin numbering
for i in LED_PINS:
GPIO.setup(i, GPIO.OUT)
@d2rk
d2rk / gist:ff270651463e53b0b093d836d4869dd7
Created September 5, 2016 12:35
Install tmux 2.2 on Ubuntu 14.04
$ apt-get install automake cmake
$ git clone -b 2.2 https://github.com/tmux/tmux /opt/tmux
$ cd /opt/tmux
$ sh autogen.sh
$ ./configure
$ make
$ /opt/tmux/tmux -V
@d2rk
d2rk / flush_database.py
Created September 27, 2016 09:15
Flush Django database (postgresql)
from django.db import connection
from django.core.management import call_command
cursor = connection.cursor()
cursor.execute("DROP SCHEMA public CASCADE;")
cursor.execute("CREATE SCHEMA public;")
call_command('migrate')