Skip to content

Instantly share code, notes, and snippets.

View amites's full-sized avatar

Alvin Mites amites

View GitHub Profile
@amites
amites / webclient_dht.ino
Created February 3, 2013 03:16
For an Arduino -- pulls sensor data from 2 DHT11's and uploads to a remote server using a GET call over an ethernet shield requires libraries from Adafruit for the DHT & EtherCard
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
#define DHTPIN2 3 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
from livereload.task import Task
def delay():
import time
time.sleep(10) # 10s
Task.add('*', delay)
@amites
amites / .bash_aliases
Created January 28, 2014 07:07
My standard ubuntu server bash aliases, most are also good on a workstation.
## Quick Bash ##
function absolute_path { echo "$PWD/$1"; }
alias ap="absolute_path"
alias edbash='vim $HOME/.bash_aliases'
alias upbash='source $HOME/.bashrc'
## apache ##
alias apr='sudo apachectl graceful'
alias apc='sudo apachectl'
def Integer(obj):
if obj["min"] < obj["value"] < obj["max"]:
return True
else:
raise ValueError("value out of range")
min_tile_size = {"type": Integer,
"min": 10,
"max": 20,
"value": 15,
@amites
amites / centos_install_compass.sh
Last active December 3, 2017 22:39
bash script to install sass/compass onto centos
#! /bin/bash
# Sass: http://sass-lang.com/
# Sass is a "smart" form of css, supporting nested targeting of html, variables and logic
# scss is a variant of sass using a syntax much closer to css
# Compass: http://compass-style.org/
# Compass is a sass framework containing a range of shortcuts for cross-browser css effects.
# rounded corners, transparency...
function control_zone() {
this.var_a = 'a';
this.var_b = 'b';
this.var_c = 'c';
this.do_stuff = function() {
// do stuff with variables
console.log('var_a: '+this.var_a);
console.log('var_b: '+this.var_b);
console.log('var_c: '+this.var_c);
@amites
amites / setup_TP-WN722NC.sh
Last active September 5, 2015 05:49
Bash script to setup a TL-WN722NC as an available wifi dongle onto a bbb.
#!/bin/bash
# install linux headers
wget https://raw.github.com/gkaindl/beaglebone-ubuntu-scripts/master/bb-get-rcn-kernel-source.sh
chmod +x bb-get-rcn-kernel-source.sh
sudo ./bb-get-rcn-kernel-source.sh
# download backports drivers
wget https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.16/backports-3.16-1.tar.gz
tar xvfz backports-3.16-1.tar.gz
# solution to entry problem 1
def multiply(a, b):
return a * b
# solution to entry problem 2
class Person:
def __init__(self, name):
self.name = name
@amites
amites / camel_case.py
Created September 10, 2016 16:28
Camel Case Code Wars
# https://www.codewars.com/kata/convert-string-to-camel-case/train/python
def to_camel_case(text):
text_list = text.replace('-', '_').split('_')
answer_list = [text_list[0], ]
for word in text_list[1:]:
answer_list.append( word.title() )
return ''.join(answer_list)
@amites
amites / setup_django_project.md
Last active September 19, 2016 16:31
README to setup a new django project.

In Terminal run the following commands

    virtualenv  VIRTUALENV_NAME
    cd VIRTUALENV_NAME
    source bin/activate
    pip install django ipython